Skip to content

Commit

Permalink
Update tests for atomicity, prefer /tmp, and add new access control t…
Browse files Browse the repository at this point in the history
…ests (keystonejs#9032)

Co-authored-by: ChrisLaneAU <[email protected]>
  • Loading branch information
dcousens and ChrisLaneAU authored Feb 22, 2024
1 parent 14e444a commit c907dc0
Show file tree
Hide file tree
Showing 105 changed files with 3,755 additions and 7,643 deletions.
22 changes: 22 additions & 0 deletions .github/actions/ci-setup-examples/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'CI setup (w/ examples)'
runs:
using: 'composite'
steps:
- run: corepack enable
shell: bash

- uses: actions/setup-node@main
with:
# preferably lts/*, but we hit API limits when querying that
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: pnpm

# limited to 1 child process, preventing Prisma postinstall races in our examples
- run: pnpm install --child-concurrency 1
shell: bash
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'

- run: pnpm run build
shell: bash
6 changes: 4 additions & 2 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ runs:
registry-url: 'https://registry.npmjs.org'
cache: pnpm

# limited to 1 child process, preventing Prisma postinstall races
- run: pnpm install --child-concurrency 1
- run: rm --recursive --force examples/ tests/test-projects/
shell: bash

- run: pnpm install
shell: bash
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
Expand Down
41 changes: 19 additions & 22 deletions .github/workflows/tests_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
strategy:
fail-fast: false
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
index: [1, 2, 3, 4]
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
run: pnpm jest --ci --runInBand --shard=${{ matrix.index }}/9 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
run: pnpm jest --ci --shard=${{ matrix.index }}/4 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
env:
DATABASE_URL: postgres://testuser:testpass@localhost:5432/test_db

Expand All @@ -46,15 +46,15 @@ jobs:
strategy:
fail-fast: false
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
index: [1, 2, 3, 4]
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
run: pnpm jest --ci --runInBand --shard=${{ matrix.index }}/9 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
run: pnpm jest --ci --shard=${{ matrix.index }}/4 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
env:
DATABASE_URL: file:./file.db
DATABASE_URL: file:./test.db

graphql_api_tests_mysql:
name: API Tests MySQL
Expand All @@ -69,13 +69,13 @@ jobs:
strategy:
fail-fast: false
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
index: [1, 2, 3, 4]
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
run: pnpm jest --ci --runInBand --shard=${{ matrix.index }}/9 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
run: pnpm jest --ci --shard=${{ matrix.index }}/4 api-tests --testPathIgnorePatterns=tests/api-tests/fields/crud
env:
DATABASE_URL: mysql://root:testpass@localhost:3306/test_db

Expand All @@ -99,7 +99,7 @@ jobs:
run: bash ./.github/workflows/s3-bucket.sh

- name: Unit tests
run: pnpm jest --ci --runInBand tests/api-tests/fields/crud
run: pnpm jest --ci tests/api-tests/fields/crud
env:
S3_ENDPOINT: http://127.0.0.1:9000/
S3_FORCE_PATH_STYLE: true
Expand All @@ -108,7 +108,6 @@ jobs:
S3_SECRET_ACCESS_KEY: keystone
# this doesn't mean anything when we're using a custom s3 endpoint but the sdk wants something so we just give it something
S3_REGION: us-east-1
TEST_ADAPTER: postgresql
DATABASE_URL: postgres://testuser:testpass@localhost:5432/test_db

field_crud_tests_sqlite:
Expand All @@ -122,7 +121,7 @@ jobs:
run: bash ./.github/workflows/s3-bucket.sh

- name: Unit tests
run: pnpm jest --ci --runInBand tests/api-tests/fields/crud
run: pnpm jest --ci tests/api-tests/fields/crud
env:
S3_ENDPOINT: http://127.0.0.1:9000/
S3_FORCE_PATH_STYLE: true
Expand All @@ -131,8 +130,7 @@ jobs:
S3_SECRET_ACCESS_KEY: keystone
# this doesn't mean anything when we're using a custom s3 endpoint but the sdk wants something so we just give it something
S3_REGION: us-east-1
TEST_ADAPTER: sqlite
DATABASE_URL: file:./dev.db
DATABASE_URL: file:./test.db

field_crud_tests_mysql:
name: Field CRUD Tests MySQL
Expand All @@ -152,7 +150,7 @@ jobs:
run: bash ./.github/workflows/s3-bucket.sh

- name: Unit tests
run: pnpm jest --ci --runInBand tests/api-tests/fields/crud
run: pnpm jest --ci tests/api-tests/fields/crud
env:
S3_ENDPOINT: http://127.0.0.1:9000/
S3_FORCE_PATH_STYLE: true
Expand All @@ -161,15 +159,14 @@ jobs:
S3_SECRET_ACCESS_KEY: keystone
# this doesn't mean anything when we're using a custom s3 endpoint but the sdk wants something so we just give it something
S3_REGION: us-east-1
TEST_ADAPTER: mysql
DATABASE_URL: mysql://root:testpass@localhost:3306/test_db

examples_tests:
name: Testing example project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-setup-examples

- name: Example unit tests
run: cd examples/testing; pnpm test
Expand All @@ -179,16 +176,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-setup-examples

- name: Example Next in app direcroty build
- name: Example Next in app directory build
run: cd examples/framework-nextjs-app-directory; pnpm build

examples_smoke_tests:
name: Smoke Tests For Examples
runs-on: ubuntu-latest
env:
DATABASE_URL: 'file:./test.db'
DATABASE_URL: file:./test.db
strategy:
matrix:
test:
Expand All @@ -214,7 +211,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-setup-examples

- name: Install Dependencies of Browsers
run: cd tests/examples-smoke-tests && pnpm playwright install-deps chromium
Expand All @@ -223,13 +220,13 @@ jobs:
run: cd tests/examples-smoke-tests && pnpm playwright install chromium

- name: Unit tests
run: pnpm jest --ci --runInBand tests/examples-smoke-tests/${{ matrix.test }}
run: pnpm jest --ci tests/examples-smoke-tests/${{ matrix.test }}

admin_ui_integration_tests:
name: Integration tests for Admin UI
runs-on: ubuntu-latest
env:
DATABASE_URL: 'file:./test.db'
DATABASE_URL: file:./test.db
strategy:
matrix:
test:
Expand All @@ -244,7 +241,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-setup-examples

- name: Install Dependencies of Browsers
run: cd tests/admin-ui-tests && pnpm playwright install-deps chromium
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
- uses: ./.github/actions/ci-setup

- name: Unit tests
run: DATABASE_URL=file:./test.db pnpm jest --ci --runInBand --testPathIgnorePatterns=admin-ui-tests --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=examples/testing
run: DATABASE_URL=file:./test.db pnpm jest --ci --testPathIgnorePatterns=admin-ui-tests --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=examples/testing
Loading

0 comments on commit c907dc0

Please sign in to comment.