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

ci: restrict the number of E2E jobs that can run in parallel #673

Merged
merged 12 commits into from
Oct 11, 2024
55 changes: 8 additions & 47 deletions .github/workflows/autogen/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { fileURLToPath } from 'url'
import * as changeCase from 'change-case'

export const AUTOGENERATE_E2E_TEST_JOBS = '# {AUTOGENERATE-E2E-TEST-JOBS}'
export const AUTOGENERATE_E2E_TEST_JOBS_2 = '# {AUTOGENERATE-E2E-TEST-JOBS-2}'
export const AUTOGENERATE_NEEDS = '# {AUTOGENERATE-NEEDS}'
export const AUTOGENERATE_WITH_SUBDIR = '# {AUTOGENERATE-WITH-SUBDIR}'
export const AUTOGENERATE_WITH_COVERAGE_REPORT = '# {AUTOGENERATE-WITH-COVERAGE-REPORT}'
export const AUTOGENERATE_JOB_OUTPUTS_SUB_DIRS = '# {AUTOGENERATE-JOB-OUTPUTS-SUB-DIRS}'
Expand Down Expand Up @@ -144,19 +142,17 @@ function buildWorkflows (outputDir, templateDir, config) {
const trimmedLine = line.trim()

switch (trimmedLine) {
case AUTOGENERATE_E2E_TEST_JOBS:
case AUTOGENERATE_E2E_TEST_JOBS_2:
case AUTOGENERATE_WORKFLOW_OUTPUTS_SUB_DIRS:
case AUTOGENERATE_WORKFLOW_OUTPUTS_COVERAGE_REPORTS:
case AUTOGENERATE_INPUTS_SUB_DIRS:
case AUTOGENERATE_INPUTS_COVERAGE_REPORTS:
autogenerateYaml(line, config, outputLines, trimmedLine)
break
case AUTOGENERATE_NEEDS:
case AUTOGENERATE_WITH_SUBDIR:
case AUTOGENERATE_WITH_COVERAGE_REPORT:
case AUTOGENERATE_JOB_OUTPUTS_SUB_DIRS:
case AUTOGENERATE_JOB_OUTPUTS_COVERAGE_REPORTS:
case AUTOGENERATE_E2E_TEST_JOBS:
autogenerateLine(line, config, outputLines, trimmedLine)
break
case AUTOGENERATE_DOWNLOAD_JOBS:
Expand Down Expand Up @@ -188,10 +184,6 @@ export function autogenerateYaml (line, config, outputLines, templateKey) {
const outputYaml = {}

switch (templateKey) {
case AUTOGENERATE_E2E_TEST_JOBS:
case AUTOGENERATE_E2E_TEST_JOBS_2:
generateTestJobs(test, templateKey, outputYaml)
break
default:
generateOutputs(test, templateKey, outputYaml)
suppressEmptyLines = true
Expand Down Expand Up @@ -259,40 +251,6 @@ export function generateOutputs (test, templateKey, outputYaml) {
outputYaml[outputKey] = outputValue
}

/**
* Generates the test jobs for the provided templateKey
* @param {Test} test
* @param {string} templateKey
* @param {Object} outputYaml
*/
export function generateTestJobs (test, templateKey, outputYaml) {
const formalNounName = test.name
const kebabCase = changeCase.kebabCase(formalNounName)
const testJobKey = `e2e-${kebabCase}-tests`
const testJobValue = {}
testJobValue.name = 'E2E Tests'

if (templateKey === AUTOGENERATE_E2E_TEST_JOBS) {
testJobValue.if = '${{ github.event_name == \'push\' || github.event.inputs.enable-e2e-tests == \'true\' }}'
} else {
testJobValue.if = '${{ !cancelled() && always() }}'
}

testJobValue.uses = './.github/workflows/zxc-e2e-test.yaml'
testJobValue.needs = ['env-vars', 'code-style']
testJobValue.with = {
'custom-job-label': formalNounName,
'npm-test-script': 'test-${{ needs.env-vars.outputs.e2e-' +
kebabCase + '-test-subdir }}',
'coverage-subdirectory': '${{ needs.env-vars.outputs.e2e-' +
kebabCase + '-test-subdir }}',
'coverage-report-name': '${{ needs.env-vars.outputs.e2e-' +
kebabCase + '-coverage-report }}'
}

outputYaml[testJobKey] = testJobValue
}

/**
* Generates the output line for the provided templateKey
* @param {string} line
Expand Down Expand Up @@ -320,10 +278,6 @@ export function autogenerateLine (line, config, outputLines, templateKey) {
namePart = `e2e-${kebabCase}`
outputLines.push(spacePrefix + namePart + '-coverage-report: ${{ needs.env-vars.outputs.' + namePart + '-coverage-report }}')
break
case AUTOGENERATE_NEEDS:
namePart = `e2e-${kebabCase}-tests`
outputLines.push(`${spacePrefix}- ${namePart}`)
break
case AUTOGENERATE_JOB_OUTPUTS_SUB_DIRS:
namePart = `e2e_${snakeCase}_test_subdir`
namePart2 = `e2e-${kebabCase}`
Expand All @@ -341,6 +295,13 @@ export function autogenerateLine (line, config, outputLines, templateKey) {
outputLines.push(spacePrefix + ' name: ${{ inputs.e2e-' + kebabCase + '-coverage-report }}')
outputLines.push(spacePrefix + ' path: \'coverage/${{ inputs.e2e-' + kebabCase + '-test-subdir }}\'')
outputLines.push('')
break
case AUTOGENERATE_E2E_TEST_JOBS:
outputLines.push(spacePrefix + '- { name: "' + formalNounName +
'", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-' + kebabCase +
'-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-' + kebabCase +
'-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-' + kebabCase +
'-coverage-report }}" }')
}
})
}
199 changes: 24 additions & 175 deletions .github/workflows/flow-build-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,194 +64,43 @@ jobs:
with:
custom-job-label: Standard

e2e-integration-tests:
e2e-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Integration
npm-test-script: test-${{ needs.env-vars.outputs.e2e-integration-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-integration-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-integration-coverage-report }}

e2e-standard-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Standard
npm-test-script: test-${{ needs.env-vars.outputs.e2e-standard-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-standard-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-standard-coverage-report }}

e2e-mirror-node-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Mirror Node
npm-test-script: test-${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-mirror-node-coverage-report }}

e2e-node-pem-stop-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node PEM Stop
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-pem-stop-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-pem-stop-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-pem-stop-coverage-report }}

e2e-node-pem-kill-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node PEM Kill
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-pem-kill-coverage-report }}

e2e-node-local-build-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Local Build
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-local-build-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-local-build-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-local-build-coverage-report }}

e2e-node-add-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Add
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-add-coverage-report }}

e2e-node-add-separate-commands-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Add - Separate commands
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }}

e2e-node-update-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Update
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-update-coverage-report }}

e2e-node-delete-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Delete
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }}

e2e-node-delete-separate-commands-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Delete - Separate commands
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }}

e2e-node-upgrade-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Node Upgrade
npm-test-script: test-${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }}

e2e-relay-tests:
name: E2E Tests
if: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }}
uses: ./.github/workflows/zxc-e2e-test.yaml
needs:
- env-vars
- code-style
with:
custom-job-label: Relay
npm-test-script: test-${{ needs.env-vars.outputs.e2e-relay-test-subdir }}
coverage-subdirectory: ${{ needs.env-vars.outputs.e2e-relay-test-subdir }}
coverage-report-name: ${{ needs.env-vars.outputs.e2e-relay-coverage-report }}
strategy:
matrix:
e2e-test-type:
- { name: "Integration", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-integration-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-integration-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-integration-coverage-report }}" }
- { name: "Standard", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-standard-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-standard-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-standard-coverage-report }}" }
- { name: "Mirror Node", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-mirror-node-coverage-report }}" }
- { name: "Node PEM Stop", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-pem-stop-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-pem-stop-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-pem-stop-coverage-report }}" }
- { name: "Node PEM Kill", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-pem-kill-coverage-report }}" }
- { name: "Node Local Build", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-local-build-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-local-build-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-local-build-coverage-report }}" }
- { name: "Node Add", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-coverage-report }}" }
- { name: "Node Add - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }}" }
- { name: "Node Update", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-update-coverage-report }}" }
- { name: "Node Delete", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }}" }
- { name: "Node Delete - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }}" }
- { name: "Node Upgrade", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }}" }
- { name: "Relay", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-relay-coverage-report }}" }
jeromy-cannon marked this conversation as resolved.
Show resolved Hide resolved
max-parallel: 5
with:
custom-job-label: ${{ matrix.e2e-test-type.name }}
npm-test-script: ${{ matrix.e2e-test-type.npm-test-script }}
coverage-subdirectory: ${{ matrix.e2e-test-type.coverage-subdirectory }}
coverage-report-name: ${{ matrix.e2e-test-type.coverage-report-name }}

analyze:
name: Analyze
uses: ./.github/workflows/zxc-code-analysis.yaml
needs:
- env-vars
- unit-tests
- e2e-integration-tests
- e2e-standard-tests
- e2e-mirror-node-tests
- e2e-node-pem-stop-tests
- e2e-node-pem-kill-tests
- e2e-node-local-build-tests
- e2e-node-add-tests
- e2e-node-add-separate-commands-tests
- e2e-node-update-tests
- e2e-node-delete-tests
- e2e-node-delete-separate-commands-tests
- e2e-node-upgrade-tests
- e2e-relay-tests
- e2e-tests
if: ${{ (github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' || github.event.inputs.enable-e2e-tests == 'true') && !failure() && !cancelled() }}
with:
custom-job-label: Source Code
Expand Down
Loading
Loading