|
7 | 7 | branches: [main, v1] |
8 | 8 |
|
9 | 9 | jobs: |
| 10 | + # Identify the CodeQL tool versions to use in the analysis job. |
| 11 | + check-codeql-versions: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + versions: ${{ steps.compare.outputs.versions }} |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - name: Init with default CodeQL bundle from the VM image |
| 19 | + id: init-default |
| 20 | + uses: ./init |
| 21 | + with: |
| 22 | + languages: javascript |
| 23 | + - name: Remove empty database |
| 24 | + # allows us to run init a second time |
| 25 | + run: | |
| 26 | + rm -rf "$RUNNER_TEMP/codeql_databases" |
| 27 | + - name: Init with latest CodeQL bundle |
| 28 | + id: init-latest |
| 29 | + uses: ./init |
| 30 | + with: |
| 31 | + tools: latest |
| 32 | + languages: javascript |
| 33 | + - name: Compare default and latest CodeQL bundle versions |
| 34 | + id: compare |
| 35 | + env: |
| 36 | + CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }} |
| 37 | + CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }} |
| 38 | + run: | |
| 39 | + CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)" |
| 40 | + CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)" |
| 41 | + echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT" |
| 42 | + echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST" |
| 43 | + if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then |
| 44 | + # Just use `tools: null` to avoid duplication in the analysis job. |
| 45 | + VERSIONS_JSON='[null]' |
| 46 | + else |
| 47 | + # Use both `tools: null` and `tools: latest` in the analysis job. |
| 48 | + VERSIONS_JSON='[null, "latest"]' |
| 49 | + fi |
| 50 | + # Output a JSON-encoded list with the distinct versions to test against. |
| 51 | + echo "Suggested matrix config for analysis job: $VERSIONS_JSON" |
| 52 | + echo "::set-output name=versions::${VERSIONS_JSON}" |
| 53 | +
|
10 | 54 | build: |
| 55 | + needs: [check-codeql-versions] |
11 | 56 | strategy: |
12 | 57 | matrix: |
13 | 58 | os: [ubuntu-latest,windows-latest,macos-latest] |
14 | | - tools: [~, latest] |
| 59 | + tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }} |
15 | 60 | runs-on: ${{ matrix.os }} |
16 | 61 |
|
17 | 62 | steps: |
|
0 commit comments