diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ba7ffc4 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/prod.yaml b/.github/workflows/prod.yaml index 0e105b1..f6825f1 100644 --- a/.github/workflows/prod.yaml +++ b/.github/workflows/prod.yaml @@ -24,62 +24,69 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: 16 - - - name: Install dependencies - run: bun install - - - name: Run tests - env: - DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/mydb' - run: bun test - - + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Install dependencies + run: yarn install + + - name: Run tests + env: + DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/mydb' + run: yarn test + + - name: Run packageChanges and publishPackage + run: | + if [ ${{ job.status }} == 'success' ]; then + echo "Build job succeeded, running packageChanges and publishPackage" + else + echo "Build job failed, skipping packageChanges and publishPackage" + fi + packageChanges: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 16.x - - name: Navigate to Package Directory - run: | - cd packages/ - yarn install --frozen-lockfile - yarn run lint && yarn run build - + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16.x + + - name: run + run: | + yarn install --frozen-lockfile + yarn run lint && yarn run build + publishPackage: - needs: packageChanges - if: needs.packageChanges.result == 'success' && github.ref == 'refs/heads/main' - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 16.x - - name: Authenticate with NPM - run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc - - name: Create Release Pull Request or Publish - id: changesets - - run: | - cd packages/ - yarn install --frozen-lockfile - yarn run release - - env: - GITHUB_TOKEN: ${{ secrets.GGITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + needs: packageChanges + if: needs.packageChanges.result == 'success' && github.ref == 'refs/heads/main' + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16.x + + - name: Authenticate with NPM + run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc + + - name: Create Release Pull Request or Publish + id: changesets + run: | + yarn install --frozen-lockfile + yarn run release + + env: + GITHUB_TOKEN: ${{ secrets.GGITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/bun.lockb b/bun.lockb index 77f3cf9..de07451 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/tests/migrations/20230912165922507-testing.ts b/tests/migrations/20230912165922507-testing.ts deleted file mode 100644 index d0fc28a..0000000 --- a/tests/migrations/20230912165922507-testing.ts +++ /dev/null @@ -1,15 +0,0 @@ -// // Example: creating a table -// import { Kysely } from 'kysely'; - -// export async function up(database: Kysely): Promise { -// await database.schema -// .createTable('test') -// .addColumn('id', 'serial', (column) => column.primaryKey()) -// .addColumn('name', 'text', (column) => column.notNull()) -// // add more column has needed -// .execute(); -// } - -// export async function down(database: Kysely): Promise { -// database.schema.dropTable('test'); -// } diff --git a/tests/migrations/20230913181627990-bew.ts b/tests/migrations/20230913181627990-bew.ts new file mode 100644 index 0000000..ca9f91c --- /dev/null +++ b/tests/migrations/20230913181627990-bew.ts @@ -0,0 +1,14 @@ +import { Kysely } from 'kysely'; + + export async function up(database: Kysely): Promise { + await database.schema + .createTable('bew') + .addColumn('id', 'serial', (column) => column.primaryKey()) + .addColumn('name', 'text', (column) => column.notNull()) + .execute(); + } + + export async function down(database: Kysely): Promise { + database.schema.dropTable('bew'); + } + \ No newline at end of file diff --git a/tests/run-all-migrations.test.ts b/tests/run-all-migrations.test.ts deleted file mode 100644 index 2f97230..0000000 --- a/tests/run-all-migrations.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -// import { jest, mock, describe, it, expect } from "bun:test"; -// import { runAllMigrations } from "../commands/run-all-migrations"; - -// mock( () => ({ -// Pool: jest.fn(() => ({ -// connect: jest.fn(), -// })), -// })); - - -// mock(() => ({ -// Kysely: jest.fn(), -// Migrator: jest.fn(), -// FileMigrationProvider: jest.fn(), -// })); -// mock(() => ({ -// promises: { -// mkdir: jest.fn(), -// }, -// })); - -// describe('runAllMigrations', () => { -// it('Runs all migrations that have not yet been run', async () => { -// try { -// await runAllMigrations(); - -// expect(true).toBe(true); -// } catch (error) { - -// console.error('Migration failed:', error); -// throw error; -// } -// }); -// });