[ci] Merge test jobs into a single generic job (#48175)
This commit is contained in:
parent
15b9805704
commit
8fc6970b90
|
@ -32,10 +32,8 @@ jobs:
|
|||
runs-on: 'ubuntu-20.04'
|
||||
outputs:
|
||||
lint-jobs: ${{ steps.project-jobs.outputs.lint-jobs }}
|
||||
default-test-jobs: ${{ steps.project-jobs.outputs.default-test-jobs }}
|
||||
e2e-test-jobs: ${{ steps.project-jobs.outputs.e2e-test-jobs }}
|
||||
api-test-jobs: ${{ steps.project-jobs.outputs.api-test-jobs }}
|
||||
performance-test-jobs: ${{ steps.project-jobs.outputs.performance-test-jobs }}
|
||||
test-jobs: ${{ steps.project-jobs.outputs.test-jobs }}
|
||||
report-jobs: ${{ steps.project-jobs.outputs.report-jobs }}
|
||||
steps:
|
||||
- uses: 'actions/checkout@v4'
|
||||
name: 'Checkout'
|
||||
|
@ -69,7 +67,6 @@ jobs:
|
|||
}
|
||||
|
||||
let trigger = ${{ toJson( inputs.trigger ) }};
|
||||
|
||||
if ( trigger ) {
|
||||
githubEvent = trigger;
|
||||
}
|
||||
|
@ -100,53 +97,27 @@ jobs:
|
|||
- name: 'Lint'
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||
|
||||
project-default-test-jobs:
|
||||
name: "Test - ${{ matrix.projectName }} - ${{ matrix.name }} ${{ matrix.optional && ' (optional)' || '' || ''}}"
|
||||
project-test-jobs:
|
||||
name: "${{ matrix.name }}"
|
||||
runs-on: 'ubuntu-20.04'
|
||||
needs: 'project-jobs'
|
||||
if: ${{ needs.project-jobs.outputs.default-test-jobs != '[]' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON( needs.project-jobs.outputs.default-test-jobs ) }}
|
||||
steps:
|
||||
- uses: 'actions/checkout@v4'
|
||||
name: 'Checkout'
|
||||
- uses: './.github/actions/setup-woocommerce-monorepo'
|
||||
name: 'Setup Monorepo'
|
||||
id: 'setup-monorepo'
|
||||
with:
|
||||
install: '${{ matrix.projectName }}...'
|
||||
build: '${{ matrix.projectName }}'
|
||||
- name: 'Start Test Environment'
|
||||
id: 'prepare-test-environment'
|
||||
if: ${{ matrix.testEnv.shouldCreate }}
|
||||
env: ${{ matrix.testEnv.envVars }}
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
||||
- name: 'Test'
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||
|
||||
project-e2e-test-jobs:
|
||||
name: "E2E - ${{ matrix.name }} ${{ matrix.optional && ' (optional)' || ''}}"
|
||||
runs-on: 'ubuntu-20.04'
|
||||
needs: 'project-jobs'
|
||||
if: ${{ needs.project-jobs.outputs.e2e-test-jobs != '[]' }}
|
||||
if: ${{ needs.project-jobs.outputs.test-jobs != '[]' }}
|
||||
env: ${{ matrix.testEnv.envVars }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON( needs.project-jobs.outputs.e2e-test-jobs ) }}
|
||||
include: ${{ fromJSON( needs.project-jobs.outputs.test-jobs ) }}
|
||||
steps:
|
||||
- uses: 'actions/checkout@v4'
|
||||
name: 'Checkout'
|
||||
|
||||
|
||||
- uses: './.github/actions/setup-woocommerce-monorepo'
|
||||
name: 'Install Monorepo'
|
||||
id: 'install-monorepo'
|
||||
with:
|
||||
install: '${{ matrix.projectName }}...'
|
||||
build: 'false'
|
||||
|
||||
install: '${{ matrix.projectName }}...'
|
||||
build: 'false'
|
||||
|
||||
- uses: './.github/actions/setup-woocommerce-monorepo'
|
||||
if: ${{ github.ref_type != 'tag' }}
|
||||
name: 'Build project'
|
||||
|
@ -154,128 +125,61 @@ jobs:
|
|||
with:
|
||||
install: 'false'
|
||||
build: ${{ matrix.projectName }}
|
||||
|
||||
- name: Get commit message
|
||||
id: get_commit_message
|
||||
env:
|
||||
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
COMMIT_MESSAGE=`echo "$HEAD_COMMIT_MESSAGE" | head -1`
|
||||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
COMMIT_MESSAGE="$PR_TITLE"
|
||||
else
|
||||
COMMIT_MESSAGE="${{ github.event_name }}"
|
||||
fi
|
||||
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> "$GITHUB_OUTPUT"
|
||||
shell: bash
|
||||
|
||||
|
||||
- name: 'Update wp-env config'
|
||||
if: ${{ github.ref_type == 'tag' }}
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
ARTIFACT_NAME: ${{ github.ref_name == 'nightly' && 'woocommerce-trunk-nightly.zip' || 'woocommerce.zip' }}
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
ARTIFACT_NAME: ${{ github.ref_name == 'nightly' && 'woocommerce-trunk-nightly.zip' || 'woocommerce.zip' }}
|
||||
working-directory: ${{ matrix.projectPath }}
|
||||
run: node ./tests/e2e-pw/bin/override-wp-env-plugins.js
|
||||
|
||||
|
||||
- name: 'Start Test Environment'
|
||||
id: 'prepare-test-environment'
|
||||
if: ${{ matrix.testEnv.shouldCreate }}
|
||||
env: ${{ matrix.testEnv.envVars }}
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
||||
|
||||
|
||||
- name: 'Get commit message'
|
||||
id: 'get_commit_message'
|
||||
env:
|
||||
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
COMMIT_MESSAGE=`echo "$HEAD_COMMIT_MESSAGE" | head -1`
|
||||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
COMMIT_MESSAGE="$PR_TITLE"
|
||||
else
|
||||
COMMIT_MESSAGE="${{ github.event_name }}"
|
||||
fi
|
||||
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> "$GITHUB_OUTPUT"
|
||||
shell: bash
|
||||
|
||||
- name: 'Run tests'
|
||||
env:
|
||||
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_CORE_E2E_TOKEN }}
|
||||
BUILDKITE_ANALYTICS_MESSAGE: ${{ steps.get_commit_message.outputs.COMMIT_MESSAGE }}
|
||||
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_CORE_E2E_TOKEN }}
|
||||
BUILDKITE_ANALYTICS_MESSAGE: ${{ steps.get_commit_message.outputs.COMMIT_MESSAGE }}
|
||||
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }} # required by Metrics tests
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||
|
||||
|
||||
- name: 'Upload artifacts'
|
||||
if: ${{ always() }}
|
||||
if: ${{ always() && matrix.report.resultsPath != '' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: all-blob-e2e-reports-${{ strategy.job-index }}
|
||||
path: ${{ matrix.projectPath }}/tests/e2e-pw/test-results
|
||||
retention-days: 1
|
||||
compression-level: 9
|
||||
|
||||
project-api-test-jobs:
|
||||
name: "API - ${{ matrix.name }} ${{ matrix.optional && ' (optional)' || ''}}"
|
||||
runs-on: 'ubuntu-20.04'
|
||||
needs: 'project-jobs'
|
||||
if: ${{ needs.project-jobs.outputs.api-test-jobs != '[]' }}
|
||||
env: ${{ matrix.testEnv.envVars }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON( needs.project-jobs.outputs.api-test-jobs ) }}
|
||||
steps:
|
||||
- uses: 'actions/checkout@v4'
|
||||
name: 'Checkout'
|
||||
|
||||
- uses: './.github/actions/setup-woocommerce-monorepo'
|
||||
name: 'Setup Monorepo'
|
||||
id: 'setup-monorepo'
|
||||
with:
|
||||
install: '${{ matrix.projectName }}...'
|
||||
build: '${{ matrix.projectName }}'
|
||||
|
||||
- name: 'Start Test Environment'
|
||||
id: 'prepare-test-environment'
|
||||
if: ${{ matrix.testEnv.shouldCreate }}
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
||||
|
||||
- name: 'Run tests'
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||
|
||||
- name: 'Upload artifacts'
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: all-blob-api-reports-${{ strategy.job-index }}
|
||||
path: ${{ matrix.projectPath }}/tests/api-core-tests/test-results/allure-results
|
||||
retention-days: 1
|
||||
compression-level: 9
|
||||
|
||||
project-performance-test-jobs:
|
||||
name: "Performance - ${{ matrix.name }} ${{ matrix.optional && ' (optional)' || ''}}"
|
||||
runs-on: 'ubuntu-20.04'
|
||||
needs: 'project-jobs'
|
||||
if: ${{ needs.project-jobs.outputs.performance-test-jobs != '[]' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON( needs.project-jobs.outputs.performance-test-jobs ) }}
|
||||
env:
|
||||
WP_ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
|
||||
|
||||
steps:
|
||||
- uses: 'actions/checkout@v4'
|
||||
name: 'Checkout'
|
||||
|
||||
- uses: './.github/actions/setup-woocommerce-monorepo'
|
||||
name: 'Setup Monorepo'
|
||||
id: 'setup-monorepo'
|
||||
with:
|
||||
install: '${{ matrix.projectName }}...'
|
||||
build: '${{ matrix.projectName }}'
|
||||
|
||||
- name: 'Start Test Environment'
|
||||
id: 'prepare-test-environment'
|
||||
if: ${{ matrix.testEnv.shouldCreate }}
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
||||
|
||||
- name: 'Run tests'
|
||||
env:
|
||||
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
|
||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||
name: '${{ matrix.report.resultsBlobName }}-${{ strategy.job-index }}'
|
||||
path: '${{ matrix.projectPath }}/${{ matrix.report.resultsPath }}'
|
||||
retention-days: 1
|
||||
compression-level: 9
|
||||
|
||||
- name: 'Archive metrics results'
|
||||
if: ${{ success() && matrix.name == 'Metrics' }}
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||
if: ${{ success() && startsWith(matrix.name, 'Metrics') }} # this seems too fragile, we should update the reporting path and use the generic upload step above
|
||||
uses: actions/upload-artifact@v4
|
||||
env:
|
||||
WP_ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
|
||||
with:
|
||||
name: metrics-results
|
||||
path: ${{ env.WP_ARTIFACTS_PATH }}/*.performance-results*.json
|
||||
name: metrics-results
|
||||
path: ${{ env.WP_ARTIFACTS_PATH }}/*.performance-results*.json
|
||||
|
||||
evaluate-project-jobs:
|
||||
# In order to add a required status check we need a consistent job that we can grab onto.
|
||||
|
@ -289,10 +193,7 @@ jobs:
|
|||
[
|
||||
'project-jobs',
|
||||
'project-lint-jobs',
|
||||
'project-default-test-jobs',
|
||||
'project-e2e-test-jobs',
|
||||
'project-api-test-jobs',
|
||||
'project-performance-test-jobs',
|
||||
'project-test-jobs',
|
||||
]
|
||||
if: ${{ always() && github.event_name == 'pull_request' }}
|
||||
steps:
|
||||
|
@ -321,10 +222,7 @@ jobs:
|
|||
[
|
||||
'project-jobs',
|
||||
'project-lint-jobs',
|
||||
'project-default-test-jobs',
|
||||
'project-e2e-test-jobs',
|
||||
'project-api-test-jobs',
|
||||
'project-performance-test-jobs',
|
||||
'project-test-jobs',
|
||||
]
|
||||
if: ${{ always() && github.event_name != 'pull_request' }}
|
||||
steps:
|
||||
|
@ -342,20 +240,32 @@ jobs:
|
|||
SLACK_CHANNEL: ${{ secrets.TEST_REPORTS_SLACK_CHANNEL }}
|
||||
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
INPUT_TRIGGER: ${{ inputs.trigger }}
|
||||
RUN_TYPE: ${{ github.ref_type == 'tag' && (github.ref_name == 'nightly' && 'nightly-checks' || 'release-checks') || '' }}
|
||||
run: |
|
||||
COMMIT_MESSAGE=`echo "$HEAD_COMMIT_MESSAGE" | head -1`
|
||||
|
||||
if [[ -n "${INPUT_TRIGGER}" ]]; then
|
||||
CHECKS_TYPE="${INPUT_TRIGGER}"
|
||||
else
|
||||
CHECKS_TYPE="${RUN_TYPE}"
|
||||
fi
|
||||
|
||||
pnpm utils slack-test-report -c "${{ needs.project-jobs.result }}" -r "$INPUT_TRIGGER Build jobs matrix" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-lint-jobs.result }}" -r "$INPUT_TRIGGER Linting" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-default-test-jobs.result }}" -r "$INPUT_TRIGGER Tests" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-e2e-test-jobs.result }}" -r "$INPUT_TRIGGER e2e tests" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-api-test-jobs.result }}" -r "$INPUT_TRIGGER Api tests" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-performance-test-jobs.result }}" -r "$INPUT_TRIGGER Performance tests" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-jobs.result }}" -r "$CHECKS_TYPE Build jobs matrix" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-lint-jobs.result }}" -r "$CHECKS_TYPE Linting" -m "$COMMIT_MESSAGE"
|
||||
pnpm utils slack-test-report -c "${{ needs.project-test-jobs.result }}" -r "$CHECKS_TYPE Tests" -m "$COMMIT_MESSAGE"
|
||||
|
||||
e2e-test-reports:
|
||||
name: 'Report e2e tests results'
|
||||
needs: [project-e2e-test-jobs]
|
||||
if: ${{ ! cancelled() && needs.project-e2e-test-jobs.result != 'skipped' }}
|
||||
test-reports:
|
||||
name: 'Publish reports - ${{ matrix.report }}'
|
||||
needs:
|
||||
[
|
||||
'project-jobs',
|
||||
'project-test-jobs',
|
||||
]
|
||||
if: ${{ always() && needs.project-jobs.outputs.report-jobs != '[]' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
report: ${{ fromJSON( needs.project-jobs.outputs.report-jobs ) }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
@ -370,8 +280,8 @@ jobs:
|
|||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./out
|
||||
pattern: all-blob-e2e-reports-*
|
||||
run-id: project-e2e-test-jobs
|
||||
pattern: ${{ matrix.report }}-*
|
||||
run-id: project-test-jobs
|
||||
merge-multiple: true
|
||||
|
||||
- name: 'Generate Allure report'
|
||||
|
@ -381,16 +291,17 @@ jobs:
|
|||
- name: 'Archive reports'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-test-report
|
||||
name: ${{ matrix.report }}
|
||||
path: ./out
|
||||
if-no-files-found: ignore
|
||||
retention-days: 5
|
||||
|
||||
- name: 'Send workflow dispatch'
|
||||
- name: 'Publish report to dashboard'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.REPORTS_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
RUN_ID: ${{ github.run_id }}
|
||||
if: ${{ contains(matrix.report, 'e2e') }} # temporary until we adapt the woocommerce-test-reports side to not care about the test type
|
||||
run: |
|
||||
if [ "$GITHUB_EVENT_NAME" == pull_request ]; then
|
||||
gh workflow run publish-test-reports-pr.yml \
|
||||
|
@ -416,63 +327,3 @@ jobs:
|
|||
if: ${{ github.event_name == 'pull_request' }}
|
||||
run: |
|
||||
echo "::notice::🔗🔗 The e2e report for this run is available at https://woocommerce.github.io/woocommerce-test-reports/pr/${{ github.event.pull_request.number }}/e2e"
|
||||
|
||||
api-test-reports:
|
||||
name: 'Report API tests results'
|
||||
needs: [project-api-test-jobs]
|
||||
if: ${{ ! cancelled() && needs.project-api-test-jobs.result != 'skipped'}}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 'Install Allure CLI'
|
||||
env:
|
||||
DESTINATION_PATH: ../
|
||||
run: ./.github/workflows/scripts/install-allure.sh
|
||||
|
||||
- name: 'Download blob reports from artifacts'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./out/allure-results
|
||||
pattern: all-blob-api-reports-*
|
||||
run-id: project-api-test-jobs
|
||||
merge-multiple: true
|
||||
|
||||
- name: 'Generate Allure report'
|
||||
id: generate_allure_report
|
||||
run: allure generate --clean ./out/allure-results --output ./out/allure-report
|
||||
|
||||
- name: 'Archive reports'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: api-test-report
|
||||
path: ./out
|
||||
if-no-files-found: ignore
|
||||
retention-days: 5
|
||||
|
||||
- name: 'Publish reports'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.REPORTS_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
RUN_ID: ${{ github.run_id }}
|
||||
run: |
|
||||
if [ "$GITHUB_EVENT_NAME" == pull_request ]; then
|
||||
gh workflow run publish-test-reports-pr.yml \
|
||||
-f run_id=$RUN_ID \
|
||||
-f api_artifact=api-test-report \
|
||||
-f pr_number=$PR_NUMBER \
|
||||
-f commit_sha=$GITHUB_SHA \
|
||||
-f s3_root=public \
|
||||
--repo woocommerce/woocommerce-test-reports
|
||||
elif [ "$GITHUB_EVENT_NAME" == push ]; then
|
||||
gh workflow run publish-test-reports-trunk-merge.yml \
|
||||
-f run_id=$RUN_ID \
|
||||
-f artifact=api-test-report \
|
||||
-f pr_number=$PR_NUMBER \
|
||||
-f commit_sha=$GITHUB_SHA \
|
||||
-f test_type="api" \
|
||||
--repo woocommerce/woocommerce-test-reports
|
||||
else
|
||||
echo "No report will be created for '$GITHUB_EVENT_NAME' event"
|
||||
fi
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
const { REPOSITORY, RUN_ID, GITHUB_TOKEN, TEST_MODE } = process.env;
|
||||
const IGNORED_JOBS = [
|
||||
'Evaluate Project Job Statuses',
|
||||
'Report e2e tests results',
|
||||
'Report API tests results',
|
||||
'Report tests results',
|
||||
];
|
||||
|
||||
const isJobRequired = ( job ) => {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
CI: merge test jobs
|
|
@ -250,7 +250,12 @@
|
|||
"pull_request",
|
||||
"push",
|
||||
"release-checks"
|
||||
]
|
||||
],
|
||||
"report": {
|
||||
"resultsBlobName": "core-e2e-report",
|
||||
"resultsPath": "tests/e2e-pw/test-results",
|
||||
"allure": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Core e2e tests - Gutenberg stable",
|
||||
|
@ -266,6 +271,7 @@
|
|||
"changes": [],
|
||||
"events": [
|
||||
"daily-e2e",
|
||||
"nightly-checks",
|
||||
"release-checks"
|
||||
],
|
||||
"testEnv": {
|
||||
|
@ -286,8 +292,7 @@
|
|||
"changes": [],
|
||||
"events": [
|
||||
"daily-e2e",
|
||||
"release-checks",
|
||||
"nightly-checks"
|
||||
"release-checks"
|
||||
],
|
||||
"testEnv": {
|
||||
"start": "env:test"
|
||||
|
@ -364,6 +369,10 @@
|
|||
"config": {
|
||||
"disableHpos": true
|
||||
}
|
||||
},
|
||||
"report": {
|
||||
"resultsBlobName": "all-blob-e2e-reports-non-hpos",
|
||||
"resultsPath": "tests/e2e-pw/test-results"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -431,7 +440,12 @@
|
|||
"events": [
|
||||
"pull_request",
|
||||
"push"
|
||||
]
|
||||
],
|
||||
"report": {
|
||||
"resultsBlobName": "core-api-report",
|
||||
"resultsPath": "tests/api-core-tests/test-results",
|
||||
"allure": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Core API tests - HPOS disabled",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -77,7 +77,7 @@
|
|||
},
|
||||
"tests": [
|
||||
{
|
||||
"name": "JavaScript",
|
||||
"name": "Monorepo Utils JS Tests",
|
||||
"command": "test:js",
|
||||
"changes": [
|
||||
"jest.config.js",
|
||||
|
|
|
@ -12,7 +12,6 @@ import { buildProjectGraph } from './lib/project-graph';
|
|||
import { getFileChanges } from './lib/file-changes';
|
||||
import { createJobsForChanges } from './lib/job-processing';
|
||||
import { isGithubCI } from '../core/environment';
|
||||
import { testTypes } from './lib/config';
|
||||
|
||||
const program = new Command( 'ci-jobs' )
|
||||
.description(
|
||||
|
@ -62,15 +61,28 @@ const program = new Command( 'ci-jobs' )
|
|||
} );
|
||||
Logger.endTask( true );
|
||||
|
||||
// Rename the test jobs to include the project name and test type.
|
||||
for ( const job of jobs.test ) {
|
||||
const optional = job.optional ? ' (optional)' : '';
|
||||
job.name = `${ job.name } - ${ job.projectName } [${ job.testType }]${ optional }`;
|
||||
Logger.notice( `- ${ job.name }` );
|
||||
}
|
||||
|
||||
const resultsBlobNames = jobs.test
|
||||
.map( ( job ) => {
|
||||
if ( job.report && job.report.allure ) {
|
||||
return job.report.resultsBlobName;
|
||||
}
|
||||
return undefined;
|
||||
} )
|
||||
.filter( Boolean );
|
||||
|
||||
const reports = [ ...new Set( resultsBlobNames ) ];
|
||||
|
||||
if ( isGithubCI() ) {
|
||||
setOutput( 'lint-jobs', JSON.stringify( jobs.lint ) );
|
||||
|
||||
testTypes.forEach( ( type ) => {
|
||||
setOutput(
|
||||
`${ type }-test-jobs`,
|
||||
JSON.stringify( jobs[ `${ type }Test` ] )
|
||||
);
|
||||
} );
|
||||
setOutput( 'test-jobs', JSON.stringify( jobs.test ) );
|
||||
setOutput( 'report-jobs', JSON.stringify( reports ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,19 +98,21 @@ const program = new Command( 'ci-jobs' )
|
|||
Logger.notice( 'No lint jobs to run.' );
|
||||
}
|
||||
|
||||
testTypes.forEach( ( type ) => {
|
||||
if ( jobs[ `${ type }Test` ].length > 0 ) {
|
||||
Logger.notice( `${ type } test Jobs` );
|
||||
for ( const job of jobs[ `${ type }Test` ] ) {
|
||||
const optional = job.optional ? ' (optional)' : '';
|
||||
Logger.notice(
|
||||
`- ${ job.projectName } - ${ job.name }${ optional }`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Logger.notice( `No ${ type } test jobs to run.` );
|
||||
if ( jobs.test.length > 0 ) {
|
||||
Logger.notice( `Test Jobs` );
|
||||
for ( const job of jobs.test ) {
|
||||
Logger.notice( `- ${ job.name }` );
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
Logger.notice( `No test jobs to run.` );
|
||||
}
|
||||
|
||||
if ( reports.length > 0 ) {
|
||||
Logger.notice( `Report Jobs` );
|
||||
Logger.notice( `${ reports }` );
|
||||
} else {
|
||||
Logger.notice( `No report jobs to run.` );
|
||||
}
|
||||
} );
|
||||
|
||||
export default program;
|
||||
|
|
|
@ -136,7 +136,7 @@ describe( 'Config', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
shardingArguments: [],
|
||||
name: 'default',
|
||||
changes: [
|
||||
|
@ -192,6 +192,47 @@ describe( 'Config', () => {
|
|||
} );
|
||||
} );
|
||||
|
||||
it( 'should parse test config with report', () => {
|
||||
const parsed = parseCIConfig( {
|
||||
name: 'foo',
|
||||
config: {
|
||||
ci: {
|
||||
tests: [
|
||||
{
|
||||
name: 'default',
|
||||
changes: '/src/**/*.{js,jsx,ts,tsx}',
|
||||
command: 'foo',
|
||||
report: {
|
||||
resultsBlobName: 'foo-blob-report',
|
||||
resultsPath: '/test-results',
|
||||
allure: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
} );
|
||||
|
||||
expect( parsed ).toMatchObject( {
|
||||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
name: 'default',
|
||||
changes: [
|
||||
/^package\.json$/,
|
||||
makeRe( '/src/**/*.{js,jsx,ts,tsx}' ),
|
||||
],
|
||||
command: 'foo',
|
||||
report: {
|
||||
resultsBlobName: 'foo-blob-report',
|
||||
resultsPath: '/test-results',
|
||||
allure: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should parse test config with cascade', () => {
|
||||
const parsed = parseCIConfig( {
|
||||
name: 'foo',
|
||||
|
@ -263,10 +304,10 @@ describe( 'Config', () => {
|
|||
);
|
||||
|
||||
it.each( [
|
||||
[ '', 'default' ],
|
||||
[ 'bad', 'default' ],
|
||||
[ 1, 'default' ],
|
||||
[ undefined, 'default' ],
|
||||
[ '', 'unit' ],
|
||||
[ 'bad', 'unit' ],
|
||||
[ 1, 'unit' ],
|
||||
[ undefined, 'unit' ],
|
||||
] )(
|
||||
'should parse test config with unexpected testType',
|
||||
( input, result ) => {
|
||||
|
|
|
@ -303,7 +303,7 @@ describe( 'Job Processing', () => {
|
|||
} );
|
||||
|
||||
it( 'should trigger test job for single node', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
|
@ -331,8 +331,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -342,11 +342,12 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should replace vars in test command', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -378,8 +379,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -389,11 +390,12 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should not trigger a test job that has already been created', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -421,11 +423,11 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 0 );
|
||||
expect( jobs.test ).toHaveLength( 0 );
|
||||
} );
|
||||
|
||||
it( 'should not trigger test job for single node with no changes', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -450,11 +452,11 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 0 );
|
||||
expect( jobs.test ).toHaveLength( 0 );
|
||||
} );
|
||||
|
||||
it( 'should trigger test job for project graph', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -480,7 +482,7 @@ describe( 'Job Processing', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
name: 'Default A',
|
||||
shardingArguments: [],
|
||||
events: [],
|
||||
|
@ -498,7 +500,7 @@ describe( 'Job Processing', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
name: 'Default B',
|
||||
shardingArguments: [],
|
||||
events: [],
|
||||
|
@ -520,8 +522,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -531,8 +533,9 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test-b',
|
||||
projectPath: 'test-b',
|
||||
name: 'Default B',
|
||||
|
@ -542,6 +545,7 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -574,8 +578,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -585,12 +589,13 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
it( 'should trigger test job for dependent without changes when dependency has matching cascade key', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -617,7 +622,7 @@ describe( 'Job Processing', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
name: 'Default A',
|
||||
shardingArguments: [],
|
||||
events: [],
|
||||
|
@ -638,8 +643,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -649,8 +654,9 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test-a',
|
||||
projectPath: 'test-a',
|
||||
name: 'Default A',
|
||||
|
@ -660,11 +666,12 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType,
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should isolate dependency cascade keys to prevent cross-dependency matching', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -691,7 +698,7 @@ describe( 'Job Processing', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
name: 'Default A',
|
||||
shardingArguments: [],
|
||||
events: [],
|
||||
|
@ -710,7 +717,7 @@ describe( 'Job Processing', () => {
|
|||
jobs: [
|
||||
{
|
||||
type: JobType.Test,
|
||||
testType: 'default',
|
||||
testType: 'unit',
|
||||
name: 'Default B',
|
||||
shardingArguments: [],
|
||||
events: [],
|
||||
|
@ -731,8 +738,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -742,8 +749,9 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
} );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test-a',
|
||||
projectPath: 'test-a',
|
||||
name: 'Default A',
|
||||
|
@ -753,11 +761,12 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should trigger test job for single node and parse test environment config', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
jest.mocked( parseTestEnvConfig ).mockResolvedValue( {
|
||||
WP_ENV_CORE: 'https://wordpress.org/latest.zip',
|
||||
} );
|
||||
|
@ -799,8 +808,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -813,11 +822,12 @@ describe( 'Job Processing', () => {
|
|||
WP_ENV_CORE: 'https://wordpress.org/latest.zip',
|
||||
},
|
||||
},
|
||||
testType: 'unit',
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should trigger all jobs for a single node with changes set to "true"', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -853,8 +863,8 @@ describe( 'Job Processing', () => {
|
|||
projectPath: 'test',
|
||||
command: 'test-lint',
|
||||
} );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -864,11 +874,12 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'should trigger sharded test jobs for single node', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -898,8 +909,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toEqual(
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toEqual(
|
||||
expect.arrayContaining( [
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -911,6 +922,7 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -922,13 +934,14 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
] )
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'should trigger job with event configured but no event cli argument', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -958,8 +971,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toEqual(
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toEqual(
|
||||
expect.arrayContaining( [
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -971,6 +984,7 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -982,13 +996,14 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
] )
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'should trigger job with event configured and matching event cli argument', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -1018,8 +1033,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 2 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toEqual(
|
||||
expect( jobs.test ).toHaveLength( 2 );
|
||||
expect( jobs.test ).toEqual(
|
||||
expect.arrayContaining( [
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -1031,6 +1046,7 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -1042,13 +1058,14 @@ describe( 'Job Processing', () => {
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
testType: 'unit',
|
||||
},
|
||||
] )
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'should not trigger job with event configured but not matching event cli argument', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -1121,12 +1138,13 @@ describe( 'Job Processing', () => {
|
|||
projectPath: 'test',
|
||||
command: 'test-lint test-base-ref',
|
||||
optional: false,
|
||||
report: undefined,
|
||||
} );
|
||||
expect( jobs.test ).toHaveLength( 0 );
|
||||
} );
|
||||
|
||||
it( 'should create optional test job', async () => {
|
||||
const testType = 'default';
|
||||
const testType = 'unit';
|
||||
const jobs = await createJobsForChanges(
|
||||
{
|
||||
name: 'test',
|
||||
|
@ -1159,8 +1177,8 @@ describe( 'Job Processing', () => {
|
|||
);
|
||||
|
||||
expect( jobs.lint ).toHaveLength( 0 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toHaveLength( 1 );
|
||||
expect( jobs[ `${ testType }Test` ] ).toContainEqual( {
|
||||
expect( jobs.test ).toHaveLength( 1 );
|
||||
expect( jobs.test ).toContainEqual( {
|
||||
projectName: 'test',
|
||||
projectPath: 'test',
|
||||
name: 'Default',
|
||||
|
@ -1171,6 +1189,8 @@ describe( 'Job Processing', () => {
|
|||
envVars: {},
|
||||
},
|
||||
optional: true,
|
||||
report: undefined,
|
||||
testType: 'unit',
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
@ -1189,6 +1209,12 @@ describe( 'Job Processing', () => {
|
|||
envVars: {},
|
||||
},
|
||||
optional: false,
|
||||
testType: 'e2e',
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: JobType.Test,
|
||||
|
@ -1198,6 +1224,11 @@ describe( 'Job Processing', () => {
|
|||
events: [],
|
||||
changes: [ /test.js$/ ],
|
||||
command: 'test-cmd',
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1211,10 +1242,16 @@ describe( 'Job Processing', () => {
|
|||
command: 'test-cmd --shard-arg-1',
|
||||
shardNumber: 1,
|
||||
optional: false,
|
||||
testType: 'e2e',
|
||||
testEnv: {
|
||||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
projectName: 'test',
|
||||
|
@ -1223,10 +1260,16 @@ describe( 'Job Processing', () => {
|
|||
command: 'test-cmd --shard-arg-2',
|
||||
shardNumber: 2,
|
||||
optional: false,
|
||||
testType: 'e2e',
|
||||
testEnv: {
|
||||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
},
|
||||
] )
|
||||
);
|
||||
|
@ -1247,6 +1290,12 @@ describe( 'Job Processing', () => {
|
|||
envVars: {},
|
||||
},
|
||||
optional: false,
|
||||
testType: 'e2e',
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: JobType.Test,
|
||||
|
@ -1256,6 +1305,11 @@ describe( 'Job Processing', () => {
|
|||
events: [],
|
||||
changes: [ /test.js$/ ],
|
||||
command: 'test-cmd',
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1267,10 +1321,16 @@ describe( 'Job Processing', () => {
|
|||
command: 'test-cmd',
|
||||
shardNumber: 0,
|
||||
optional: false,
|
||||
testType: 'e2e',
|
||||
testEnv: {
|
||||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
report: {
|
||||
resultsBlobName: 'blob-name',
|
||||
resultsPath: 'results-path',
|
||||
allure: false,
|
||||
},
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
|
|
@ -24,7 +24,7 @@ export const enum JobType {
|
|||
/**
|
||||
* The type of the test job.
|
||||
*/
|
||||
export const testTypes = [ 'default', 'e2e', 'api', 'performance' ] as const;
|
||||
export const testTypes = [ 'unit', 'e2e', 'api', 'performance' ] as const;
|
||||
|
||||
/**
|
||||
* The variables that can be used in tokens on command strings
|
||||
|
@ -297,6 +297,26 @@ interface TestEnvConfig {
|
|||
config: TestEnvConfigVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* The configuration of a report.
|
||||
*/
|
||||
interface ReportConfig {
|
||||
/**
|
||||
* The name of the artifact to be uploaded.
|
||||
*/
|
||||
resultsBlobName: string;
|
||||
|
||||
/**
|
||||
* The path to the results that will be uploaded under the resultsBlobName name.
|
||||
*/
|
||||
resultsPath: string;
|
||||
|
||||
/**
|
||||
* Whether Allure results exists and an Allure report should be generated and possibly published.
|
||||
*/
|
||||
allure: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The configuration of a test job.
|
||||
*/
|
||||
|
@ -330,6 +350,11 @@ export interface TestJobConfig extends BaseJobConfig {
|
|||
* The key(s) to use when identifying what jobs should be triggered by a cascade.
|
||||
*/
|
||||
cascadeKeys?: string[];
|
||||
|
||||
/**
|
||||
* The configuration for the report if one is needed.
|
||||
*/
|
||||
report?: ReportConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,7 +400,7 @@ function parseTestJobConfig( raw: any ): TestJobConfig {
|
|||
);
|
||||
}
|
||||
|
||||
let testType: ( typeof testTypes )[ number ] = 'default';
|
||||
let testType: ( typeof testTypes )[ number ] = 'unit';
|
||||
if (
|
||||
raw.testType &&
|
||||
testTypes.includes( raw.testType.toString().toLowerCase() )
|
||||
|
@ -410,6 +435,42 @@ function parseTestJobConfig( raw: any ): TestJobConfig {
|
|||
};
|
||||
}
|
||||
|
||||
if ( raw.report ) {
|
||||
if ( typeof raw.report !== 'object' ) {
|
||||
throw new ConfigError( 'The "report" option must be an object.' );
|
||||
}
|
||||
|
||||
if (
|
||||
! raw.report.resultsBlobName ||
|
||||
typeof raw.report.resultsBlobName !== 'string'
|
||||
) {
|
||||
throw new ConfigError(
|
||||
'A string "resultsBlobName" option is required for report.'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
! raw.report.resultsPath ||
|
||||
typeof raw.report.resultsPath !== 'string'
|
||||
) {
|
||||
throw new ConfigError(
|
||||
'A string "resultsPath" option is required for report.'
|
||||
);
|
||||
}
|
||||
|
||||
if ( raw.report.allure && typeof raw.report.allure !== 'boolean' ) {
|
||||
throw new ConfigError(
|
||||
'A boolean "allure" option is required for report.'
|
||||
);
|
||||
}
|
||||
|
||||
config.report = {
|
||||
resultsBlobName: raw.report.resultsBlobName,
|
||||
resultsPath: raw.report.resultsPath,
|
||||
allure: raw.report.allure,
|
||||
};
|
||||
}
|
||||
|
||||
if ( raw.cascade ) {
|
||||
config.cascadeKeys = parseTestCascade( raw.cascade );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import {
|
||||
CommandVarOptions,
|
||||
JobType,
|
||||
testTypes,
|
||||
LintJobConfig,
|
||||
TestJobConfig,
|
||||
} from './config';
|
||||
|
@ -31,6 +30,15 @@ interface TestJobEnv {
|
|||
start?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A testing job report.
|
||||
*/
|
||||
interface TestJobReport {
|
||||
resultsBlobName: string;
|
||||
resultsPath: string;
|
||||
allure: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A testing job.
|
||||
*/
|
||||
|
@ -42,6 +50,8 @@ interface TestJob {
|
|||
testEnv: TestJobEnv;
|
||||
shardNumber: number;
|
||||
optional: boolean;
|
||||
testType: string;
|
||||
report: TestJobReport;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,8 +240,10 @@ async function createTestJob(
|
|||
shouldCreate: false,
|
||||
envVars: {},
|
||||
},
|
||||
report: config.report,
|
||||
shardNumber,
|
||||
optional: config.optional,
|
||||
testType: config.testType,
|
||||
};
|
||||
|
||||
// We want to make sure that we're including the configuration for
|
||||
|
@ -268,10 +280,6 @@ async function createJobsForProject(
|
|||
test: [],
|
||||
};
|
||||
|
||||
testTypes.forEach( ( type ) => {
|
||||
newJobs[ `${ type }Test` ] = [];
|
||||
} );
|
||||
|
||||
// In order to simplify the way that cascades work we're going to recurse depth-first and check our dependencies
|
||||
// for jobs before ourselves. This lets any cascade keys created in dependencies cascade to dependents.
|
||||
const newCascadeKeys = [];
|
||||
|
@ -304,12 +312,7 @@ async function createJobsForProject(
|
|||
}
|
||||
|
||||
newJobs.lint.push( ...dependencyJobs.lint );
|
||||
|
||||
testTypes.forEach( ( type ) => {
|
||||
newJobs[ `${ type }Test` ].push(
|
||||
...dependencyJobs[ `${ type }Test` ]
|
||||
);
|
||||
} );
|
||||
newJobs.test.push( ...dependencyJobs.test );
|
||||
|
||||
// Track any new cascade keys added by the dependency.
|
||||
// Since we're filtering out duplicates after the
|
||||
|
@ -402,9 +405,7 @@ async function createJobsForProject(
|
|||
|
||||
jobConfig.jobCreated = true;
|
||||
|
||||
newJobs[ `${ jobConfig.testType }Test` ].push(
|
||||
...getShardedJobs( created, jobConfig )
|
||||
);
|
||||
newJobs.test.push( ...getShardedJobs( created, jobConfig ) );
|
||||
|
||||
// We need to track any cascade keys that this job is associated with so that
|
||||
// dependent projects can trigger jobs with matching keys. We are expecting
|
||||
|
|
Loading…
Reference in New Issue