|
36 | 36 | # them. This job automatically runs every night. |
37 | 37 | # - create-stable-release |
38 | 38 | # takes the fat and skinny JARs produced by configuration `release` during `build` job and creates a draft release with |
39 | | -# them. |
| 39 | +# them. This only works on branch `release`. |
40 | 40 |
|
41 | 41 | env: |
42 | 42 | Z3_VERSION: "4.8.6" |
43 | 43 |
|
44 | 44 | jobs: |
45 | | - build: |
| 45 | + prepare-matrix: |
46 | 46 | # build is the base job on which all other jobs depend |
47 | 47 | # we enforce here that the nightly build job only runs in the main repo: |
48 | 48 | if: (github.event_name == 'schedule' && github.repository == 'viperproject/viperserver') || (github.event_name != 'schedule') |
| 49 | + # sets up matrix for `build` job (based on https://stackoverflow.com/a/65434401/1990080) |
| 50 | + runs-on: ubuntu-latest |
| 51 | + outputs: |
| 52 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 53 | + steps: |
| 54 | + - id: set-matrix |
| 55 | + run: | |
| 56 | + # note that the values of `NAME` are also used in all other jobs and they have to match! |
| 57 | + IS_RELEASE=${{ github.ref == 'refs/heads/release' }} |
| 58 | + # skip 'latest' name on 'release' branch and ignore 'release' on all other branches' |
| 59 | + if [[ "$IS_RELEASE" == ${{ true }} ]] |
| 60 | + then |
| 61 | + NAME="release" |
| 62 | + SILVER_REF="v.21.07-release" |
| 63 | + SILICON_REF="v.21.07-release" |
| 64 | + CARBON_REF="v.21.07-release" |
| 65 | + else |
| 66 | + NAME="latest" |
| 67 | + SILVER_REF="master" |
| 68 | + SILICON_REF="master" |
| 69 | + CARBON_REF="master" |
| 70 | + fi |
| 71 | + # creates a JSON object that looks like the key-values in the GitHub documentation on `strategy.matrix` |
| 72 | + MATRIX="{ \ |
| 73 | + \"name\":[\"$NAME\"], \ |
| 74 | + \"include\": [{ \ |
| 75 | + \"name\":\"$NAME\", \ |
| 76 | + \"silver-ref\":\"$SILVER_REF\", \ |
| 77 | + \"silicon-ref\":\"$SILICON_REF\", \ |
| 78 | + \"carbon-ref\":\"$CARBON_REF\" \ |
| 79 | + }] \ |
| 80 | + }" |
| 81 | + # print matrix for debugging purposes: |
| 82 | + echo $MATRIX |
| 83 | + # set outputs of job: |
| 84 | + echo ::set-output name=matrix::$MATRIX |
| 85 | +
|
| 86 | + build: |
| 87 | + needs: prepare-matrix |
49 | 88 | runs-on: ubuntu-latest |
50 | 89 | container: viperproject/viperserver:v3_z3_4.8.6 |
51 | 90 | strategy: |
52 | 91 | # tests should not be stopped when they fail on one of the configurations: |
53 | 92 | fail-fast: false |
54 | | - matrix: |
55 | | - # note that the same names are also used in all other jobs and they have to match! |
56 | | - name: [latest, release] |
57 | | - include: |
58 | | - - name: latest |
59 | | - silver-ref: "master" |
60 | | - silicon-ref: "master" |
61 | | - carbon-ref: "master" |
62 | | - - name: release |
63 | | - silver-ref: "v.21.07-release" |
64 | | - silicon-ref: "v.21.07-release" |
65 | | - carbon-ref: "v.21.07-release" |
| 93 | + matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} |
66 | 94 | steps: |
67 | 95 | - name: Checkout ViperServer |
68 | 96 | uses: actions/checkout@v2 |
@@ -180,13 +208,13 @@ jobs: |
180 | 208 |
|
181 | 209 |
|
182 | 210 | test: |
183 | | - needs: build |
| 211 | + needs: [prepare-matrix, build] |
184 | 212 | strategy: |
185 | 213 | # tests should not be stopped when they fail on one of the OSes: |
186 | 214 | fail-fast: false |
187 | 215 | matrix: |
188 | 216 | os: [macos-latest, ubuntu-latest, windows-latest] |
189 | | - name: [latest, release] |
| 217 | + name: ${{ fromJson(needs.prepare-matrix.outputs.matrix).name }} |
190 | 218 | runs-on: ${{ matrix.os }} |
191 | 219 | steps: |
192 | 220 | # we need to checkout the repo to have access to the test files |
@@ -262,9 +290,9 @@ jobs: |
262 | 290 |
|
263 | 291 |
|
264 | 292 | create-nightly-release: |
| 293 | + needs: [prepare-matrix, test] |
265 | 294 | # this job creates a new nightly pre-release, set viperserver.jar as artifacts, and deletes old releases |
266 | | - if: (github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly') || github.event_name == 'schedule' |
267 | | - needs: test |
| 295 | + if: contains(fromJson(needs.prepare-matrix.outputs.matrix).name, 'latest') && ((github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly') || github.event_name == 'schedule') |
268 | 296 | runs-on: ubuntu-latest |
269 | 297 | env: |
270 | 298 | # specifies that `latest` artifacts from `build` job should be used for nightly releases: |
@@ -370,9 +398,9 @@ jobs: |
370 | 398 |
|
371 | 399 |
|
372 | 400 | create-stable-release: |
| 401 | + needs: [prepare-matrix, test] |
373 | 402 | # this job creates a stable draft-release and set viperserver.jar as artifacts |
374 | | - if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'stable' |
375 | | - needs: test |
| 403 | + if: contains(fromJson(needs.prepare-matrix.outputs.matrix).name, 'release') && github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'stable' |
376 | 404 | runs-on: ubuntu-latest |
377 | 405 | env: |
378 | 406 | # specifies that `release` artifacts from `build` job should be used for stable releases: |
|
0 commit comments