Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for atomicity, prefer /tmp, and add new access control tests #9032

Merged
merged 29 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
18a5c87
tidy up createContext, explicit sudo and session arguments
dcousens Feb 21, 2024
23a8438
tidy up field access control for output types
dcousens Feb 21, 2024
b1fab86
pnpm postinstall
dcousens Feb 21, 2024
619c0e6
rename schema.test.ts to omit.test.ts
dcousens Feb 19, 2024
e968b5f
use a different temporary directory for every setupTestRunner call
dcousens Feb 19, 2024
2df4082
dont need testConfig in omit
dcousens Feb 19, 2024
7b647c1
prefer declarative style
dcousens Feb 19, 2024
cfd046a
allow false for omit
dcousens Feb 19, 2024
de278aa
drop redundant ??
dcousens Feb 19, 2024
ddf0341
add new setupTestSuite, to minimise setup cost
dcousens Feb 20, 2024
7d7329c
add new access tests
dcousens Feb 20, 2024
e057d84
add where filtering access tests
dcousens Feb 21, 2024
9c8d7f7
add access control counting and error message tests
dcousens Feb 21, 2024
848457c
add *Many access-control tests
dcousens Feb 21, 2024
b5fe273
add update*/delete* field access-control tests, prefer early exit
dcousens Feb 21, 2024
2bf35bc
drop redundant tests
dcousens Feb 21, 2024
5f6ee1a
flatten api-tests folder
dcousens Feb 21, 2024
2a24986
rm redundant COOKIE_SECRET from tests
dcousens Feb 22, 2024
03357c4
rm --runInBand from CI tests
dcousens Feb 22, 2024
0df2f49
rm TEST_ADAPTER references
dcousens Feb 22, 2024
2a18f81
fix other tests to use new test suites
dcousens Feb 22, 2024
da8e3b5
try to reduce CI setup time, less shards
dcousens Feb 22, 2024
4c51b61
add concurrency for some tests
dcousens Feb 22, 2024
4ea8680
add concurrent database support mariadb and postgres in test-runner
dcousens Feb 22, 2024
ad8b273
dont use testConfig
dcousens Feb 22, 2024
b50938d
remove testConfig function from tests
dcousens Feb 22, 2024
e2002f0
add higher timeouts for concurrent tests
dcousens Feb 22, 2024
efc2e01
restore --runInBand for admin-ui-tests
dcousens Feb 22, 2024
36d787c
fix db-enable-logging tests
dcousens Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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