Skip to content

Commit

Permalink
updated autogen
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Oct 11, 2024
1 parent c8b8809 commit 07085e4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
82 changes: 41 additions & 41 deletions .github/workflows/autogen/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
// }
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 07085e4

Please sign in to comment.