Skip to content

Commit

Permalink
Use GitHub Actions' built-in path filtering for skipping workflows (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed Aug 29, 2022
1 parent c227562 commit 18e29b5
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 118 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/always_tests.yml
Original file line number Diff line number Diff line change
@@ -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
121 changes: 3 additions & 118 deletions .github/workflows/tests.yml → .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -91,7 +64,6 @@ jobs:

graphql_api_tests_mysql:
name: API Tests MySQL
needs: should_run_tests
runs-on: ubuntu-latest
services:
mysql:
Expand All @@ -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
Expand All @@ -126,7 +95,6 @@ jobs:

redis_session_tests_postgresql:
name: Redis Session Tests PostgreSQL
needs: should_run_tests
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -144,21 +112,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: postgresql
DATABASE_URL: postgres://testuser:testpass@localhost:5432/test_db

redis_session_tests_sqlite:
name: Redis Session Tests SQLite
needs: should_run_tests
runs-on: ubuntu-latest
services:
redis:
Expand All @@ -168,21 +132,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: sqlite
DATABASE_URL: file:./dev.db

redis_session_tests_mysql:
name: Redis Session Tests MySQL
needs: should_run_tests
runs-on: ubuntu-latest
services:
redis:
Expand All @@ -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:
Expand All @@ -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/
Expand All @@ -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/
Expand All @@ -299,7 +231,6 @@ jobs:

field_crud_tests_mysql:
name: Field CRUD Tests MySQL
needs: should_run_tests
runs-on: ubuntu-latest
services:
mysql:
Expand All @@ -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/
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Loading

0 comments on commit 18e29b5

Please sign in to comment.