From 50369b5618d87da9da651937165b1e25a1badf59 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Thu, 17 Apr 2025 09:43:07 +0100 Subject: [PATCH 1/7] feat(ci): Add support for .codeqlversion --- .codeqlversion | 1 + .github/actions/install-codeql/action.yml | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 .codeqlversion diff --git a/.codeqlversion b/.codeqlversion new file mode 100644 index 00000000..0352eb17 --- /dev/null +++ b/.codeqlversion @@ -0,0 +1 @@ +2.20.1 \ No newline at end of file diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index 4820f129..c0530088 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -26,6 +26,12 @@ runs: CODEQL_HOME: ${{ github.workspace }}/codeql_home CODEQL_CLI_VERSION: ${{ inputs.codeql-cli-version }} run: | + if [ -z "$CODEQL_CLI_VERSION" ]; then + echo "No CodeQL CLI version specified. Reading from .codeqlversion file." + CODEQL_CLI_VERSION=$(cat ./.codeqlversion) + fi + echo "Installing CodeQL CLI v${CODEQL_CLI_VERSION}." + mkdir -p $CODEQL_HOME echo "Change directory to $CODEQL_HOME" pushd $CODEQL_HOME From 9d14ab7b580188afafa13ca07f1c9f25bce8f264 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Mon, 28 Apr 2025 11:42:22 +0100 Subject: [PATCH 2/7] feat(ci): Enhance CodeQL action to output installed CLI version --- .github/actions/install-codeql/action.yml | 6 ++++++ .github/workflows/ci.yml | 7 ++----- .github/workflows/publish.yml | 4 ---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index c0530088..3243de7b 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -5,6 +5,10 @@ inputs: codeql-cli-version: description: | The version of the CodeQL CLI to be downloaded. +outputs: + codeql-cli-version: + description: "The version of the CodeQL CLI that was installed or retrieved from cache" + value: ${{ steps.install-codeql.outputs.codeql-cli-version }} runs: using: composite @@ -19,6 +23,7 @@ runs: key: codeql-home-${{ inputs.codeql-cli-version }} - name: Install CodeQL + id: install-codeql if: steps.cache-codeql.outputs.cache-hit != 'true' shell: bash env: @@ -44,6 +49,7 @@ runs: popd echo "Done." + echo "codeql-cli-version=${CODEQL_CLI_VERSION}" >> $GITHUB_OUTPUT - name: Add CodeQL to the PATH shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e7dcd64..503ef104 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,15 +31,14 @@ jobs: - name: Setup CodeQL if: steps.changes.outputs.src == 'true' + id: install-codeql uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Install Packs if: steps.changes.outputs.src == 'true' env: GITHUB_TOKEN: ${{ github.token }} - CODEQL_CLI_VERSION: ${{ env.CODEQL_CLI_VERSION }} + CODEQL_CLI_VERSION: ${{ steps.install-codeql.outputs.codeql-cli-version }} run: | gh repo clone github/codeql -- -b codeql-cli-${CODEQL_CLI_VERSION} # to make stubs available for tests codeql pack install "${{ matrix.language }}/lib" @@ -247,5 +246,3 @@ jobs: GITHUB_TOKEN: ${{ github.token }} run: | ./.github/scripts/pr-configs.sh "${{ github.event.number }}" - - diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0b4dd7e5..9d8064f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,8 +5,6 @@ on: branches: [main] workflow_dispatch: -env: - CODEQL_CLI_VERSION: 2.20.1 jobs: queries: @@ -42,8 +40,6 @@ jobs: - name: Setup CodeQL if: steps.check_version.outputs.publish == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Publish codeql-LANG-queries (src) pack. if: steps.check_version.outputs.publish == 'true' From d004692301f68b5ef28d7a719a8f32bc37940d67 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:43:29 +0100 Subject: [PATCH 3/7] Update .github/actions/install-codeql/action.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/actions/install-codeql/action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index 3243de7b..01904ded 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -32,7 +32,12 @@ runs: CODEQL_CLI_VERSION: ${{ inputs.codeql-cli-version }} run: | if [ -z "$CODEQL_CLI_VERSION" ]; then - echo "No CodeQL CLI version specified. Reading from .codeqlversion file." + echo "No CodeQL CLI version specified. Checking for .codeqlversion file." + if [ ! -f ./.codeqlversion ]; then + echo "Error: .codeqlversion file not found. Please specify a CodeQL CLI version." >&2 + exit 1 + fi + echo "Reading CodeQL CLI version from .codeqlversion file." CODEQL_CLI_VERSION=$(cat ./.codeqlversion) fi echo "Installing CodeQL CLI v${CODEQL_CLI_VERSION}." From bceaf784ad4550188c9cfb489df3b7ce6e56fe33 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Mon, 28 Apr 2025 15:29:40 +0100 Subject: [PATCH 4/7] feat(ci): Simplify CodeQL CLI version handling in action.yml --- .github/actions/install-codeql/action.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index 01904ded..97ce0f2a 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -2,9 +2,7 @@ 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. + outputs: codeql-cli-version: description: "The version of the CodeQL CLI that was installed or retrieved from cache" @@ -29,17 +27,11 @@ runs: env: GITHUB_TOKEN: ${{ github.token }} CODEQL_HOME: ${{ github.workspace }}/codeql_home - CODEQL_CLI_VERSION: ${{ inputs.codeql-cli-version }} run: | - if [ -z "$CODEQL_CLI_VERSION" ]; then - echo "No CodeQL CLI version specified. Checking for .codeqlversion file." - if [ ! -f ./.codeqlversion ]; then - echo "Error: .codeqlversion file not found. Please specify a CodeQL CLI version." >&2 - exit 1 - fi - echo "Reading CodeQL CLI version from .codeqlversion file." - CODEQL_CLI_VERSION=$(cat ./.codeqlversion) - fi + set -e + + echo "Reading CodeQL CLI version from .codeqlversion file." + CODEQL_CLI_VERSION=$(cat ./.codeqlversion) echo "Installing CodeQL CLI v${CODEQL_CLI_VERSION}." mkdir -p $CODEQL_HOME From 100afbec045812be429f42a0ea4fb4ec9ec36074 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Mon, 28 Apr 2025 15:33:09 +0100 Subject: [PATCH 5/7] refactor(ci): Remove unused input for CodeQL CLI version in action.yml and workflows --- .github/actions/install-codeql/action.yml | 1 - .github/workflows/publish.yml | 6 ------ 2 files changed, 7 deletions(-) diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index 97ce0f2a..4a9e892b 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -1,7 +1,6 @@ name: Setup CodeQL CLI description: | Install a CodeQL CLI or re-use an existing one from the cache and it to the path. -inputs: outputs: codeql-cli-version: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9d8064f6..bdc0889e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -83,8 +83,6 @@ jobs: - name: Setup CodeQL if: steps.check_version.outputs.publish == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Publish codeql-LANG-libs (lib) pack if: steps.check_version.outputs.publish == 'true' @@ -127,8 +125,6 @@ jobs: - name: Setup CodeQL if: steps.check_version.outputs.publish == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Publish codeql-LANG-extensions (ext) pack if: steps.check_version.outputs.publish == 'true' @@ -172,8 +168,6 @@ jobs: - name: Setup CodeQL if: steps.check_version.outputs.publish == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Publish codeql-LANG-library-sources (ext-library-sources) pack if: steps.check_version.outputs.publish == 'true' From 664ff2d9a57f0afa63ee5235952b4c1894dca962 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Mon, 28 Apr 2025 15:35:35 +0100 Subject: [PATCH 6/7] fix(ci): Remove CODEQL_CLI_VERSION environment variable and related inputs from ci.yml --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 503ef104..77145daf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,6 @@ on: branches: [ main ] workflow_dispatch: -env: - CODEQL_CLI_VERSION: 2.20.1 - jobs: compile-and-test: runs-on: ubuntu-latest @@ -174,8 +171,6 @@ jobs: - name: Setup CodeQL if: steps.changes.outputs.src == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Install Packs if: steps.changes.outputs.src == 'true' @@ -209,8 +204,6 @@ jobs: - name: Setup CodeQL if: steps.changes.outputs.src == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: Install CodeQL if: steps.changes.outputs.src == 'true' @@ -237,8 +230,6 @@ jobs: - name: Setup CodeQL if: steps.changes.outputs.src == 'true' uses: ./.github/actions/install-codeql - with: - codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }} - name: "Check Configurations" if: steps.changes.outputs.src == 'true' From 1993142e0addcbe90c019f5f7f4d4ada231e224a Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Mon, 28 Apr 2025 15:40:44 +0100 Subject: [PATCH 7/7] feat(ci): Update Action to read and output CodeQL Version --- .github/actions/install-codeql/action.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/actions/install-codeql/action.yml b/.github/actions/install-codeql/action.yml index 4a9e892b..19a3e1b0 100644 --- a/.github/actions/install-codeql/action.yml +++ b/.github/actions/install-codeql/action.yml @@ -5,11 +5,20 @@ description: | outputs: codeql-cli-version: description: "The version of the CodeQL CLI that was installed or retrieved from cache" - value: ${{ steps.install-codeql.outputs.codeql-cli-version }} + value: ${{ steps.codeql-version.outputs.codeql-cli-version }} runs: using: composite steps: + - name: "CodeQL Version" + id: codeql-version + shell: bash + run: | + echo "Reading CodeQL CLI version from .codeqlversion file." + CODEQL_CLI_VERSION=$(cat ./.codeqlversion) + echo "CODEQL_CLI_VERSION=${CODEQL_CLI_VERSION}" >> $GITHUB_ENV + echo "codeql-cli-version=${CODEQL_CLI_VERSION}" >> $GITHUB_OUTPUT + - name: Cache CodeQL id: cache-codeql uses: actions/cache@v4 @@ -17,7 +26,7 @@ runs: # 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 }} + key: codeql-home-${{ steps.codeql-version.outputs.codeql-cli-version }} - name: Install CodeQL id: install-codeql @@ -26,11 +35,8 @@ runs: env: GITHUB_TOKEN: ${{ github.token }} CODEQL_HOME: ${{ github.workspace }}/codeql_home + CODEQL_CLI_VERSION: ${{ steps.codeql-version.outputs.codeql-cli-version }} run: | - set -e - - echo "Reading CodeQL CLI version from .codeqlversion file." - CODEQL_CLI_VERSION=$(cat ./.codeqlversion) echo "Installing CodeQL CLI v${CODEQL_CLI_VERSION}." mkdir -p $CODEQL_HOME