|
| 1 | +name: Run CLI tests |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * *' |
| 6 | + pull_request: |
| 7 | + types: [opened, synchronize, reopened, ready_for_review] |
| 8 | + paths: |
| 9 | + - extensions/ql-vscode/src/codeql-cli/** |
| 10 | + - extensions/ql-vscode/src/language-support/** |
| 11 | + - extensions/ql-vscode/src/query-server/** |
| 12 | + |
| 13 | +jobs: |
| 14 | + find-nightly: |
| 15 | + name: Find Nightly Release |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + url: ${{ steps.get-url.outputs.nightly-url }} |
| 19 | + steps: |
| 20 | + - name: Get Nightly Release URL |
| 21 | + id: get-url |
| 22 | + env: |
| 23 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 24 | + shell: bash |
| 25 | + # This workflow step gets an unstable testing version of the CodeQL CLI. It should not be used outside of these tests. |
| 26 | + run: | |
| 27 | + LATEST=`gh api repos/dsp-testing/codeql-cli-nightlies/releases --jq '.[].tag_name' --method GET --raw-field 'per_page=1'` |
| 28 | + echo "nightly-url=https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$LATEST" >> "$GITHUB_OUTPUT" |
| 29 | +
|
| 30 | + set-matrix: |
| 31 | + name: Set Matrix for cli-test |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v3 |
| 36 | + - name: Set the variables |
| 37 | + id: set-variables |
| 38 | + run: echo "cli-versions=$(cat ./extensions/ql-vscode/supported_cli_versions.json | jq -rc)" >> $GITHUB_OUTPUT |
| 39 | + outputs: |
| 40 | + cli-versions: ${{ steps.set-variables.outputs.cli-versions }} |
| 41 | + |
| 42 | + cli-test: |
| 43 | + name: CLI Test |
| 44 | + runs-on: ${{ matrix.os }} |
| 45 | + needs: [find-nightly, set-matrix] |
| 46 | + timeout-minutes: 30 |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + os: [ubuntu-latest, windows-latest] |
| 50 | + version: ${{ fromJson(needs.set-matrix.outputs.cli-versions) }} |
| 51 | + fail-fast: false |
| 52 | + env: |
| 53 | + CLI_VERSION: ${{ matrix.version }} |
| 54 | + NIGHTLY_URL: ${{ needs.find-nightly.outputs.url }} |
| 55 | + TEST_CODEQL_PATH: '${{ github.workspace }}/codeql' |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v3 |
| 60 | + |
| 61 | + - uses: actions/setup-node@v3 |
| 62 | + with: |
| 63 | + node-version: '16.17.1' |
| 64 | + cache: 'npm' |
| 65 | + cache-dependency-path: extensions/ql-vscode/package-lock.json |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + working-directory: extensions/ql-vscode |
| 69 | + run: | |
| 70 | + npm ci |
| 71 | + shell: bash |
| 72 | + |
| 73 | + - name: Build |
| 74 | + working-directory: extensions/ql-vscode |
| 75 | + run: | |
| 76 | + npm run build |
| 77 | + shell: bash |
| 78 | + |
| 79 | + - name: Decide on ref of CodeQL repo |
| 80 | + id: choose-ref |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + if [[ "${{ matrix.version }}" == "nightly" ]] |
| 84 | + then |
| 85 | + REF="codeql-cli/latest" |
| 86 | + else |
| 87 | + REF="codeql-cli/${{ matrix.version }}" |
| 88 | + fi |
| 89 | + echo "ref=$REF" >> "$GITHUB_OUTPUT" |
| 90 | +
|
| 91 | + - name: Checkout QL |
| 92 | + uses: actions/checkout@v3 |
| 93 | + with: |
| 94 | + repository: github/codeql |
| 95 | + ref: ${{ steps.choose-ref.outputs.ref }} |
| 96 | + path: codeql |
| 97 | + |
| 98 | + - name: Run CLI tests (Linux) |
| 99 | + working-directory: extensions/ql-vscode |
| 100 | + if: matrix.os == 'ubuntu-latest' |
| 101 | + run: | |
| 102 | + unset DBUS_SESSION_BUS_ADDRESS |
| 103 | + /usr/bin/xvfb-run npm run test:cli-integration |
| 104 | +
|
| 105 | + - name: Run CLI tests (Windows) |
| 106 | + working-directory: extensions/ql-vscode |
| 107 | + if: matrix.os == 'windows-latest' |
| 108 | + run: | |
| 109 | + npm run test:cli-integration |
0 commit comments