From 07085e482eae80eb35e10eebae1eeb2be3f54c13 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Fri, 11 Oct 2024 15:05:40 +0100 Subject: [PATCH] updated autogen Signed-off-by: Jeromy Cannon --- .github/workflows/autogen/src/index.mjs | 82 +++++++++---------- .../template.flow-pull-request-checks.yaml | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.github/workflows/autogen/src/index.mjs b/.github/workflows/autogen/src/index.mjs index 553e3acf..255c1aed 100644 --- a/.github/workflows/autogen/src/index.mjs +++ b/.github/workflows/autogen/src/index.mjs @@ -22,7 +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_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}' @@ -143,8 +142,6 @@ 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: @@ -157,6 +154,7 @@ function buildWorkflows (outputDir, templateDir, config) { case AUTOGENERATE_JOB_OUTPUTS_COVERAGE_REPORTS: autogenerateLine(line, config, outputLines, trimmedLine) break + case AUTOGENERATE_E2E_TEST_JOBS: case AUTOGENERATE_DOWNLOAD_JOBS: autogenerateLine(line, config, outputLines, trimmedLine) outputLines.pop() // remove the extra new line character @@ -186,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 @@ -257,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 @@ -335,6 +295,46 @@ 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 }}" }') } }) } +/// ** +// * 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 +// } diff --git a/.github/workflows/templates/template.flow-pull-request-checks.yaml b/.github/workflows/templates/template.flow-pull-request-checks.yaml index 8de838c7..c3288679 100644 --- a/.github/workflows/templates/template.flow-pull-request-checks.yaml +++ b/.github/workflows/templates/template.flow-pull-request-checks.yaml @@ -72,7 +72,7 @@ jobs: strategy: matrix: e2e-test-type: - # {AUTOGENERATE-E2E-TEST-JOBS-2} + # {AUTOGENERATE-E2E-TEST-JOBS} max-parallel: 5 with: custom-job-label: ${{ matrix.e2e-test-type.name }}