|
| 1 | +inputs: |
| 2 | + run-full-matrix: |
| 3 | + description: "Run the full matrix" |
| 4 | + required: true |
| 5 | + type: boolean |
| 6 | + containers: |
| 7 | + description: "Run in containers" |
| 8 | + required: true |
| 9 | + default: false |
| 10 | + type: boolean |
| 11 | + |
| 12 | +outputs: |
| 13 | + server-matrix-output: |
| 14 | + description: "Server matrix" |
| 15 | + value: ${{ steps.load-server-matrix.outputs.server-matrix }} |
| 16 | + os-matrix-output: |
| 17 | + description: "OS matrix" |
| 18 | + value: ${{ steps.load-os-matrix.outputs.os-matrix }} |
| 19 | + version-matrix-output: |
| 20 | + description: "Version matrix" |
| 21 | + value: ${{ steps.create-lang-version-matrix.outputs.version-matrix }} |
| 22 | + |
| 23 | +runs: |
| 24 | + using: "composite" |
| 25 | + steps: |
| 26 | + - name: "Setup Environment Variables" |
| 27 | + shell: bash |
| 28 | + env: |
| 29 | + RUN_FULL_MATRIX: ${{ inputs.run-full-matrix }} |
| 30 | + CONTAINERS: ${{ inputs.containers }} |
| 31 | + run: | |
| 32 | + echo "RUN_FULL_MATRIX=$RUN_FULL_MATRIX" >> $GITHUB_ENV |
| 33 | + echo "CONTAINERS=$CONTAINERS" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: Load server matrix |
| 36 | + id: load-server-matrix |
| 37 | + shell: bash |
| 38 | + working-directory: .github/json_matrices |
| 39 | + run: | |
| 40 | + set -o pipefail |
| 41 | + echo 'Select server versions to run tests against' |
| 42 | + if [[ "$RUN_FULL_MATRIX" == "true" ]]; then |
| 43 | + echo 'Pick all server versions - on cron (schedule) or if manually triggered job requires a full matrix' |
| 44 | + jq -c . < server-matrix.json | awk '{ printf "server-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo 'Pick server versions marked as `"run": "always"` only - on PR, push or manually triggered job which does not require full matrix' |
| 47 | + jq -c '[.[] | select(.run == "always")]' < server-matrix.json | awk '{ printf "server-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Load os matrix |
| 51 | + id: load-os-matrix |
| 52 | + shell: bash |
| 53 | + working-directory: .github/json_matrices |
| 54 | + run: | |
| 55 | + set -o pipefail |
| 56 | + [[ "$CONTAINERS" == "true" ]] && CONDITION=".IMAGE?" || CONDITION=".IMAGE == null" |
| 57 | + echo 'Select runners (VMs) to run tests on' |
| 58 | + if [[ "$RUN_FULL_MATRIX" == "true" ]]; then |
| 59 | + echo 'Pick all runners - on cron (schedule) or if manually triggered job requires a full matrix' |
| 60 | + jq -c "[.[] | select($CONDITION)]" < os-matrix.json | awk '{ printf "os-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + echo 'Pick runners marked as '"run": "always"' only - on PR, push or manually triggered job which does not require full matrix' |
| 63 | + jq -c '[.[] | select(.run == "always")]' < os-matrix.json | awk '{ printf "os-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Create language version matrix |
| 67 | + id: create-lang-version-matrix |
| 68 | + shell: bash |
| 69 | + working-directory: .github/json_matrices |
| 70 | + run: | |
| 71 | + set -o pipefail |
| 72 | + echo 'Select language (framework/SDK) versions to run tests on' |
| 73 | + if [[ "$RUN_FULL_MATRIX" == "true" ]]; then |
| 74 | + echo 'Pick language versions listed in 'versions' - on cron (schedule) or if manually triggered job requires a full matrix' |
| 75 | + jq -c ".versions" < version-matrix.json | awk '{ printf "version-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 76 | + else |
| 77 | + echo 'Pick language versions listed in 'always-run-versions' only - on PR, push or manually triggered job which does not require full matrix' |
| 78 | + jq -c ".\"always-run-versions\"" < version-matrix.json | awk '{ printf "version-matrix=%s\n", $0 }' | tee -a $GITHUB_OUTPUT |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Validate no empty/incorrect matrices |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + SERVERS=`jq length <<< '${{ steps.load-server-matrix.outputs.server-matrix }}'` |
| 85 | + if [[ $SERVERS == 0 ]]; then |
| 86 | + echo "Server version matrix is empty!" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + HOSTS=`jq length <<< '${{ steps.load-os-matrix.outputs.os-matrix }}'` |
| 90 | + if [[ $HOSTS == 0 ]]; then |
| 91 | + echo "OS matrix is empty!" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | + LANGS=`jq length <<< '${{ steps.create-lang-version-matrix.outputs.version-matrix }}'` |
| 95 | + if [[ $LANGS == 0 ]]; then |
| 96 | + echo "Dotnet version matrix is empty!" |
| 97 | + exit 1 |
| 98 | + fi |
0 commit comments