Skip to content

Commit

Permalink
Execute all scripts before publish (#6)
Browse files Browse the repository at this point in the history
* fix(test): redis adapter

* ci: check

* ups

* fix: xd?

* redis?

* ups 2
  • Loading branch information
socram03 authored Sep 13, 2024
1 parent 0400325 commit 07dff61
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 54 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build, Lint, Format & Publish
on:
push:

jobs:
build:
runs-on: ubuntu-latest

services:
redis:
image: redis:latest
ports:
- 6379:6379

steps:
- name: check out code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

# For some reason, in actions, run check can execute test before build
- name: Run formating
run: pnpm run format lint
id: biome

- name: Building
run: pnpm run build
id: build

- name: Testing
run: pnpm run test
id: test

- name: Commit and Push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
if ! git diff-index --quiet HEAD; then
git commit -m "chore: apply formatting"
git push origin HEAD:${{ github.ref }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HUSKY: 0

- name: Publish in pkg.pr.new
run: pnpx pkg-pr-new publish './packages/*'
if: github.repository == 'tiramisulabs/extra'
25 changes: 0 additions & 25 deletions .github/workflows/pkg.yml

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"format": "turbo format"
"format": "turbo format",
"test": "turbo test",
"check": "turbo run lint format build test"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/cooldown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"build": "tsc",
"lint": "biome lint --write ./src",
"format": "biome format --write ./src",
"turbo:build": "turbo build",
"test": "pnpm turbo:build && node --test ./test/*"
"test": "node --test ./test/*"
},
"devDependencies": {
"@types/node": "^22.4.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/cooldown/test/manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('CooldownManager', async () => {
const handler = new CommandHandler(new Logger({ active: true }), client);
cooldownData = {
type: CooldownType.User,
interval: 10000,
interval: 1000,
uses: 3
}
handler.values = [
Expand All @@ -39,7 +39,7 @@ describe('CooldownManager', async () => {
const data = cooldownManager.getCommandData('testCommand');
assert.deepEqual(data, {
type: CooldownType.User,
interval: 10000,
interval: 1000,
uses: 3
});
});
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('CooldownManager', async () => {
cooldownManager.use('testCommand', 'user1');

// Simulate time passing
await new Promise(resolve => setTimeout(resolve, 10000));
await new Promise(resolve => setTimeout(resolve, 1000));

const data = cooldownManager.resource.get('testCommand:user:user1');
const props = cooldownManager.getCommandData('testCommand');
Expand Down
14 changes: 4 additions & 10 deletions packages/redis-adapter/test/cache.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { describe, test, after, before } = require('node:test');
const { Cache, Client } = require('seyfert');
const { describe, test } = require('node:test');
const { Client } = require('seyfert');
const { RedisAdapter } = require('../lib/index');
const { setTimeout } = require('node:timers/promises');
const { doesNotThrow } = require('node:assert/strict');

// all intents
Expand Down Expand Up @@ -33,13 +32,8 @@ describe('Test Adapter cache', async t => {
}
})
await client.cache.testAdapter();
});
await setTimeout(2e3);
});


after(async () => {
await adapter.flush()
await adapter.client.quit();
await adapter.client.quit();
});
});
});
21 changes: 8 additions & 13 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
"ui": "tui",
"tasks": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"lib/**"
]
"dependsOn": ["^build"],
"outputs": ["lib/**"]
},
"lint": {
"dependsOn": [
"^lint"
]
"dependsOn": ["^lint"]
},
"format": {
"dependsOn": [
"^format"
]
"dependsOn": ["^format"]
},
"test": {
"dependsOn": ["^test"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}
}

0 comments on commit 07dff61

Please sign in to comment.