From 18e29b5ec076ef9eff7c2a2f6de81be4662bb324 Mon Sep 17 00:00:00 2001 From: Mitchell Hamilton Date: Mon, 29 Aug 2022 10:27:37 +1000 Subject: [PATCH] Use GitHub Actions' built-in path filtering for skipping workflows (#7847) --- .github/workflows/always_tests.yml | 48 ++++++ .../workflows/{tests.yml => core_tests.yml} | 121 +-------------- .github/workflows/skip_core_tests.yml | 146 ++++++++++++++++++ 3 files changed, 197 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/always_tests.yml rename .github/workflows/{tests.yml => core_tests.yml} (68%) create mode 100644 .github/workflows/skip_core_tests.yml diff --git a/.github/workflows/always_tests.yml b/.github/workflows/always_tests.yml new file mode 100644 index 00000000000..696e126fb10 --- /dev/null +++ b/.github/workflows/always_tests.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - uses: ./.github/actions/ci-setup + + - name: Prettier + run: yarn lint:prettier + + - name: TypeScript + run: yarn lint:types + + - name: ESLint + run: yarn lint:eslint + + - name: Preconstruct + run: yarn build + + - name: Remark + run: yarn lint:markdown + + - name: Prisma Filters + run: yarn lint:filters + + unit_tests: + name: Package Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - uses: ./.github/actions/ci-setup + + - name: Unit tests + run: yarn jest --ci --runInBand --testPathIgnorePatterns=admin-ui-tests --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=examples/testing diff --git a/.github/workflows/tests.yml b/.github/workflows/core_tests.yml similarity index 68% rename from .github/workflows/tests.yml rename to .github/workflows/core_tests.yml index 6eddf711269..78649eb6cc4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/core_tests.yml @@ -5,34 +5,14 @@ on: branches: - main pull_request: + paths-ignore: + - 'docs/**' + - '**/*.md' workflow_dispatch: jobs: - should_run_tests: - name: Should run tests - runs-on: ubuntu-latest - outputs: - shouldRunTests: ${{ env.SHOULD_RUN_TESTS }} - steps: - - uses: dorny/paths-filter@v2 - id: filter - if: github.event_name == 'pull_request' - with: - filters: | - shouldRunTests: - - '!{{design-system}/**,**/*.md,docs/**}' - - - run: echo "SHOULD_RUN_TESTS=$SHOULD_RUN" >> $GITHUB_ENV - if: github.event_name == 'pull_request' - env: - SHOULD_RUN: ${{ steps.filter.outputs.shouldRunTests }} - - - run: echo "SHOULD_RUN_TESTS=true" >> $GITHUB_ENV - if: github.event_name != 'pull_request' - graphql_api_tests_postgresql: name: API Tests PostgreSQL - needs: should_run_tests runs-on: ubuntu-latest services: postgres: @@ -50,13 +30,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=tests/api-tests/fields/crud --testPathIgnorePatterns=tests/api-tests/auth-stored-session.test.ts env: CI_NODE_TOTAL: 9 @@ -66,7 +43,6 @@ jobs: graphql_api_tests_sqlite: name: API Tests SQLite - needs: should_run_tests runs-on: ubuntu-latest strategy: fail-fast: false @@ -75,13 +51,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=tests/api-tests/fields/crud --testPathIgnorePatterns=tests/api-tests/auth-stored-session.test.ts env: CI_NODE_TOTAL: 9 @@ -91,7 +64,6 @@ jobs: graphql_api_tests_mysql: name: API Tests MySQL - needs: should_run_tests runs-on: ubuntu-latest services: mysql: @@ -110,13 +82,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=tests/api-tests/fields/crud --testPathIgnorePatterns=tests/api-tests/auth-stored-session.test.ts env: CI_NODE_TOTAL: 9 @@ -126,7 +95,6 @@ jobs: redis_session_tests_postgresql: name: Redis Session Tests PostgreSQL - needs: should_run_tests runs-on: ubuntu-latest services: postgres: @@ -144,13 +112,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/auth-stored-session.test.ts env: TEST_ADAPTER: postgresql @@ -158,7 +123,6 @@ jobs: redis_session_tests_sqlite: name: Redis Session Tests SQLite - needs: should_run_tests runs-on: ubuntu-latest services: redis: @@ -168,13 +132,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/auth-stored-session.test.ts env: TEST_ADAPTER: sqlite @@ -182,7 +143,6 @@ jobs: redis_session_tests_mysql: name: Redis Session Tests MySQL - needs: should_run_tests runs-on: ubuntu-latest services: redis: @@ -201,36 +161,17 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/auth-stored-session.test.ts env: TEST_ADAPTER: mysql DATABASE_URL: mysql://testuser:testpass@localhost:3306/test_db - unit_tests: - name: Package Unit Tests - needs: should_run_tests - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - - uses: ./.github/actions/ci-setup - - - name: Unit tests - run: yarn jest --ci --runInBand --testPathIgnorePatterns=admin-ui-tests --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=examples/testing - field_crud_tests_postgresql: name: Field CRUD Tests PostgreSQL - needs: should_run_tests runs-on: ubuntu-latest services: postgres: @@ -243,18 +184,14 @@ jobs: - 5432:5432 steps: - name: Checkout Repo - if: needs.should_run_tests.outputs.shouldRunTests == 'true' uses: actions/checkout@v3 - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Setup local S3 bucket - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: bash ./.github/workflows/s3-bucket.sh - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/fields/crud env: S3_ENDPOINT: http://127.0.0.1:9000/ @@ -269,22 +206,17 @@ jobs: field_crud_tests_sqlite: name: Field CRUD Tests SQLite - needs: should_run_tests runs-on: ubuntu-latest steps: - name: Checkout Repo - if: needs.should_run_tests.outputs.shouldRunTests == 'true' uses: actions/checkout@v3 - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Setup local S3 bucket - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: bash ./.github/workflows/s3-bucket.sh - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/fields/crud env: S3_ENDPOINT: http://127.0.0.1:9000/ @@ -299,7 +231,6 @@ jobs: field_crud_tests_mysql: name: Field CRUD Tests MySQL - needs: should_run_tests runs-on: ubuntu-latest services: mysql: @@ -313,18 +244,14 @@ jobs: - 3306:3306 steps: - name: Checkout Repo - if: needs.should_run_tests.outputs.shouldRunTests == 'true' uses: actions/checkout@v3 - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Setup local S3 bucket - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: bash ./.github/workflows/s3-bucket.sh - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/api-tests/fields/crud env: S3_ENDPOINT: http://127.0.0.1:9000/ @@ -339,10 +266,7 @@ jobs: examples_tests: name: Testing example project - needs: should_run_tests runs-on: ubuntu-latest - strategy: - fail-fast: false steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -353,7 +277,6 @@ jobs: examples_smoke_tests: name: Smoke Tests For Examples runs-on: ubuntu-latest - needs: should_run_tests env: DATABASE_URL: 'file:./test.db' strategy: @@ -383,28 +306,22 @@ jobs: fail-fast: false steps: - name: Checkout Repo - if: needs.should_run_tests.outputs.shouldRunTests == 'true' uses: actions/checkout@v3 - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Install Dependencies of Browsers - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn playwright install-deps chromium - name: Install Browsers - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn playwright install chromium - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/examples-smoke-tests/${{ matrix.test }} admin_ui_integration_tests: name: Integration tests for Admin UI runs-on: ubuntu-latest - needs: should_run_tests env: DATABASE_URL: 'file:./test.db' strategy: @@ -420,47 +337,15 @@ jobs: fail-fast: false steps: - name: Checkout Repo - if: needs.should_run_tests.outputs.shouldRunTests == 'true' uses: actions/checkout@v3 - uses: ./.github/actions/ci-setup - if: needs.should_run_tests.outputs.shouldRunTests == 'true' - name: Install Dependencies of Browsers - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn playwright install-deps chromium - name: Install Browsers - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn playwright install chromium - name: Unit tests - if: needs.should_run_tests.outputs.shouldRunTests == 'true' run: yarn jest --ci --runInBand tests/admin-ui-tests/${{ matrix.test }} - - linting: - name: Linting - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - - uses: ./.github/actions/ci-setup - - - name: Prettier - run: yarn lint:prettier - - - name: TypeScript - run: yarn lint:types - - - name: ESLint - run: yarn lint:eslint - - - name: Preconstruct - run: yarn build - - - name: Remark - run: yarn lint:markdown - - - name: Prisma Filters - run: yarn lint:filters diff --git a/.github/workflows/skip_core_tests.yml b/.github/workflows/skip_core_tests.yml new file mode 100644 index 00000000000..1fa833f8a84 --- /dev/null +++ b/.github/workflows/skip_core_tests.yml @@ -0,0 +1,146 @@ +# The names here intentionally align with the jobs in core_tests +# so that the required checks pass in GitHub when they're skipped + +name: CI + +on: + pull_request: + paths-ignore: + - '**' + - '!docs/**' + - '!**/*.md' + +jobs: + graphql_api_tests_postgresql: + name: API Tests PostgreSQL + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + index: [0, 1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Skipped tests + run: echo "Skipped tests" + + graphql_api_tests_sqlite: + name: API Tests SQLite + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + index: [0, 1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Skipped tests + run: echo "Skipped tests" + + graphql_api_tests_mysql: + name: API Tests MySQL + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + index: [0, 1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Skipped tests + run: echo "Skipped tests" + + redis_session_tests_postgresql: + name: Redis Session Tests PostgreSQL + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + redis_session_tests_sqlite: + name: Redis Session Tests SQLite + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + redis_session_tests_mysql: + name: Redis Session Tests MySQL + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + field_crud_tests_postgresql: + name: Field CRUD Tests PostgreSQL + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + field_crud_tests_sqlite: + name: Field CRUD Tests SQLite + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + field_crud_tests_mysql: + name: Field CRUD Tests MySQL + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + examples_tests: + name: Testing example project + runs-on: ubuntu-latest + steps: + - name: Skipped tests + run: echo "Skipped tests" + + examples_smoke_tests: + name: Smoke Tests For Examples + runs-on: ubuntu-latest + strategy: + matrix: + test: + [ + 'auth.test.ts', + 'basic.test.ts', + 'blog.test.ts', + 'document-field.test.ts', + 'default-values.test.ts', + 'extend-graphql-schema.test.ts', + 'extend-graphql-schema-graphql-ts.test.ts', + 'extend-graphql-schema-nexus.test.ts', + 'json.test.ts', + 'rest-api.test.ts', + 'roles.test.ts', + 'task-manager.test.ts', + 'testing.test.ts', + 'with-auth.test.ts', + 'custom-field-view.test.ts', + 'custom-field.test.ts', + 'custom-admin-ui-pages.test.ts', + 'custom-admin-ui-logo.test.ts', + 'custom-admin-ui-navigation.test.ts', + ] + fail-fast: false + steps: + - name: Skipped tests + run: echo "Skipped tests" + + admin_ui_integration_tests: + name: Integration tests for Admin UI + runs-on: ubuntu-latest + env: + DATABASE_URL: 'file:./test.db' + strategy: + matrix: + test: + [ + 'init.test.ts', + 'filters.test.ts', + 'list-view-crud.test.ts', + 'navigation.test.ts', + 'live-reloading.test.ts', + ] + fail-fast: false + steps: + - name: Skipped tests + run: echo "Skipped tests"