From 3e12c0ea54e58f6ddfada6287d9923940d9bcaa2 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Mon, 22 May 2023 17:26:21 +0200 Subject: [PATCH] Split CI database tests into separate types - this will allow us to see which set of tests are consuming the most amount of time in CI - in order to split apart the commands, I've had to override the coverage thresholds for integration+regression tests in order to keep c8 happy - also sprinkled some more labels into the workflows to make things clearer to read --- .github/workflows/test.yml | 35 ++++++++++++++++++++++++++--------- ghost/core/.c8rc.e2e.json | 8 ++++---- ghost/core/package.json | 5 +++-- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6199724fa3..1b9d409d56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -211,9 +211,11 @@ jobs: mysql database: 'ghost_testing' mysql root password: 'root' - - run: yarn --prefer-offline + - name: Install dependencies + run: yarn --prefer-offline - - run: date +%s > ${{ runner.temp }}/startTime # Get start time for test suite + - name: Record start time + run: date +%s > ${{ runner.temp }}/startTime # Get start time for test suite - name: Set env vars (SQLite) if: contains(matrix.env.DB, 'sqlite') @@ -223,12 +225,21 @@ jobs: if: contains(matrix.env.DB, 'mysql') run: echo "database__connection__password=root" >> $GITHUB_ENV - - name: Run tests + - name: E2E tests working-directory: ghost/core - run: yarn test:ci + run: yarn test:ci:e2e + + - name: Regression tests + working-directory: ghost/core + run: yarn test:ci:regression + + - name: Integration tests + working-directory: ghost/core + run: yarn test:ci:integration # Get runtime in seconds for test suite - - run: | + - name: Record test duration + run: | startTime="$(cat ${{ runner.temp }}/startTime)" endTime="$(date +%s)" echo "test_time=$(($endTime-$startTime))" >> $GITHUB_ENV @@ -237,7 +248,10 @@ jobs: if: startsWith(matrix.node, '16') && contains(matrix.env.DB, 'mysql') with: name: e2e-coverage - path: ghost/*/coverage-e2e/cobertura-coverage.xml + path: | + ghost/*/coverage-e2e/cobertura-coverage.xml + ghost/*/coverage-integration/cobertura-coverage.xml + ghost/*/coverage-regression/cobertura-coverage.xml # Continue on error if TailScale service is down - name: Tailscale Action @@ -250,7 +264,8 @@ jobs: # Report time taken to metrics service # Continue on error if previous TailScale step fails - - uses: tryghost/action-trigger-metric@main + - name: Store test duration + uses: tryghost/action-trigger-metric@main timeout-minutes: 1 continue-on-error: true if: (github.event_name == 'push' && github.repository_owner == 'TryGhost') || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'TryGhost/')) @@ -360,7 +375,8 @@ jobs: rsync -av --remove-source-files admin/* ghost/admin rsync -av --remove-source-files core/* ghost/core - - uses: codecov/codecov-action@v3 + - name: Upload E2E test coverage + uses: codecov/codecov-action@v3 with: flags: e2e-tests move_coverage_to_trash: true @@ -371,7 +387,8 @@ jobs: name: unit-coverage path: coverage - run: rsync -av --remove-source-files coverage/* ghost/ - - uses: codecov/codecov-action@v3 + - name: Upload unit test coverage + uses: codecov/codecov-action@v3 with: flags: unit-tests diff --git a/ghost/core/.c8rc.e2e.json b/ghost/core/.c8rc.e2e.json index a9c0a559b4..bc3640d06c 100644 --- a/ghost/core/.c8rc.e2e.json +++ b/ghost/core/.c8rc.e2e.json @@ -7,10 +7,10 @@ "cobertura" ], "reportsDir": "./coverage-e2e", - "statements": 86, - "branches": 85, - "functions": 87, - "lines": 86, + "statements": 80, + "branches": 82, + "functions": 81, + "lines": 80, "include": [ "core/{*.js,frontend,server,shared}" ], diff --git a/ghost/core/package.json b/ghost/core/package.json index f8d612094d..b794fa2164 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -39,8 +39,9 @@ "test:browser:single": "NODE_ENV=testing-browser playwright test", "test:browser:setup": "npx playwright install", "test:browser:record": "NODE_ENV=testing-browser yarn start record-test", - "test:ci": "c8 -c ./.c8rc.e2e.json yarn test:ci:base", - "test:ci:base": "yarn test:e2e -b && yarn test:integration -b && yarn test:regression -b", + "test:ci:e2e": "c8 -c ./.c8rc.e2e.json -o coverage-e2e yarn test:e2e -b", + "test:ci:regression": "c8 -c ./.c8rc.e2e.json -o coverage-regression --lines 72 --functions 66 --branches 82 --statements 72 yarn test:regression -b", + "test:ci:integration": "c8 -c ./.c8rc.e2e.json -o coverage-integration --lines 57 --functions 48 --branches 77 --statements 57 yarn test:integration -b", "test:unit:slow": "yarn test:unit --reporter=mocha-slow-test-reporter", "test:int:slow": "yarn test:integration --reporter=mocha-slow-test-reporter", "test:e2e:slow": "yarn test:e2e --reporter=mocha-slow-test-reporter",