Skip to content

Commit

Permalink
Do not populate os in custom matrix unless provided
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Jul 16, 2024
1 parent 73be3bd commit bda7801
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 130 deletions.
138 changes: 75 additions & 63 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 73 additions & 67 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2071,75 +2071,96 @@ jobs:
custom_clean: ${{ steps.custom.outputs.clean }}
custom_always: ${{ steps.custom.outputs.always }}

custom_test_matrix: ${{ steps.custom_test_matrix.outputs.json || inputs.custom_test_matrix }}
custom_publish_matrix: ${{ steps.custom_publish_matrix.outputs.json || inputs.custom_publish_matrix }}
custom_finalize_matrix: ${{ steps.custom_finalize_matrix.outputs.json || inputs.custom_finalize_matrix }}
custom_test_matrix: ${{ steps.test_matrix_step3.outputs.json || steps.test_matrix_step2.outputs.json || inputs.custom_test_matrix }}
custom_publish_matrix: ${{ steps.publish_matrix_step3.outputs.json || steps.publish_matrix_step2.outputs.json || inputs.custom_publish_matrix }}
custom_finalize_matrix: ${{ steps.finalize_matrix_step3.outputs.json || steps.finalize_matrix_step2.outputs.json || inputs.custom_finalize_matrix }}

steps:
- *getGitHubAppToken
- *checkoutVersionedSha
- *resetGitHubDirectory

# FIXME: remove this handling of deprecated comma-separated values
- id: custom_test_values
- id: test_matrix_step1
if: contains(inputs.custom_test_matrix, '{') != true
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_test_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- &customValuesInput
name: Create matrix from custom values
id: custom_test_matrix
if: steps.custom_test_values.outputs.json != ''
env:
MATRIX: >
{
"value": ${{ steps.custom_test_values.outputs.json }},
"os": ${{ inputs.custom_runs_on || format('[{0}]', inputs.runs_on) }}
}
run: |
json=$(jq -e -c . <<<"${MATRIX}") || exit $?
echo "json=${json}" >> "${GITHUB_OUTPUT}"
# FIXME: remove this handling of deprecated comma-separated values
- id: custom_publish_values
- id: publish_matrix_step1
if: contains(inputs.custom_publish_matrix, '{') != true
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_publish_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customValuesInput
id: custom_publish_matrix
if: steps.custom_publish_values.outputs.json != ''
env:
MATRIX: >
{
"value": ${{ steps.custom_publish_values.outputs.json }},
"os": ${{ inputs.custom_runs_on || format('[{0}]', inputs.runs_on) }}
}
# FIXME: remove this handling of deprecated comma-separated values
- id: custom_finalize_values
- id: finalize_matrix_step1
if: contains(inputs.custom_finalize_matrix, '{') != true
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_finalize_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customValuesInput
id: custom_finalize_matrix
if: steps.custom_finalize_values.outputs.json != ''
- &customMatrixStep2
name: Add custom values to matrix
id: test_matrix_step2
if: join(fromJSON(steps.test_matrix_step1.outputs.json || '[]')) != ''
env:
MATRIX: >
{
"value": ${{ steps.custom_finalize_values.outputs.json }},
"os": ${{ inputs.custom_runs_on || format('[{0}]', inputs.runs_on) }}
}
input: "{}"
key: value
value: ${{ steps.test_matrix_step1.outputs.json }}
run: |
json=$(jq --compact-output --arg key "${key}" --argjson value "${value}" '{ ($key): [$value] }' <<< "${input}")
echo "json=${json}" >> "${GITHUB_OUTPUT}"
# FIXME: remove this handling of deprecated comma-separated values
- <<: *customMatrixStep2
id: publish_matrix_step2
if: join(fromJSON(steps.publish_matrix_step1.outputs.json || '[]')) != ''
env:
input: "{}"
key: value
value: ${{ steps.test_matrix_step1.outputs.json }}

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customMatrixStep2
id: finalize_matrix_step2
if: join(fromJSON(steps.finalize_matrix_step1.outputs.json || '[]')) != ''
env:
input: "{}"
key: value
value: ${{ steps.finalize_matrix_step1.outputs.json }}

# FIXME: remove this handling of deprecated comma-separated values
- &customMatrixStep3
<<: *customMatrixStep2
name: Add custom_runs_on to matrix
if: join(fromJSON(inputs.custom_runs_on || '[]')) != ''
id: test_matrix_step3
env:
input: ${{ steps.test_matrix_step2.outputs.json || '{}' }}
key: os
value: ${{ inputs.custom_runs_on }}

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customMatrixStep3
id: publish_matrix_step3
env:
input: ${{ steps.publish_matrix_step2.outputs.json || '{}' }}
key: os
value: ${{ inputs.custom_runs_on }}

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customMatrixStep3
id: finalize_matrix_step3
env:
input: ${{ steps.finalize_matrix_step2.outputs.json || '{}' }}
key: os
value: ${{ inputs.custom_runs_on }}

- name: Check for custom actions
id: custom
Expand Down Expand Up @@ -3704,16 +3725,11 @@ jobs:
- *resetGitHubDirectory
- *createLocalRefs

- name: Set the matrix value env var
shell: bash
run: |
{
echo "matrix_value=${{ matrix.value }}" ;
echo "os_value=$(echo '${{ toJSON(matrix.os) }}' | jq -c .)" ;
echo "environment=${{ matrix.environment }}" ;
} >> "${GITHUB_ENV}"
- uses: ./.github/actions/test
env:
matrix_value: ${{ matrix.value }}
os_value: ${{ toJSON(matrix.os) || inputs.runs_on }}
environment: ${{ matrix.environment }}
with:
json: ${{ toJSON(inputs) }}
secrets: ${{ toJSON(secrets) }}
Expand Down Expand Up @@ -3757,16 +3773,11 @@ jobs:
- *resetGitHubDirectory
- *createLocalRefs

- name: Set the matrix value env var
shell: bash
run: |
{
echo "matrix_value=${{ matrix.value }}" ;
echo "os_value=$(echo '${{ toJSON(matrix.os) }}' | jq -c .)" ;
echo "environment=${{ matrix.environment }}" ;
} >> "${GITHUB_ENV}"
- uses: ./.github/actions/publish
env:
matrix_value: ${{ matrix.value }}
os_value: ${{ toJSON(matrix.os) || inputs.runs_on }}
environment: ${{ matrix.environment }}
with:
json: ${{ toJSON(inputs) }}
secrets: ${{ toJSON(secrets) }}
Expand Down Expand Up @@ -3802,16 +3813,11 @@ jobs:
- *checkoutVersionedSha
- *resetGitHubDirectory

- name: Set the matrix value env var
shell: bash
run: |
{
echo "matrix_value=${{ matrix.value }}" ;
echo "os_value=$(echo '${{ toJSON(matrix.os) }}' | jq -c .)" ;
echo "environment=${{ matrix.environment }}" ;
} >> "${GITHUB_ENV}"
- uses: ./.github/actions/finalize
env:
matrix_value: ${{ matrix.value }}
os_value: ${{ toJSON(matrix.os) || inputs.runs_on }}
environment: ${{ matrix.environment }}
with:
json: ${{ toJSON(inputs) }}
secrets: ${{ toJSON(secrets) }}
Expand Down

0 comments on commit bda7801

Please sign in to comment.