From 3119b35eedcda944caf9e7b8519180ffe3710a51 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 15 Aug 2025 17:58:10 +0100 Subject: [PATCH 1/2] Add template option for installing Java --- ...obuild-direct-tracing-with-working-dir.yml | 19 ++++++++++++++-- .../workflows/__autobuild-direct-tracing.yml | 19 ++++++++++++++-- ...obuild-direct-tracing-with-working-dir.yml | 1 + pr-checks/checks/autobuild-direct-tracing.yml | 3 ++- pr-checks/sync.py | 22 +++++++++++++++++++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/__autobuild-direct-tracing-with-working-dir.yml b/.github/workflows/__autobuild-direct-tracing-with-working-dir.yml index 325d8c2d97..2cff8956e7 100644 --- a/.github/workflows/__autobuild-direct-tracing-with-working-dir.yml +++ b/.github/workflows/__autobuild-direct-tracing-with-working-dir.yml @@ -21,9 +21,19 @@ on: schedule: - cron: '0 5 * * *' workflow_dispatch: - inputs: {} + inputs: + java-version: + type: string + description: The version of Java to install + required: false + default: '17' workflow_call: - inputs: {} + inputs: + java-version: + type: string + description: The version of Java to install + required: false + default: '17' jobs: autobuild-direct-tracing-with-working-dir: strategy: @@ -54,6 +64,11 @@ jobs: version: ${{ matrix.version }} use-all-platform-bundle: 'false' setup-kotlin: 'true' + - name: Install Java + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.java-version || '17' }} + distribution: temurin - name: Test setup shell: bash run: | diff --git a/.github/workflows/__autobuild-direct-tracing.yml b/.github/workflows/__autobuild-direct-tracing.yml index 882174eab5..58273261f2 100644 --- a/.github/workflows/__autobuild-direct-tracing.yml +++ b/.github/workflows/__autobuild-direct-tracing.yml @@ -21,9 +21,19 @@ on: schedule: - cron: '0 5 * * *' workflow_dispatch: - inputs: {} + inputs: + java-version: + type: string + description: The version of Java to install + required: false + default: '17' workflow_call: - inputs: {} + inputs: + java-version: + type: string + description: The version of Java to install + required: false + default: '17' jobs: autobuild-direct-tracing: strategy: @@ -54,6 +64,11 @@ jobs: version: ${{ matrix.version }} use-all-platform-bundle: 'false' setup-kotlin: 'true' + - name: Install Java + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.java-version || '17' }} + distribution: temurin - name: Set up Java test repo configuration shell: bash run: | diff --git a/pr-checks/checks/autobuild-direct-tracing-with-working-dir.yml b/pr-checks/checks/autobuild-direct-tracing-with-working-dir.yml index e6ba989176..2cfab107c5 100644 --- a/pr-checks/checks/autobuild-direct-tracing-with-working-dir.yml +++ b/pr-checks/checks/autobuild-direct-tracing-with-working-dir.yml @@ -5,6 +5,7 @@ description: > autobuild Action. operatingSystems: ["ubuntu", "windows"] versions: ["linked", "nightly-latest"] +installJava: "true" env: CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING: true steps: diff --git a/pr-checks/checks/autobuild-direct-tracing.yml b/pr-checks/checks/autobuild-direct-tracing.yml index edc6122f13..9eb404459f 100644 --- a/pr-checks/checks/autobuild-direct-tracing.yml +++ b/pr-checks/checks/autobuild-direct-tracing.yml @@ -2,6 +2,7 @@ name: "Autobuild direct tracing" description: "An end-to-end integration test of a Java repository built using 'build-mode: autobuild', with direct tracing enabled" operatingSystems: ["ubuntu", "windows"] versions: ["linked", "nightly-latest"] +installJava: "true" env: CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING: true steps: @@ -19,7 +20,7 @@ steps: db-location: "${{ runner.temp }}/customDbLocation" languages: java tools: ${{ steps.prepare-test.outputs.tools-url }} - + - name: Check that indirect tracing is disabled shell: bash run: | diff --git a/pr-checks/sync.py b/pr-checks/sync.py index b937e43bb1..75316eea5a 100755 --- a/pr-checks/sync.py +++ b/pr-checks/sync.py @@ -138,6 +138,28 @@ def writeHeader(checkStream): } }) + installJava = False + if checkSpecification.get('installJava'): + installJava = True if checkSpecification['installJava'].lower() == "true" else False + + if installJava: + baseJavaVersionExpr = '17' + workflowInputs['java-version'] = { + 'type': 'string', + 'description': 'The version of Java to install', + 'required': False, + 'default': baseJavaVersionExpr, + } + + steps.append({ + 'name': 'Install Java', + 'uses': 'actions/setup-java@v4', + 'with': { + 'java-version': '${{ inputs.java-version || \'' + baseJavaVersionExpr + '\' }}', + 'distribution': 'temurin' + } + }) + # 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 1dafc5cf4c28caaf5f9419a5930ba65e59c8a0be Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 15 Aug 2025 18:06:57 +0100 Subject: [PATCH 2/2] Fix redundant `True` / `False` --- pr-checks/sync.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pr-checks/sync.py b/pr-checks/sync.py index 75316eea5a..dafb7f5216 100755 --- a/pr-checks/sync.py +++ b/pr-checks/sync.py @@ -114,9 +114,7 @@ def writeHeader(checkStream): }, ] - installGo = False - if checkSpecification.get('installGo'): - installGo = True if checkSpecification['installGo'].lower() == "true" else False + installGo = checkSpecification.get('installGo', '').lower() == 'true' if installGo: baseGoVersionExpr = '>=1.21.0' @@ -138,9 +136,7 @@ def writeHeader(checkStream): } }) - installJava = False - if checkSpecification.get('installJava'): - installJava = True if checkSpecification['installJava'].lower() == "true" else False + installJava = checkSpecification.get('installJava', '').lower() == 'true' if installJava: baseJavaVersionExpr = '17'