From efea9cca026eff7fe5311a32572d0b8eda9bfdd5 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Sat, 24 Jan 2026 13:43:15 +0000 Subject: [PATCH 1/2] Add `installYq` option to `sync.py` and cache downloads --- .github/workflows/__build-mode-autobuild.yml | 17 ++++++++++----- pr-checks/checks/build-mode-autobuild.yml | 6 +----- pr-checks/sync.py | 22 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/.github/workflows/__build-mode-autobuild.yml b/.github/workflows/__build-mode-autobuild.yml index 39ec213811..09fa8aee58 100644 --- a/.github/workflows/__build-mode-autobuild.yml +++ b/.github/workflows/__build-mode-autobuild.yml @@ -76,6 +76,18 @@ jobs: with: java-version: ${{ inputs.java-version || '17' }} distribution: temurin + - name: Restore choco cache + if: runner.os == 'Windows' + uses: actions/cache@v5 + with: + key: windows-choco-cache + path: ${{ runner.temp }}/windows-choco-cache + - name: Install yq + if: runner.os == 'Windows' + shell: pwsh + env: + CACHE_DIR: ${{ runner.temp }}/windows-choco-cache + run: choco install yq -y --stoponfirstfailure --cache-location=${env:CACHE_DIR} - name: Set up Java test repo configuration run: | mv * .github ../action/tests/multi-language-repo/ @@ -90,11 +102,6 @@ jobs: languages: java tools: ${{ steps.prepare-test.outputs.tools-url }} - - name: Install yq - if: runner.os == 'Windows' - run: | - choco install yq -y - - name: Validate database build mode run: | metadata_path="$RUNNER_TEMP/customDbLocation/java/codeql-database.yml" diff --git a/pr-checks/checks/build-mode-autobuild.yml b/pr-checks/checks/build-mode-autobuild.yml index 26b8626f22..8a51926faa 100644 --- a/pr-checks/checks/build-mode-autobuild.yml +++ b/pr-checks/checks/build-mode-autobuild.yml @@ -3,6 +3,7 @@ description: "An end-to-end integration test of a Java repository built using 'b operatingSystems: ["ubuntu", "windows"] versions: ["linked", "nightly-latest"] installJava: "true" +installYq: "true" steps: - name: Set up Java test repo configuration run: | @@ -18,11 +19,6 @@ steps: languages: java tools: ${{ steps.prepare-test.outputs.tools-url }} - - name: Install yq - if: runner.os == 'Windows' - run: | - choco install yq -y - - name: Validate database build mode run: | metadata_path="$RUNNER_TEMP/customDbLocation/java/codeql-database.yml" diff --git a/pr-checks/sync.py b/pr-checks/sync.py index 9d1296a549..fbaca470d5 100755 --- a/pr-checks/sync.py +++ b/pr-checks/sync.py @@ -223,6 +223,28 @@ def writeHeader(checkStream): } }) + installYq = is_truthy(checkSpecification.get('installYq', '')) + + if installYq: + steps.append({ + 'name': "Restore choco cache", + 'if': "runner.os == 'Windows'", + 'uses': 'actions/cache@v5', + 'with': { + 'key': 'windows-choco-cache', + 'path': '${{ runner.temp }}/windows-choco-cache' + } + }) + steps.append({ + 'name': 'Install yq', + 'if': "runner.os == 'Windows'", + 'shell': 'pwsh', + 'env': { + 'CACHE_DIR': '${{ runner.temp }}/windows-choco-cache' + }, + 'run': 'choco install yq -y --stoponfirstfailure --cache-location=${env:CACHE_DIR}', + }) + # If container initialisation steps are present in the check specification, # make sure to execute them first. if 'container' in checkSpecification and 'container-init-steps' in checkSpecification: From 605d404db0cf675582be6ebf20124de53bf13043 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Sat, 24 Jan 2026 14:09:33 +0000 Subject: [PATCH 2/2] Install `yq` directly from GitHub release --- .github/workflows/__build-mode-autobuild.yml | 13 ++++--------- pr-checks/sync.py | 19 ++++++------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/__build-mode-autobuild.yml b/.github/workflows/__build-mode-autobuild.yml index 09fa8aee58..4347905ed3 100644 --- a/.github/workflows/__build-mode-autobuild.yml +++ b/.github/workflows/__build-mode-autobuild.yml @@ -76,18 +76,13 @@ jobs: with: java-version: ${{ inputs.java-version || '17' }} distribution: temurin - - name: Restore choco cache - if: runner.os == 'Windows' - uses: actions/cache@v5 - with: - key: windows-choco-cache - path: ${{ runner.temp }}/windows-choco-cache - name: Install yq if: runner.os == 'Windows' - shell: pwsh env: - CACHE_DIR: ${{ runner.temp }}/windows-choco-cache - run: choco install yq -y --stoponfirstfailure --cache-location=${env:CACHE_DIR} + YQ_PATH: ${{ runner.temp }}/yq + run: |- + gh release download --repo mikefarah/yq --pattern "yq_windows_amd64.exe" v4.50.1 -O "$YQ_PATH/yq.exe" + echo "$YQ_PATH" >> "$GITHUB_PATH" - name: Set up Java test repo configuration run: | mv * .github ../action/tests/multi-language-repo/ diff --git a/pr-checks/sync.py b/pr-checks/sync.py index fbaca470d5..71f86ef521 100755 --- a/pr-checks/sync.py +++ b/pr-checks/sync.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import ruamel.yaml -from ruamel.yaml.scalarstring import SingleQuotedScalarString +from ruamel.yaml.scalarstring import SingleQuotedScalarString, LiteralScalarString import pathlib import os @@ -226,23 +226,16 @@ def writeHeader(checkStream): installYq = is_truthy(checkSpecification.get('installYq', '')) if installYq: - steps.append({ - 'name': "Restore choco cache", - 'if': "runner.os == 'Windows'", - 'uses': 'actions/cache@v5', - 'with': { - 'key': 'windows-choco-cache', - 'path': '${{ runner.temp }}/windows-choco-cache' - } - }) steps.append({ 'name': 'Install yq', 'if': "runner.os == 'Windows'", - 'shell': 'pwsh', 'env': { - 'CACHE_DIR': '${{ runner.temp }}/windows-choco-cache' + 'YQ_PATH': '${{ runner.temp }}/yq' }, - 'run': 'choco install yq -y --stoponfirstfailure --cache-location=${env:CACHE_DIR}', + 'run': LiteralScalarString( + 'gh release download --repo mikefarah/yq --pattern "yq_windows_amd64.exe" v4.50.1 -O "$YQ_PATH/yq.exe"\n' + 'echo "$YQ_PATH" >> "$GITHUB_PATH"' + ), }) # If container initialisation steps are present in the check specification,