Skip to content

Commit

Permalink
Install a specific CodeQL version.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnebel committed Dec 13, 2024
1 parent 7110e6e commit 54132d4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 29 deletions.
48 changes: 48 additions & 0 deletions .github/actions/install-codeql/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Setup CodeQL CLI
description: |
Install a CodeQL CLI or re-use an existing one from the cache and it to the path.
inputs:
codeql-cli-version:
description: |
The version of the CodeQL CLI to be downloaded.
runs:
using: composite
steps:
- name: Cache CodeQL
id: cache-codeql
uses: actions/cache@v4
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ${{github.workspace}}/codeql_home
# An explicit key for restoring and saving the cache
key: codeql-home-${{ inputs.codeql-cli-version }}

- name: Install CodeQL
if: steps.cache-codeql.outputs.cache-hit != 'true'
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
CODEQL_HOME: ${{ github.workspace }}/codeql_home
CODEQL_CLI_VERSION: ${{ inputs.codeql-cli-version }}
run: |
mkdir -p $CODEQL_HOME
echo "Change directory to $CODEQL_HOME"
pushd $CODEQL_HOME
echo "Downloading CodeQL CLI v${CODEQL_CLI_VERSION}."
gh release download "v${CODEQL_CLI_VERSION}" --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip
echo "Unzipping CodeQL CLI."
unzip -q codeql-linux64.zip
popd
echo "Done."
- name: Add CodeQL to the PATH
shell: bash
env:
CODEQL_HOME: ${{ github.workspace }}/codeql_home
run: |
echo "Adding CodeQL CLI to the PATH."
echo "$CODEQL_HOME/codeql" >> $GITHUB_PATH
49 changes: 20 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ main ]
workflow_dispatch:

env:
CODEQL_CLI_VERSION: 2.19.2

jobs:
compile-and-test:
runs-on: ubuntu-latest
Expand All @@ -25,15 +28,12 @@ jobs:
src:
- '${{ matrix.language }}/**'
- name: Initialize CodeQL
- name: Setup CodeQL
if: steps.changes.outputs.src == 'true'
run: |
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
| sort \
| tail -n 1 \
| tr -d '\n')"
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}

- name: Install Packs
if: steps.changes.outputs.src == 'true'
env:
Expand Down Expand Up @@ -171,14 +171,11 @@ jobs:
src:
- '${{ matrix.language }}/ext/**'
- name: Initialize CodeQL
- name: Setup CodeQL
if: steps.changes.outputs.src == 'true'
run: |
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
| sort \
| tail -n 1 \
| tr -d '\n')"
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}

- name: Install Packs
if: steps.changes.outputs.src == 'true'
Expand Down Expand Up @@ -209,14 +206,11 @@ jobs:
src:
- '${{ matrix.language }}/ext-library-sources/**'
- name: Initialize CodeQL
- name: Setup CodeQL
if: steps.changes.outputs.src == 'true'
run: |
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
| sort \
| tail -n 1 \
| tr -d '\n')"
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}

- name: Install CodeQL
if: steps.changes.outputs.src == 'true'
Expand All @@ -240,14 +234,11 @@ jobs:
src:
- 'configs/**'
- name: Initialize CodeQL
- name: Setup CodeQL
if: steps.changes.outputs.src == 'true'
run: |
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
| sort \
| tail -n 1 \
| tr -d '\n')"
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}

- name: "Check Configurations"
if: steps.changes.outputs.src == 'true'
Expand Down

0 comments on commit 54132d4

Please sign in to comment.