From b6e5d76aa62e950dd3dfe3b4219b4cb7c2166ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 12 Apr 2023 04:38:09 +0200 Subject: [PATCH 01/30] Write GitHub Actions workflow files in Kotlin instead of Yaml --- .github/workflows/branches-and-prs.main.kts | 151 +++++++++++ .github/workflows/branches-and-prs.yaml | 92 +++++++ .github/workflows/branches-and-prs.yml | 69 ----- .github/workflows/codeql-analysis.main.kts | 147 ++++++++++ .github/workflows/codeql-analysis.yaml | 59 ++++ .github/workflows/codeql-analysis.yml | 62 ----- .../gradle-wrapper-validation.main.kts | 51 ++++ .../workflows/gradle-wrapper-validation.yaml | 34 +++ .../workflows/gradle-wrapper-validation.yml | 10 - .github/workflows/release.main.kts | 255 ++++++++++++++++++ .github/workflows/release.yaml | 167 ++++++++++++ .github/workflows/release.yml | 114 -------- build.gradle | 45 +++- 13 files changed, 1000 insertions(+), 256 deletions(-) create mode 100755 .github/workflows/branches-and-prs.main.kts create mode 100644 .github/workflows/branches-and-prs.yaml delete mode 100644 .github/workflows/branches-and-prs.yml create mode 100755 .github/workflows/codeql-analysis.main.kts create mode 100644 .github/workflows/codeql-analysis.yaml delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100755 .github/workflows/gradle-wrapper-validation.main.kts create mode 100644 .github/workflows/gradle-wrapper-validation.yaml delete mode 100644 .github/workflows/gradle-wrapper-validation.yml create mode 100755 .github/workflows/release.main.kts create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts new file mode 100755 index 0000000000..0f471bcb84 --- /dev/null +++ b/.github/workflows/branches-and-prs.main.kts @@ -0,0 +1,151 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 +import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 +import io.github.typesafegithub.workflows.domain.Concurrency +import io.github.typesafegithub.workflows.domain.RunnerType +import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.triggers.PullRequest +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.dsl.expressions.Contexts +import io.github.typesafegithub.workflows.dsl.expressions.expr +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Verify Branches and PRs", + on = listOf( + Push( + branchesIgnore = listOf( + "master", + "gh-pages" + ) + ), + PullRequest() + ), + sourceFile = __FILE__.toPath(), + //# https://stackoverflow.com/a/72408109/16358266 + concurrency = Concurrency( + group = "${expr { github.workflow }}-${expr("${Contexts.github.eventPullRequest.pull_request.number} || ${Contexts.github.ref}")}", + cancelInProgress = true + ) +) { + job( + id = "build-and-verify", + name = "Build and Verify", + runsOn = RunnerType.Custom(expr("matrix.os")), + _customArguments = mapOf( + "strategy" to mapOf( + "fail-fast" to false, + "matrix" to mapOf( + "os" to listOf("ubuntu-latest"), + "variant" to listOf("2.5", "3.0", "4.0"), + "java" to listOf("8", "11", "17"), + "exclude" to listOf( + mapOf( + "os" to "ubuntu-latest", + "variant" to "2.5", + "java" to "17" + ) + ), + "include" to listOf( + mapOf( + "os" to "windows-latest", + "variant" to "2.5", + "java" to "8" + ), + mapOf( + "os" to "windows-latest", + "variant" to "3.0", + "java" to "8" + ), + mapOf( + "os" to "windows-latest", + "variant" to "4.0", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "2.5", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "3.0", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "4.0", + "java" to "8" + ) + ) + ) + ) + ) + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3( + // Codecov needs fetch-depth > 1 + fetchDepth = CheckoutV3.FetchDepth.Value(2) + ) + ) + uses( + name = "Set up JDKs", + action = CustomAction( + actionOwner = ".github", + actionName = "actions/setup-build-env", + actionVersion = "v0", + inputs = mapOf( + "additional-java-version" to expr("matrix.java") + ) + ), + _customArguments = mapOf( + "uses" to "./.github/actions/setup-build-env" + ) + ) + val SPOCK_BUILD_CACHE_USERNAME by Contexts.secrets + val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets + val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets + uses( + name = "Build Spock", + action = GradleBuildActionV2( + arguments = """--no-parallel --stacktrace ghActionsBuild "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ + expr( + "matrix.java" + ) + }"""" + ), + // secrets are not injected for pull requests + env = linkedMapOf( + "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), + "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), + "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) + ) + ) + uses( + name = "Upload to Codecov.io", + action = CodecovActionV3() + ) + } +}.writeToFile() diff --git a/.github/workflows/branches-and-prs.yaml b/.github/workflows/branches-and-prs.yaml new file mode 100644 index 0000000000..b00c2f26d7 --- /dev/null +++ b/.github/workflows/branches-and-prs.yaml @@ -0,0 +1,92 @@ +# This file was generated using Kotlin DSL (.github/workflows/branches-and-prs.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: Verify Branches and PRs +on: + push: + branches-ignore: + - master + - gh-pages + pull_request: {} +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + check_yaml_consistency: + name: Check YAML consistency + runs-on: ubuntu-latest + steps: + - id: step-0 + name: Check out + uses: actions/checkout@v3 + - id: step-1 + name: Execute script + run: rm '.github/workflows/branches-and-prs.yaml' && '.github/workflows/branches-and-prs.main.kts' + - id: step-2 + name: Consistency check + run: git diff --exit-code '.github/workflows/branches-and-prs.yaml' + build-and-verify: + name: Build and Verify + runs-on: ${{ matrix.os }} + needs: + - check_yaml_consistency + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + variant: + - 2.5 + - 3.0 + - 4.0 + java: + - 8 + - 11 + - 17 + exclude: + - os: ubuntu-latest + variant: 2.5 + java: 17 + include: + - os: windows-latest + variant: 2.5 + java: 8 + - os: windows-latest + variant: 3.0 + java: 8 + - os: windows-latest + variant: 4.0 + java: 8 + - os: macos-latest + variant: 2.5 + java: 8 + - os: macos-latest + variant: 3.0 + java: 8 + - os: macos-latest + variant: 4.0 + java: 8 + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - id: step-1 + name: Set up JDKs + uses: ./.github/actions/setup-build-env + with: + additional-java-version: ${{ matrix.java }} + - id: step-2 + name: Build Spock + uses: gradle/gradle-build-action@v2 + with: + arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" + env: + ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} + ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - id: step-3 + name: Upload to Codecov.io + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml deleted file mode 100644 index 83c0753656..0000000000 --- a/.github/workflows/branches-and-prs.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: 'Verify Branches and PRs' - -on: - push: - branches-ignore: - - master - - gh-pages - pull_request: - merge_group: - -# https://stackoverflow.com/a/72408109/16358266 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - build-and-verify: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - variant: ['2.5', '3.0', '4.0'] - java: ['8', '11', '17', '21', '22'] - os: ['ubuntu-latest'] - exclude: - - variant: '2.5' - java: '17' - os: 'ubuntu-latest' - - variant: '2.5' - java: '21' - os: 'ubuntu-latest' - - variant: '2.5' - java: '22' - os: 'ubuntu-latest' - include: - - variant: '2.5' - java: '8' - os: 'windows-latest' - - variant: '3.0' - java: '8' - os: 'windows-latest' - - variant: '4.0' - java: '8' - os: 'windows-latest' - - variant: '2.5' - java: '8' - os: 'macos-latest' - - variant: '3.0' - java: '8' - os: 'macos-latest' - - variant: '4.0' - java: '8' - os: 'macos-latest' - steps: - - uses: actions/checkout@v4 - with: - # Codecov needs fetch-depth > 1 - fetch-depth: 2 - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - with: - additional-java-version: ${{ matrix.java }} - - name: 'Build Spock' - # secrets are not injected for pull requests - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - run: ./gradlew --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" - - name: 'Upload to Codecov.io' - uses: codecov/codecov-action@v4 diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts new file mode 100755 index 0000000000..6c45168510 --- /dev/null +++ b/.github/workflows/codeql-analysis.main.kts @@ -0,0 +1,147 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 +import io.github.typesafegithub.workflows.domain.Concurrency +import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.triggers.Cron +import io.github.typesafegithub.workflows.domain.triggers.PullRequest +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.domain.triggers.Schedule +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github +import io.github.typesafegithub.workflows.dsl.expressions.expr +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Code scanning - action", + on = listOf( + Push( + branches = listOf("!dependabot/**") + ), + PullRequest(), + Schedule( + listOf( + Cron( + minute = "0", + hour = "15", + dayWeek = "TUE" + ) + ) + ) + ), + sourceFile = __FILE__.toPath(), + //# https://stackoverflow.com/a/72408109/16358266 + concurrency = Concurrency( + group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}", + cancelInProgress = true + ) +) { + job( + id = "codeql-build", + name = "CodeQL-Build", + // CodeQL runs on UbuntuLatest, WindowsLatest, and MacOSLatest + runsOn = UbuntuLatest, + _customArguments = mapOf( + "strategy" to mapOf( + "fail-fast" to false, + "matrix" to mapOf( + "variant" to listOf("2.5", "3.0", "4.0") + ) + ) + ) + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3() + ) + // Manually added: Install and setup JDK + uses( + name = "Set up JDKs", + action = CustomAction( + actionOwner = ".github", + actionName = "actions/setup-build-env", + actionVersion = "v0", + inputs = emptyMap() + ), + _customArguments = mapOf( + "uses" to "./.github/actions/setup-build-env" + ) + ) + // Initializes the CodeQL tools for scanning + uses( + name = "Initialize CodeQL", + action = CustomAction( + actionOwner = "github", + actionName = "codeql-action/init", + actionVersion = "v3", + inputs = emptyMap() + // Override language selection by uncommenting this and choosing your languages + //inputs = mapOf("languages" to "go, javascript, csharp, python, cpp, java") + ) + ) + // Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + // If this step fails, then you should remove it and run the build manually (see below). + //uses( + // name = "Autobuild", + // action = CustomAction( + // actionOwner = "github", + // actionName = "codeql-action/autobuild", + // actionVersion = "v1", + // inputs = emptyMap() + // ) + //) + // + // ℹī¸ Command-line programs to run using the OS shell. + // 📚 https://git.io/JvXDl + // + // ✏ī¸ If the Autobuild fails above, remove it and uncomment the following + // three lines and modify them (or add more) to build your code if your + // project uses a compiled language + // + //run( + // command = """ + // make bootstrap + // make release + // """.trimIndent() + //) + + // Manually added: build + // we have to disable build cache for now as it seems to be necessary for the compiler to run during the build + // https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-the-codeql-workflow#no-code-found-during-the-build + uses( + name = "Build Spock Classes", + action = GradleBuildActionV2( + arguments = """--stacktrace --no-build-cache testClasses "-Dvariant=${expr("matrix.variant")}"""" + ) + ) + uses( + name = "Perform CodeQL Analysis", + action = CustomAction( + actionOwner = "github", + actionName = "codeql-action/analyze", + actionVersion = "v3", + inputs = emptyMap() + ) + ) + } +}.writeToFile() diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml new file mode 100644 index 0000000000..86a3832ffb --- /dev/null +++ b/.github/workflows/codeql-analysis.yaml @@ -0,0 +1,59 @@ +# This file was generated using Kotlin DSL (.github/workflows/codeql-analysis.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: Code scanning - action +on: + push: + branches: + - '!dependabot/**' + pull_request: {} + schedule: + - cron: 0 15 * * TUE +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + check_yaml_consistency: + name: Check YAML consistency + runs-on: ubuntu-latest + steps: + - id: step-0 + name: Check out + uses: actions/checkout@v3 + - id: step-1 + name: Execute script + run: rm '.github/workflows/codeql-analysis.yaml' && '.github/workflows/codeql-analysis.main.kts' + - id: step-2 + name: Consistency check + run: git diff --exit-code '.github/workflows/codeql-analysis.yaml' + codeql-build: + name: CodeQL-Build + runs-on: ubuntu-latest + needs: + - check_yaml_consistency + strategy: + fail-fast: false + matrix: + variant: + - 2.5 + - 3.0 + - 4.0 + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + - id: step-1 + name: Set up JDKs + uses: ./.github/actions/setup-build-env + - id: step-2 + name: Initialize CodeQL + uses: github/codeql-action/init@v3 + - id: step-3 + name: Build Spock Classes + uses: gradle/gradle-build-action@v2 + with: + arguments: --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}" + - id: step-4 + name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index a9d632bb86..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: "Code scanning - action" - -on: - push: - branches: - - '!dependabot/**' - pull_request: - merge_group: - schedule: - - cron: '0 15 * * 2' - -# https://stackoverflow.com/a/72408109/16358266 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - CodeQL-Build: - # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - variant: [ '2.5', '3.0', '4.0' ] - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Manually added: Install and setup JDK - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below). - #- name: Autobuild - # uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following - # three lines and modify them (or add more) to build your code if your - # project uses a compiled language - - #- run: | - # make bootstrap - # make release - - # Manually added: build - # we have to disable build cache for now as it seems to be necessary for the compiler to run during the build - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-the-codeql-workflow#no-code-found-during-the-build - - name: 'Build Spock Classes' - run: ./gradlew --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}" - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts new file mode 100755 index 0000000000..6e0e014e68 --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -0,0 +1,51 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 +import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.triggers.PullRequest +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Validate Gradle Wrapper", + on = listOf( + Push(), + PullRequest() + ), + sourceFile = __FILE__.toPath() +) { + job( + id = "validation", + name = "Validation", + runsOn = UbuntuLatest + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3() + ) + uses( + name = "Validate Wrapper", + action = WrapperValidationActionV1() + ) + } +}.writeToFile() diff --git a/.github/workflows/gradle-wrapper-validation.yaml b/.github/workflows/gradle-wrapper-validation.yaml new file mode 100644 index 0000000000..19bda3bd90 --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yaml @@ -0,0 +1,34 @@ +# This file was generated using Kotlin DSL (.github/workflows/gradle-wrapper-validation.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: Validate Gradle Wrapper +on: + push: {} + pull_request: {} +jobs: + check_yaml_consistency: + name: Check YAML consistency + runs-on: ubuntu-latest + steps: + - id: step-0 + name: Check out + uses: actions/checkout@v3 + - id: step-1 + name: Execute script + run: rm '.github/workflows/gradle-wrapper-validation.yaml' && '.github/workflows/gradle-wrapper-validation.main.kts' + - id: step-2 + name: Consistency check + run: git diff --exit-code '.github/workflows/gradle-wrapper-validation.yaml' + validation: + name: Validation + runs-on: ubuntu-latest + needs: + - check_yaml_consistency + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + - id: step-1 + name: Validate Wrapper + uses: gradle/wrapper-validation-action@v1 diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml deleted file mode 100644 index a95413f88c..0000000000 --- a/.github/workflows/gradle-wrapper-validation.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: "Validate Gradle Wrapper" -on: [push, pull_request, merge_group] - -jobs: - validation: - name: "Validation" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v3 diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts new file mode 100755 index 0000000000..d69863b5b7 --- /dev/null +++ b/.github/workflows/release.main.kts @@ -0,0 +1,255 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth +import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 +import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 +import io.github.typesafegithub.workflows.domain.RunnerType +import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.dsl.expressions.Contexts +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github +import io.github.typesafegithub.workflows.dsl.expressions.expr +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Build and Release Spock", + on = listOf( + Push( + branches = listOf("master"), + tags = listOf("spock-*") + ) + ), + sourceFile = __FILE__.toPath() +) { + val GITHUB_TOKEN by Contexts.secrets + val SONATYPE_OSS_USER by Contexts.secrets + val SONATYPE_OSS_PASSWORD by Contexts.secrets + val SIGNING_GPG_PASSWORD by Contexts.secrets + val SPOCK_BUILD_CACHE_USERNAME by Contexts.secrets + val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets + val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets + + val buildAndVerify = job( + id = "build-and-verify", + name = "Build and Verify", + runsOn = RunnerType.Custom(expr("matrix.os")), + condition = "${github.repository} == 'spockframework/spock'", + _customArguments = mapOf( + "strategy" to mapOf( + "fail-fast" to false, + "matrix" to mapOf( + "os" to listOf("ubuntu-latest"), + "variant" to listOf("2.5", "3.0", "4.0"), + "java" to listOf("8", "11", "17"), + "exclude" to listOf( + mapOf( + "os" to "ubuntu-latest", + "variant" to "2.5", + "java" to "17" + ) + ), + "include" to listOf( + mapOf( + "os" to "windows-latest", + "variant" to "2.5", + "java" to "8" + ), + mapOf( + "os" to "windows-latest", + "variant" to "3.0", + "java" to "8" + ), + mapOf( + "os" to "windows-latest", + "variant" to "4.0", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "2.5", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "3.0", + "java" to "8" + ), + mapOf( + "os" to "macos-latest", + "variant" to "4.0", + "java" to "8" + ) + ) + ) + ) + ) + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3( + // Codecov needs fetch-depth > 1 + fetchDepth = FetchDepth.Value(2) + ) + ) + uses( + name = "Set up JDKs", + action = CustomAction( + actionOwner = ".github", + actionName = "actions/setup-build-env", + actionVersion = "v0", + inputs = mapOf( + "additional-java-version" to expr("matrix.java") + ) + ), + _customArguments = mapOf( + "uses" to "./.github/actions/setup-build-env" + ) + ) + uses( + name = "Build Spock", + action = GradleBuildActionV2( + arguments = """--no-parallel --stacktrace ghActionsBuild "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ + expr( + "matrix.java" + ) + }" "-Dscan.tag.main-build"""" + ), + env = linkedMapOf( + "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), + "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), + "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) + ) + ) + run( + name = "Stop Daemon", + command = "./gradlew --stop" + ) + uses( + name = "Upload to Codecov.io", + action = CodecovActionV3() + ) + } + val releaseSpock = job( + id = "release-spock", + name = "Release Spock", + runsOn = RunnerType.Custom(expr("matrix.os")), + needs = listOf(buildAndVerify), + strategyMatrix = mapOf( + "os" to listOf("ubuntu-latest"), + // publish needs to be done for all versions + "variant" to listOf("2.5", "3.0", "4.0"), + // publish needs the min supported java version + "java" to listOf("8") + ) + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3() + ) + uses( + name = "Set up JDKs", + action = CustomAction( + actionOwner = ".github", + actionName = "actions/setup-build-env", + actionVersion = "v0", + inputs = mapOf( + "additional-java-version" to expr("matrix.java") + ) + ), + _customArguments = mapOf( + "uses" to "./.github/actions/setup-build-env" + ) + ) + uses( + name = "Publish Spock", + action = GradleBuildActionV2( + arguments = """--no-parallel --stacktrace ghActionsPublish "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ + expr( + "matrix.java" + ) + }" "-Dscan.tag.main-publish"""" + ), + env = linkedMapOf( + "GITHUB_TOKEN" to expr(GITHUB_TOKEN), + "SONATYPE_OSS_USER" to expr(SONATYPE_OSS_USER), + "SONATYPE_OSS_PASSWORD" to expr(SONATYPE_OSS_PASSWORD), + "SIGNING_PASSWORD" to expr(SIGNING_GPG_PASSWORD), + "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), + "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), + "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) + ) + ) + } + job( + id = "publish-release-docs", + name = "Publish Release Docs", + runsOn = RunnerType.Custom(expr("matrix.os")), + needs = listOf(releaseSpock), + strategyMatrix = mapOf( + "os" to listOf("ubuntu-latest"), + // docs need the highest variant + "variant" to listOf("4.0"), + // docs need the highest java version + "java" to listOf("17") + ) + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3() + ) + uses( + name = "Set up JDKs", + action = CustomAction( + actionOwner = ".github", + actionName = "actions/setup-build-env", + actionVersion = "v0", + inputs = mapOf( + "additional-java-version" to expr("matrix.java") + ) + ), + _customArguments = mapOf( + "uses" to "./.github/actions/setup-build-env" + ) + ) + run( + name = "Create Temporary Branch", + command = "git checkout -b \"docs-\$GITHUB_SHA\"" + ) + uses( + name = "Publish Docs", + action = GradleBuildActionV2( + arguments = """--no-parallel --stacktrace ghActionsDocs "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ + expr( + "matrix.java" + ) + }" "-Dscan.tag.main-docs"""" + ), + env = linkedMapOf( + "GITHUB_TOKEN" to expr(GITHUB_TOKEN), + "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), + "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), + "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) + ) + ) + } +}.writeToFile() diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..8edf539c9f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,167 @@ +# This file was generated using Kotlin DSL (.github/workflows/release.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: Build and Release Spock +on: + push: + branches: + - master + tags: + - spock-* +jobs: + check_yaml_consistency: + name: Check YAML consistency + runs-on: ubuntu-latest + steps: + - id: step-0 + name: Check out + uses: actions/checkout@v3 + - id: step-1 + name: Execute script + run: rm '.github/workflows/release.yaml' && '.github/workflows/release.main.kts' + - id: step-2 + name: Consistency check + run: git diff --exit-code '.github/workflows/release.yaml' + build-and-verify: + name: Build and Verify + runs-on: ${{ matrix.os }} + needs: + - check_yaml_consistency + if: github.repository == 'spockframework/spock' + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + variant: + - 2.5 + - 3.0 + - 4.0 + java: + - 8 + - 11 + - 17 + exclude: + - os: ubuntu-latest + variant: 2.5 + java: 17 + include: + - os: windows-latest + variant: 2.5 + java: 8 + - os: windows-latest + variant: 3.0 + java: 8 + - os: windows-latest + variant: 4.0 + java: 8 + - os: macos-latest + variant: 2.5 + java: 8 + - os: macos-latest + variant: 3.0 + java: 8 + - os: macos-latest + variant: 4.0 + java: 8 + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - id: step-1 + name: Set up JDKs + uses: ./.github/actions/setup-build-env + with: + additional-java-version: ${{ matrix.java }} + - id: step-2 + name: Build Spock + uses: gradle/gradle-build-action@v2 + with: + arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-build" + env: + ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} + ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - id: step-3 + name: Stop Daemon + run: ./gradlew --stop + - id: step-4 + name: Upload to Codecov.io + uses: codecov/codecov-action@v3 + release-spock: + name: Release Spock + runs-on: ${{ matrix.os }} + needs: + - build-and-verify + - check_yaml_consistency + strategy: + matrix: + os: + - ubuntu-latest + variant: + - 2.5 + - 3.0 + - 4.0 + java: + - 8 + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + - id: step-1 + name: Set up JDKs + uses: ./.github/actions/setup-build-env + with: + additional-java-version: ${{ matrix.java }} + - id: step-2 + name: Publish Spock + uses: gradle/gradle-build-action@v2 + with: + arguments: --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-publish" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONATYPE_OSS_USER: ${{ secrets.SONATYPE_OSS_USER }} + SONATYPE_OSS_PASSWORD: ${{ secrets.SONATYPE_OSS_PASSWORD }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_GPG_PASSWORD }} + ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} + ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + publish-release-docs: + name: Publish Release Docs + runs-on: ${{ matrix.os }} + needs: + - release-spock + - check_yaml_consistency + strategy: + matrix: + os: + - ubuntu-latest + variant: + - 4.0 + java: + - 17 + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + - id: step-1 + name: Set up JDKs + uses: ./.github/actions/setup-build-env + with: + additional-java-version: ${{ matrix.java }} + - id: step-2 + name: Create Temporary Branch + run: git checkout -b "docs-$GITHUB_SHA" + - id: step-3 + name: Publish Docs + uses: gradle/gradle-build-action@v2 + with: + arguments: --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-docs" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} + ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 75b7dd4bf2..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: 'Build and Release Spock' - -on: - push: - branches: - - master - tags: - - 'spock-*' - -jobs: - build-and-verify: - runs-on: ${{ matrix.os }} - if: github.repository == 'spockframework/spock' - strategy: - fail-fast: false - matrix: - variant: ['2.5', '3.0', '4.0'] - java: [ '8', '11', '17', '21', '22' ] - os: [ 'ubuntu-latest' ] - exclude: - - variant: '2.5' - java: '17' - os: 'ubuntu-latest' - - variant: '2.5' - java: '21' - os: 'ubuntu-latest' - - variant: '2.5' - java: '22' - os: 'ubuntu-latest' - include: - - variant: '2.5' - java: '8' - os: 'windows-latest' - - variant: '3.0' - java: '8' - os: 'windows-latest' - - variant: '4.0' - java: '8' - os: 'windows-latest' - - variant: '2.5' - java: '8' - os: 'macos-latest' - - variant: '3.0' - java: '8' - os: 'macos-latest' - - variant: '4.0' - java: '8' - os: 'macos-latest' - steps: - - uses: actions/checkout@v4 - with: - # Codecov needs fetch-depth > 1 - fetch-depth: 2 - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - with: - additional-java-version: ${{ matrix.java }} - - name: 'Build Spock' - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - run: ./gradlew --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-build" - - name: 'Stop Daemon' - run: | - ./gradlew --stop - - name: 'Upload to Codecov.io' - uses: codecov/codecov-action@v4 - - release-spock: - runs-on: ${{ matrix.os }} - needs: [ 'build-and-verify' ] - strategy: - matrix: - os: [ 'ubuntu-latest' ] - variant: [ '2.5', '3.0', '4.0' ] # publish needs to be done for all versions - java: [ '8' ] # publish needs the min supported java version - steps: - - uses: actions/checkout@v4 - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - with: - additional-java-version: ${{ matrix.java }} - - name: 'Publish Spock' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_OSS_USER: ${{ secrets.SONATYPE_OSS_USER }} - SONATYPE_OSS_PASSWORD: ${{ secrets.SONATYPE_OSS_PASSWORD }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_GPG_PASSWORD }} - DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - run: ./gradlew --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-publish" - - publish-release-docs: - runs-on: ${{ matrix.os }} - needs: ['release-spock'] - strategy: - matrix: - os: ['ubuntu-latest'] - variant: ['4.0'] # docs need the highest variant - java: ['21'] # docs need the highest java version - steps: - - uses: actions/checkout@v4 - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - with: - additional-java-version: ${{ matrix.java }} - - name: 'Create Temporary Branch' - run: | - git checkout -b "docs-$GITHUB_SHA" - - name: Install GraphViz - run: sudo apt update && sudo apt install --yes graphviz - - name: 'Publish Docs' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - run: ./gradlew --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-docs" diff --git a/build.gradle b/build.gradle index 941719f982..9aca66a58a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import static org.spockframework.gradle.AsciiDocLinkVerifier.verifyLinksAndAncho plugins { id "org.spockframework.base" apply false - id "base" + id "java-base" id "org.asciidoctor.jvm.convert" id "jacoco" id "net.nemerosa.versioning" @@ -441,3 +441,46 @@ def configureGroovydoc(TaskProvider groovydoc) { include "spock/**" } } + +configurations { + kotlinCompilerClasspath { + canBeConsumed = false + } + kotlinScriptClasspath { + canBeConsumed = false + } +} + +dependencies { + kotlinCompilerClasspath 'org.jetbrains.kotlin:kotlin-compiler:1.8.20' + kotlinCompilerClasspath 'org.jetbrains.kotlin:kotlin-scripting-compiler:1.8.20' + kotlinScriptClasspath('org.jetbrains.kotlin:kotlin-main-kts:1.8.20') { transitive = false } +} + +def preprocessWorkflows = tasks.register('preprocessWorkflows') +file('.github/workflows').eachFileMatch(~/.*\.main\.kts$/) { workflowScript -> + def workflowName = workflowScript.name - ~/\.main\.kts$/ + def pascalCasedWorkflowName = workflowName + .replaceAll(/-\w/) { it[1].toUpperCase() } + .replaceFirst(/^\w/) { it[0].toUpperCase() } + def preprocessWorkflow = tasks.register("preprocess${pascalCasedWorkflowName}Workflow", JavaExec) { + inputs + .file(workflowScript) + .withPropertyName('workflowScript') + outputs + .file(new File(workflowScript.parent, "${workflowName}.yaml")) + .withPropertyName('workflowFile') + + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(17) + } + classpath(configurations.kotlinCompilerClasspath) + mainClass = 'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler' + args('-no-stdlib', '-no-reflect') + args('-classpath', configurations.kotlinScriptClasspath.asPath) + args('-script', workflowScript.absolutePath) + } + preprocessWorkflows.configure { + dependsOn(preprocessWorkflow) + } +} From d22743b58f6639168f7d94a61badbd3451d4f357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 17 Apr 2023 04:17:21 +0200 Subject: [PATCH 02/30] Update to latest github-workflows-kt version and some improvements --- .editorconfig | 4 + .github/workflows/branches-and-prs.main.kts | 40 +++++---- .github/workflows/codeql-analysis.main.kts | 76 ++++++++-------- .../gradle-wrapper-validation.main.kts | 2 +- .github/workflows/release.main.kts | 89 +++++++++---------- .github/workflows/release.yaml | 6 +- 6 files changed, 108 insertions(+), 109 deletions(-) diff --git a/.editorconfig b/.editorconfig index af6e9e0d27..be09a3f654 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,7 @@ indent_size = 2 # The file contains important whitespace at the end of the line in a multi-line string. # and editorconfig doesn't seem to respect multi-line strings. trim_trailing_whitespace = false + +[*.{kt,kts}] +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 0f471bcb84..a7239ccee7 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -16,14 +16,15 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType -import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.actions.Action.Outputs +import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts @@ -43,7 +44,7 @@ workflow( PullRequest() ), sourceFile = __FILE__.toPath(), - //# https://stackoverflow.com/a/72408109/16358266 + // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( group = "${expr { github.workflow }}-${expr("${Contexts.github.eventPullRequest.pull_request.number} || ${Contexts.github.ref}")}", cancelInProgress = true @@ -112,16 +113,8 @@ workflow( ) uses( name = "Set up JDKs", - action = CustomAction( - actionOwner = ".github", - actionName = "actions/setup-build-env", - actionVersion = "v0", - inputs = mapOf( - "additional-java-version" to expr("matrix.java") - ) - ), - _customArguments = mapOf( - "uses" to "./.github/actions/setup-build-env" + action = SetupBuildEnv( + additionalJavaVersion = expr("matrix.java") ) ) val SPOCK_BUILD_CACHE_USERNAME by Contexts.secrets @@ -130,11 +123,13 @@ workflow( uses( name = "Build Spock", action = GradleBuildActionV2( - arguments = """--no-parallel --stacktrace ghActionsBuild "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ - expr( - "matrix.java" - ) - }"""" + arguments = listOf( + "--no-parallel", + "--stacktrace", + "ghActionsBuild", + """"-Dvariant=${expr("matrix.variant")}"""", + """"-DjavaVersion=${expr("matrix.java")}"""" + ).joinToString(" ") ), // secrets are not injected for pull requests env = linkedMapOf( @@ -149,3 +144,12 @@ workflow( ) } }.writeToFile() + +data class SetupBuildEnv( + val additionalJavaVersion: String? = null +) : LocalAction("./.github/actions/setup-build-env") { + override fun toYamlArguments() = + additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() + + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) +} diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 6c45168510..5595b44509 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -16,13 +16,16 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 +import io.github.typesafegithub.workflows.actions.github.CodeqlActionInitV2 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.actions.Action +import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.Cron import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push @@ -50,7 +53,7 @@ workflow( ) ), sourceFile = __FILE__.toPath(), - //# https://stackoverflow.com/a/72408109/16358266 + // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}", cancelInProgress = true @@ -77,39 +80,23 @@ workflow( // Manually added: Install and setup JDK uses( name = "Set up JDKs", - action = CustomAction( - actionOwner = ".github", - actionName = "actions/setup-build-env", - actionVersion = "v0", - inputs = emptyMap() - ), - _customArguments = mapOf( - "uses" to "./.github/actions/setup-build-env" - ) + action = SetupBuildEnv() ) // Initializes the CodeQL tools for scanning uses( name = "Initialize CodeQL", - action = CustomAction( - actionOwner = "github", - actionName = "codeql-action/init", - actionVersion = "v3", - inputs = emptyMap() + action = CodeqlActionInitV2( + _customVersion = "v3" // Override language selection by uncommenting this and choosing your languages - //inputs = mapOf("languages" to "go, javascript, csharp, python, cpp, java") + // languages = listOf("go", "javascript", "csharp", "python", "cpp", "java"), ) ) // Autobuild attempts to build any compiled languages (C/C++, C#, or Java). // If this step fails, then you should remove it and run the build manually (see below). - //uses( - // name = "Autobuild", - // action = CustomAction( - // actionOwner = "github", - // actionName = "codeql-action/autobuild", - // actionVersion = "v1", - // inputs = emptyMap() - // ) - //) + // uses( + // name = "Autobuild", + // action = CodeqlActionAutobuildV2() + // ) // // ℹī¸ Command-line programs to run using the OS shell. // 📚 https://git.io/JvXDl @@ -118,12 +105,12 @@ workflow( // three lines and modify them (or add more) to build your code if your // project uses a compiled language // - //run( - // command = """ - // make bootstrap - // make release - // """.trimIndent() - //) + // run( + // command = """ + // make bootstrap + // make release + // """.trimIndent() + // ) // Manually added: build // we have to disable build cache for now as it seems to be necessary for the compiler to run during the build @@ -131,17 +118,26 @@ workflow( uses( name = "Build Spock Classes", action = GradleBuildActionV2( - arguments = """--stacktrace --no-build-cache testClasses "-Dvariant=${expr("matrix.variant")}"""" + arguments = listOf( + "--stacktrace", + "--no-build-cache", + "testClasses", + """"-Dvariant=${expr("matrix.variant")}"""" + ).joinToString(" ") ) ) uses( name = "Perform CodeQL Analysis", - action = CustomAction( - actionOwner = "github", - actionName = "codeql-action/analyze", - actionVersion = "v3", - inputs = emptyMap() - ) + action = CodeqlActionAnalyzeV2(_customVersion = "v3") ) } }.writeToFile() + +data class SetupBuildEnv( + val additionalJavaVersion: String? = null +) : LocalAction("./.github/actions/setup-build-env") { + override fun toYamlArguments() = + additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() + + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) +} diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 6e0e014e68..53a46f19a6 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index d69863b5b7..77f207ae84 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -16,14 +16,15 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.40.1") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.RunnerType -import io.github.typesafegithub.workflows.domain.actions.CustomAction +import io.github.typesafegithub.workflows.domain.actions.Action +import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github @@ -113,26 +114,21 @@ workflow( ) uses( name = "Set up JDKs", - action = CustomAction( - actionOwner = ".github", - actionName = "actions/setup-build-env", - actionVersion = "v0", - inputs = mapOf( - "additional-java-version" to expr("matrix.java") - ) - ), - _customArguments = mapOf( - "uses" to "./.github/actions/setup-build-env" + action = SetupBuildEnv( + additionalJavaVersion = expr("matrix.java") ) ) uses( name = "Build Spock", action = GradleBuildActionV2( - arguments = """--no-parallel --stacktrace ghActionsBuild "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ - expr( - "matrix.java" - ) - }" "-Dscan.tag.main-build"""" + arguments = listOf( + "--no-parallel", + "--stacktrace", + "ghActionsBuild", + """"-Dvariant=${expr("matrix.variant")}"""", + """"-DjavaVersion=${expr("matrix.java")}"""", + "-Dscan.tag.main-build" + ).joinToString(" ") ), env = linkedMapOf( "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), @@ -168,26 +164,21 @@ workflow( ) uses( name = "Set up JDKs", - action = CustomAction( - actionOwner = ".github", - actionName = "actions/setup-build-env", - actionVersion = "v0", - inputs = mapOf( - "additional-java-version" to expr("matrix.java") - ) - ), - _customArguments = mapOf( - "uses" to "./.github/actions/setup-build-env" + action = SetupBuildEnv( + additionalJavaVersion = expr("matrix.java") ) ) uses( name = "Publish Spock", action = GradleBuildActionV2( - arguments = """--no-parallel --stacktrace ghActionsPublish "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ - expr( - "matrix.java" - ) - }" "-Dscan.tag.main-publish"""" + arguments = listOf( + "--no-parallel", + "--stacktrace", + "ghActionsPublish", + """"-Dvariant=${expr("matrix.variant")}"""", + """"-DjavaVersion=${expr("matrix.java")}"""", + "-Dscan.tag.main-publish" + ).joinToString(" ") ), env = linkedMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN), @@ -219,16 +210,8 @@ workflow( ) uses( name = "Set up JDKs", - action = CustomAction( - actionOwner = ".github", - actionName = "actions/setup-build-env", - actionVersion = "v0", - inputs = mapOf( - "additional-java-version" to expr("matrix.java") - ) - ), - _customArguments = mapOf( - "uses" to "./.github/actions/setup-build-env" + action = SetupBuildEnv( + additionalJavaVersion = expr("matrix.java") ) ) run( @@ -238,11 +221,14 @@ workflow( uses( name = "Publish Docs", action = GradleBuildActionV2( - arguments = """--no-parallel --stacktrace ghActionsDocs "-Dvariant=${expr("matrix.variant")}" "-DjavaVersion=${ - expr( - "matrix.java" - ) - }" "-Dscan.tag.main-docs"""" + arguments = listOf( + "--no-parallel", + "--stacktrace", + "ghActionsDocs", + """"-Dvariant=${expr("matrix.variant")}"""", + """"-DjavaVersion=${expr("matrix.java")}"""", + "-Dscan.tag.main-docs" + ).joinToString(" ") ), env = linkedMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN), @@ -253,3 +239,12 @@ workflow( ) } }.writeToFile() + +data class SetupBuildEnv( + val additionalJavaVersion: String? = null +) : LocalAction("./.github/actions/setup-build-env") { + override fun toYamlArguments() = + additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() + + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) +} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8edf539c9f..345508fc76 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -80,7 +80,7 @@ jobs: name: Build Spock uses: gradle/gradle-build-action@v2 with: - arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-build" + arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build env: ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} @@ -120,7 +120,7 @@ jobs: name: Publish Spock uses: gradle/gradle-build-action@v2 with: - arguments: --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-publish" + arguments: --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONATYPE_OSS_USER: ${{ secrets.SONATYPE_OSS_USER }} @@ -159,7 +159,7 @@ jobs: name: Publish Docs uses: gradle/gradle-build-action@v2 with: - arguments: --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" "-Dscan.tag.main-docs" + arguments: --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} From b61b0eb03e630d1ea6df1f1a9621ddfb9612aef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 17 Apr 2023 04:59:53 +0200 Subject: [PATCH 03/30] Move preprocessWorkflow task creation to build-logic --- .../preprocess-workflows.gradle | 13 ++++ .../gradle/PreprocessWorkflowsPlugin.groovy | 68 +++++++++++++++++++ build-logic/settings.gradle | 1 + build.gradle | 44 +----------- 4 files changed, 83 insertions(+), 43 deletions(-) create mode 100644 build-logic/preprocess-workflows/preprocess-workflows.gradle create mode 100644 build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy diff --git a/build-logic/preprocess-workflows/preprocess-workflows.gradle b/build-logic/preprocess-workflows/preprocess-workflows.gradle new file mode 100644 index 0000000000..52e46d0ce4 --- /dev/null +++ b/build-logic/preprocess-workflows/preprocess-workflows.gradle @@ -0,0 +1,13 @@ +plugins { + id 'groovy-gradle-plugin' + id 'idea' +} + +gradlePlugin { + plugins { + preprocessWorkflowsPlugin { + id = 'org.spockframework.preprocess-workflows' + implementationClass = 'org.spockframework.gradle.PreprocessWorkflowsPlugin' + } + } +} diff --git a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy new file mode 100644 index 0000000000..0482a9d73c --- /dev/null +++ b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy @@ -0,0 +1,68 @@ +/* + * Copyright 2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.spockframework.gradle + +import groovy.transform.CompileStatic +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.ModuleDependency +import org.gradle.api.tasks.JavaExec +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.jvm.toolchain.JavaToolchainService + +@CompileStatic +class PreprocessWorkflowsPlugin implements Plugin { + void apply(Project project) { + def kotlinCompilerClasspath = project.configurations.detachedConfiguration( + project.dependencies.create('org.jetbrains.kotlin:kotlin-compiler:1.8.20'), + project.dependencies.create('org.jetbrains.kotlin:kotlin-scripting-compiler:1.8.20') + ) + def kotlinScriptClasspath = project.configurations.detachedConfiguration( + project.dependencies.create('org.jetbrains.kotlin:kotlin-main-kts:1.8.20') { ModuleDependency it -> + it.transitive = false + } + ) + + def preprocessWorkflows = project.tasks.register('preprocessWorkflows') + project.file('.github/workflows').eachFileMatch(~/.*\.main\.kts$/) { workflowScript -> + def workflowName = workflowScript.name - ~/\.main\.kts$/ + def pascalCasedWorkflowName = workflowName + .replaceAll(/-\w/) { String it -> it[1].toUpperCase() } + .replaceFirst(/^\w/) { String it -> it[0].toUpperCase() } + def preprocessWorkflow = project.tasks.register("preprocess${pascalCasedWorkflowName}Workflow", JavaExec) { + it.inputs + .file(workflowScript) + .withPropertyName('workflowScript') + it.outputs + .file(new File(workflowScript.parent, "${workflowName}.yaml")) + .withPropertyName('workflowFile') + + it.javaLauncher.set project.extensions.getByType(JavaToolchainService).launcherFor { + it.languageVersion.set(JavaLanguageVersion.of(17)) + } + it.classpath(kotlinCompilerClasspath) + it.mainClass.set 'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler' + it.args('-no-stdlib', '-no-reflect') + it.args('-classpath', kotlinScriptClasspath.asPath) + it.args('-script', workflowScript.absolutePath) + } + preprocessWorkflows.configure { + it.dependsOn(preprocessWorkflow) + } + } + } +} diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle index c3ff77d254..c3583866fd 100644 --- a/build-logic/settings.gradle +++ b/build-logic/settings.gradle @@ -19,6 +19,7 @@ dependencyResolutionManagement { } include("base") +include("preprocess-workflows") include("asciidoc-extensions") nameBuildScriptsAfterProjectNames(rootProject.children) diff --git a/build.gradle b/build.gradle index 9aca66a58a..e4d47ac36e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,7 @@ plugins { id "io.github.gradle-nexus.publish-plugin" id "com.github.ben-manes.versions" id "io.spring.nohttp" + id "org.spockframework.preprocess-workflows" } description = "Spock Framework" @@ -441,46 +442,3 @@ def configureGroovydoc(TaskProvider groovydoc) { include "spock/**" } } - -configurations { - kotlinCompilerClasspath { - canBeConsumed = false - } - kotlinScriptClasspath { - canBeConsumed = false - } -} - -dependencies { - kotlinCompilerClasspath 'org.jetbrains.kotlin:kotlin-compiler:1.8.20' - kotlinCompilerClasspath 'org.jetbrains.kotlin:kotlin-scripting-compiler:1.8.20' - kotlinScriptClasspath('org.jetbrains.kotlin:kotlin-main-kts:1.8.20') { transitive = false } -} - -def preprocessWorkflows = tasks.register('preprocessWorkflows') -file('.github/workflows').eachFileMatch(~/.*\.main\.kts$/) { workflowScript -> - def workflowName = workflowScript.name - ~/\.main\.kts$/ - def pascalCasedWorkflowName = workflowName - .replaceAll(/-\w/) { it[1].toUpperCase() } - .replaceFirst(/^\w/) { it[0].toUpperCase() } - def preprocessWorkflow = tasks.register("preprocess${pascalCasedWorkflowName}Workflow", JavaExec) { - inputs - .file(workflowScript) - .withPropertyName('workflowScript') - outputs - .file(new File(workflowScript.parent, "${workflowName}.yaml")) - .withPropertyName('workflowFile') - - javaLauncher = javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(17) - } - classpath(configurations.kotlinCompilerClasspath) - mainClass = 'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler' - args('-no-stdlib', '-no-reflect') - args('-classpath', configurations.kotlinScriptClasspath.asPath) - args('-script', workflowScript.absolutePath) - } - preprocessWorkflows.configure { - dependsOn(preprocessWorkflow) - } -} From bf8ef4e2251386695c4a642180d777f0ac9c1e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 17 Apr 2023 05:15:03 +0200 Subject: [PATCH 04/30] Verify consistency of all workflow YAMLs on pull requests and branches --- .github/workflows/branches-and-prs.main.kts | 20 ++++++++++++++++++++ .github/workflows/branches-and-prs.yaml | 15 +++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index a7239ccee7..bec7c5bc17 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -23,6 +23,7 @@ import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType +import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.actions.Action.Outputs import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.PullRequest @@ -50,6 +51,25 @@ workflow( cancelInProgress = true ) ) { + job( + id = "check_all_workflow_yaml_consistency", + name = "Check all Workflow YAML consistency", + runsOn = UbuntuLatest + ) { + uses( + name = "Checkout Repository", + action = CheckoutV3() + ) + run( + name = "Regenerate all workflow YAMLs", + command = """find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" -exec sh -c {} \;""" + ) + run( + name = "Check if some file is different after regeneration", + command = "git diff --exit-code ." + ) + } + job( id = "build-and-verify", name = "Build and Verify", diff --git a/.github/workflows/branches-and-prs.yaml b/.github/workflows/branches-and-prs.yaml index b00c2f26d7..08316a2cfe 100644 --- a/.github/workflows/branches-and-prs.yaml +++ b/.github/workflows/branches-and-prs.yaml @@ -26,6 +26,21 @@ jobs: - id: step-2 name: Consistency check run: git diff --exit-code '.github/workflows/branches-and-prs.yaml' + check_all_workflow_yaml_consistency: + name: Check all Workflow YAML consistency + runs-on: ubuntu-latest + needs: + - check_yaml_consistency + steps: + - id: step-0 + name: Checkout Repository + uses: actions/checkout@v3 + - id: step-1 + name: Regenerate all workflow YAMLs + run: find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" -exec sh -c {} \; + - id: step-2 + name: Check if some file is different after regeneration + run: git diff --exit-code . build-and-verify: name: Build and Verify runs-on: ${{ matrix.os }} From bf794094d988d5ed1c338f9b0112b6cc3a125b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 17 Apr 2023 10:10:31 +0200 Subject: [PATCH 05/30] yaml => yml --- .github/workflows/branches-and-prs.main.kts | 1 + .../workflows/{branches-and-prs.yaml => branches-and-prs.yml} | 4 ++-- .github/workflows/codeql-analysis.main.kts | 1 + .../workflows/{codeql-analysis.yaml => codeql-analysis.yml} | 4 ++-- .github/workflows/gradle-wrapper-validation.main.kts | 3 ++- ...-wrapper-validation.yaml => gradle-wrapper-validation.yml} | 4 ++-- .github/workflows/release.main.kts | 3 ++- .github/workflows/{release.yaml => release.yml} | 4 ++-- .../spockframework/gradle/PreprocessWorkflowsPlugin.groovy | 2 +- 9 files changed, 15 insertions(+), 11 deletions(-) rename .github/workflows/{branches-and-prs.yaml => branches-and-prs.yml} (96%) rename .github/workflows/{codeql-analysis.yaml => codeql-analysis.yml} (93%) rename .github/workflows/{gradle-wrapper-validation.yaml => gradle-wrapper-validation.yml} (87%) rename .github/workflows/{release.yaml => release.yml} (97%) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index bec7c5bc17..d4d4478baa 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -45,6 +45,7 @@ workflow( PullRequest() ), sourceFile = __FILE__.toPath(), + targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( group = "${expr { github.workflow }}-${expr("${Contexts.github.eventPullRequest.pull_request.number} || ${Contexts.github.ref}")}", diff --git a/.github/workflows/branches-and-prs.yaml b/.github/workflows/branches-and-prs.yml similarity index 96% rename from .github/workflows/branches-and-prs.yaml rename to .github/workflows/branches-and-prs.yml index 08316a2cfe..28a654d3e1 100644 --- a/.github/workflows/branches-and-prs.yaml +++ b/.github/workflows/branches-and-prs.yml @@ -22,10 +22,10 @@ jobs: uses: actions/checkout@v3 - id: step-1 name: Execute script - run: rm '.github/workflows/branches-and-prs.yaml' && '.github/workflows/branches-and-prs.main.kts' + run: rm '.github/workflows/branches-and-prs.yml' && '.github/workflows/branches-and-prs.main.kts' - id: step-2 name: Consistency check - run: git diff --exit-code '.github/workflows/branches-and-prs.yaml' + run: git diff --exit-code '.github/workflows/branches-and-prs.yml' check_all_workflow_yaml_consistency: name: Check all Workflow YAML consistency runs-on: ubuntu-latest diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 5595b44509..fb8f22b2e4 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -53,6 +53,7 @@ workflow( ) ), sourceFile = __FILE__.toPath(), + targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}", diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yml similarity index 93% rename from .github/workflows/codeql-analysis.yaml rename to .github/workflows/codeql-analysis.yml index 86a3832ffb..3ea5247041 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yml @@ -23,10 +23,10 @@ jobs: uses: actions/checkout@v3 - id: step-1 name: Execute script - run: rm '.github/workflows/codeql-analysis.yaml' && '.github/workflows/codeql-analysis.main.kts' + run: rm '.github/workflows/codeql-analysis.yml' && '.github/workflows/codeql-analysis.main.kts' - id: step-2 name: Consistency check - run: git diff --exit-code '.github/workflows/codeql-analysis.yaml' + run: git diff --exit-code '.github/workflows/codeql-analysis.yml' codeql-build: name: CodeQL-Build runs-on: ubuntu-latest diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 53a46f19a6..ab882e029f 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -32,7 +32,8 @@ workflow( Push(), PullRequest() ), - sourceFile = __FILE__.toPath() + sourceFile = __FILE__.toPath(), + targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" ) { job( id = "validation", diff --git a/.github/workflows/gradle-wrapper-validation.yaml b/.github/workflows/gradle-wrapper-validation.yml similarity index 87% rename from .github/workflows/gradle-wrapper-validation.yaml rename to .github/workflows/gradle-wrapper-validation.yml index 19bda3bd90..1b344e6aad 100644 --- a/.github/workflows/gradle-wrapper-validation.yaml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -16,10 +16,10 @@ jobs: uses: actions/checkout@v3 - id: step-1 name: Execute script - run: rm '.github/workflows/gradle-wrapper-validation.yaml' && '.github/workflows/gradle-wrapper-validation.main.kts' + run: rm '.github/workflows/gradle-wrapper-validation.yml' && '.github/workflows/gradle-wrapper-validation.main.kts' - id: step-2 name: Consistency check - run: git diff --exit-code '.github/workflows/gradle-wrapper-validation.yaml' + run: git diff --exit-code '.github/workflows/gradle-wrapper-validation.yml' validation: name: Validation runs-on: ubuntu-latest diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 77f207ae84..a1f3a520a2 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -40,7 +40,8 @@ workflow( tags = listOf("spock-*") ) ), - sourceFile = __FILE__.toPath() + sourceFile = __FILE__.toPath(), + targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" ) { val GITHUB_TOKEN by Contexts.secrets val SONATYPE_OSS_USER by Contexts.secrets diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yml similarity index 97% rename from .github/workflows/release.yaml rename to .github/workflows/release.yml index 345508fc76..a9835d3143 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yml @@ -19,10 +19,10 @@ jobs: uses: actions/checkout@v3 - id: step-1 name: Execute script - run: rm '.github/workflows/release.yaml' && '.github/workflows/release.main.kts' + run: rm '.github/workflows/release.yml' && '.github/workflows/release.main.kts' - id: step-2 name: Consistency check - run: git diff --exit-code '.github/workflows/release.yaml' + run: git diff --exit-code '.github/workflows/release.yml' build-and-verify: name: Build and Verify runs-on: ${{ matrix.os }} diff --git a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy index 0482a9d73c..a536f92f4a 100644 --- a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy +++ b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy @@ -48,7 +48,7 @@ class PreprocessWorkflowsPlugin implements Plugin { .file(workflowScript) .withPropertyName('workflowScript') it.outputs - .file(new File(workflowScript.parent, "${workflowName}.yaml")) + .file(new File(workflowScript.parent, "${workflowName}.yml")) .withPropertyName('workflowFile') it.javaLauncher.set project.extensions.getByType(JavaToolchainService).launcherFor { From d4f1d72f39a6e624fec12196c0798bb1454edfdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 19 Apr 2023 00:43:16 +0200 Subject: [PATCH 06/30] Use programmatic logic for variants and java versions --- .github/workflows/branches-and-prs.main.kts | 63 +++++++----------- .github/workflows/release.main.kts | 71 ++++++++------------- 2 files changed, 48 insertions(+), 86 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index d4d4478baa..68035da82d 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -71,6 +71,8 @@ workflow( ) } + val variants = listOf("2.5", "3.0", "4.0") + val javaVersions = listOf("8", "11", "17") job( id = "build-and-verify", name = "Build and Verify", @@ -80,47 +82,26 @@ workflow( "fail-fast" to false, "matrix" to mapOf( "os" to listOf("ubuntu-latest"), - "variant" to listOf("2.5", "3.0", "4.0"), - "java" to listOf("8", "11", "17"), - "exclude" to listOf( - mapOf( - "os" to "ubuntu-latest", - "variant" to "2.5", - "java" to "17" - ) - ), - "include" to listOf( - mapOf( - "os" to "windows-latest", - "variant" to "2.5", - "java" to "8" - ), - mapOf( - "os" to "windows-latest", - "variant" to "3.0", - "java" to "8" - ), - mapOf( - "os" to "windows-latest", - "variant" to "4.0", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "2.5", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "3.0", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "4.0", - "java" to "8" - ) - ) + "variant" to variants, + "java" to javaVersions, + "exclude" to javaVersions + .filter { it.toInt() >= 17 } + .map { javaVersion -> + mapOf( + "os" to "ubuntu-latest", + "variant" to "2.5", + "java" to javaVersion + ) + }, + "include" to listOf("windows-latest", "macos-latest") + .flatMap { os -> variants.map { os to it } } + .map { (os, variant) -> + mapOf( + "os" to os, + "variant" to variant, + "java" to javaVersions.first() + ) + } ) ) ) diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index a1f3a520a2..73dc4fbfd0 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -51,6 +51,8 @@ workflow( val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets + val variants = listOf("2.5", "3.0", "4.0") + val javaVersions = listOf("8", "11", "17") val buildAndVerify = job( id = "build-and-verify", name = "Build and Verify", @@ -61,47 +63,26 @@ workflow( "fail-fast" to false, "matrix" to mapOf( "os" to listOf("ubuntu-latest"), - "variant" to listOf("2.5", "3.0", "4.0"), - "java" to listOf("8", "11", "17"), - "exclude" to listOf( - mapOf( - "os" to "ubuntu-latest", - "variant" to "2.5", - "java" to "17" - ) - ), - "include" to listOf( - mapOf( - "os" to "windows-latest", - "variant" to "2.5", - "java" to "8" - ), - mapOf( - "os" to "windows-latest", - "variant" to "3.0", - "java" to "8" - ), - mapOf( - "os" to "windows-latest", - "variant" to "4.0", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "2.5", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "3.0", - "java" to "8" - ), - mapOf( - "os" to "macos-latest", - "variant" to "4.0", - "java" to "8" - ) - ) + "variant" to variants, + "java" to javaVersions, + "exclude" to javaVersions + .filter { it.toInt() >= 17 } + .map { javaVersion -> + mapOf( + "os" to "ubuntu-latest", + "variant" to "2.5", + "java" to javaVersion + ) + }, + "include" to listOf("windows-latest", "macos-latest") + .flatMap { os -> variants.map { os to it } } + .map { (os, variant) -> + mapOf( + "os" to os, + "variant" to variant, + "java" to javaVersions.first() + ) + } ) ) ) @@ -154,9 +135,9 @@ workflow( strategyMatrix = mapOf( "os" to listOf("ubuntu-latest"), // publish needs to be done for all versions - "variant" to listOf("2.5", "3.0", "4.0"), + "variant" to variants, // publish needs the min supported java version - "java" to listOf("8") + "java" to javaVersions.take(1) ) ) { uses( @@ -200,9 +181,9 @@ workflow( strategyMatrix = mapOf( "os" to listOf("ubuntu-latest"), // docs need the highest variant - "variant" to listOf("4.0"), + "variant" to variants.takeLast(1), // docs need the highest java version - "java" to listOf("17") + "java" to javaVersions.takeLast(1) ) ) { uses( From 690d1a55182375e8f53b1975444184f177ff147f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 19 Apr 2023 14:14:25 +0200 Subject: [PATCH 07/30] Use one central location to define the java versions and variants --- .github/workflows/branches-and-prs.main.kts | 22 +++++++++++++++++++-- .github/workflows/release.main.kts | 22 +++++++++++++++++++-- build.gradle | 7 +++++-- matrix.groovy | 2 ++ 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 matrix.groovy diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 68035da82d..407642aee0 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -17,7 +17,10 @@ */ @file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +import groovy.lang.Binding +import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 @@ -71,8 +74,7 @@ workflow( ) } - val variants = listOf("2.5", "3.0", "4.0") - val javaVersions = listOf("8", "11", "17") + val (javaVersions, variants) = getMatrixAxes() job( id = "build-and-verify", name = "Build and Verify", @@ -155,3 +157,19 @@ data class SetupBuildEnv( override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) } + +fun getMatrixAxes(): Pair, List> { + val binding = object : Binding() { + lateinit var javaVersions: List + lateinit var variants: List + + override fun setVariable(name: String?, value: Any?) { + when (name) { + "javaVersions" -> javaVersions = (value as List).map { it.toString() } + "variants" -> variants = value as List + } + } + } + GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) + return binding.javaVersions to binding.variants +} diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 73dc4fbfd0..f0a7f3d410 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -17,7 +17,10 @@ */ @file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +import groovy.lang.Binding +import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 @@ -51,8 +54,7 @@ workflow( val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets - val variants = listOf("2.5", "3.0", "4.0") - val javaVersions = listOf("8", "11", "17") + val (javaVersions, variants) = getMatrixAxes() val buildAndVerify = job( id = "build-and-verify", name = "Build and Verify", @@ -230,3 +232,19 @@ data class SetupBuildEnv( override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) } + +fun getMatrixAxes(): Pair, List> { + val binding = object : Binding() { + lateinit var javaVersions: List + lateinit var variants: List + + override fun setVariable(name: String?, value: Any?) { + when (name) { + "javaVersions" -> javaVersions = (value as List).map { it.toString() } + "variants" -> variants = value as List + } + } + } + GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) + return binding.javaVersions to binding.variants +} diff --git a/build.gradle b/build.gradle index e4d47ac36e..582b61b37d 100644 --- a/build.gradle +++ b/build.gradle @@ -15,13 +15,16 @@ plugins { description = "Spock Framework" +ext.javaVersions = null +ext.variants = null +apply from: 'matrix.groovy' +variants = variants.collect { it as BigDecimal } + ext { baseVersion = "2.4" snapshotVersion = true milestone = 0 - javaVersions = [8, 11, 17, 21] // ensure that latest version is actually build on GH actions and added to gradle.properties, otherwise no docs get published javaVersion = (System.getProperty("javaVersion") ?: 8) as int - variants = [2.5, 3.0, 4.0] variant = System.getProperty("variant") as BigDecimal ?: variants.first() develocity.buildScan.tag "groovy-$variant" if (variant == 2.5) { diff --git a/matrix.groovy b/matrix.groovy new file mode 100644 index 0000000000..202bd3dda7 --- /dev/null +++ b/matrix.groovy @@ -0,0 +1,2 @@ +javaVersions = [8, 11, 17] // ensure that latest version is actually built on GitHub Actions, otherwise no docs get published +variants = ['2.5', '3.0', '4.0'] From 0247fe23fc094f32ac140571a2216605179ca367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 19 Apr 2023 15:34:12 +0200 Subject: [PATCH 08/30] Improve all script consistency check --- .github/workflows/branches-and-prs.main.kts | 8 ++------ .github/workflows/branches-and-prs.yml | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 407642aee0..873a86ab1a 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -65,12 +65,8 @@ workflow( action = CheckoutV3() ) run( - name = "Regenerate all workflow YAMLs", - command = """find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" -exec sh -c {} \;""" - ) - run( - name = "Check if some file is different after regeneration", - command = "git diff --exit-code ." + name = "Regenerate all workflow YAMLs and check for modifications", + command = """find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c '{} && git diff --exit-code'""" ) } diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 28a654d3e1..6a18d6e9d2 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -36,11 +36,8 @@ jobs: name: Checkout Repository uses: actions/checkout@v3 - id: step-1 - name: Regenerate all workflow YAMLs - run: find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" -exec sh -c {} \; - - id: step-2 - name: Check if some file is different after regeneration - run: git diff --exit-code . + name: Regenerate all workflow YAMLs and check for modifications + run: find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c '{} && git diff --exit-code' build-and-verify: name: Build and Verify runs-on: ${{ matrix.os }} From 955f8cb65fd22948e143cb37de694f2ea896cc08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Fri, 28 Apr 2023 15:03:12 +0200 Subject: [PATCH 09/30] Update github-workflows-kt to v0.44.0 --- .github/workflows/branches-and-prs.main.kts | 2 +- .github/workflows/branches-and-prs.yml | 146 +++++------ .github/workflows/codeql-analysis.main.kts | 2 +- .github/workflows/codeql-analysis.yml | 72 +++--- .../gradle-wrapper-validation.main.kts | 2 +- .../workflows/gradle-wrapper-validation.yml | 42 ++-- .github/workflows/release.main.kts | 2 +- .github/workflows/release.yml | 238 +++++++++--------- 8 files changed, 253 insertions(+), 253 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 873a86ab1a..fd0d0e0136 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") @file:DependsOn("org.codehaus.groovy:groovy:3.0.15") import groovy.lang.Binding diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 6a18d6e9d2..e852b3108e 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -2,103 +2,103 @@ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. # Generated with https://github.com/typesafegithub/github-workflows-kt -name: Verify Branches and PRs +name: 'Verify Branches and PRs' on: push: branches-ignore: - - master - - gh-pages + - 'master' + - 'gh-pages' pull_request: {} concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' cancel-in-progress: true jobs: check_yaml_consistency: - name: Check YAML consistency - runs-on: ubuntu-latest + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' steps: - - id: step-0 - name: Check out - uses: actions/checkout@v3 - - id: step-1 - name: Execute script - run: rm '.github/workflows/branches-and-prs.yml' && '.github/workflows/branches-and-prs.main.kts' - - id: step-2 - name: Consistency check - run: git diff --exit-code '.github/workflows/branches-and-prs.yml' + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/branches-and-prs.yml'' && ''.github/workflows/branches-and-prs.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/branches-and-prs.yml''' check_all_workflow_yaml_consistency: - name: Check all Workflow YAML consistency - runs-on: ubuntu-latest + name: 'Check all Workflow YAML consistency' + runs-on: 'ubuntu-latest' needs: - - check_yaml_consistency + - 'check_yaml_consistency' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 - - id: step-1 - name: Regenerate all workflow YAMLs and check for modifications - run: find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c '{} && git diff --exit-code' + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Regenerate all workflow YAMLs and check for modifications' + run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c ''{} && git diff --exit-code''' build-and-verify: - name: Build and Verify - runs-on: ${{ matrix.os }} + name: 'Build and Verify' + runs-on: '${{ matrix.os }}' needs: - - check_yaml_consistency + - 'check_yaml_consistency' strategy: fail-fast: false matrix: os: - - ubuntu-latest + - 'ubuntu-latest' variant: - - 2.5 - - 3.0 - - 4.0 + - '2.5' + - '3.0' + - '4.0' java: - - 8 - - 11 - - 17 + - '8' + - '11' + - '17' exclude: - - os: ubuntu-latest - variant: 2.5 - java: 17 + - os: 'ubuntu-latest' + variant: '2.5' + java: '17' include: - - os: windows-latest - variant: 2.5 - java: 8 - - os: windows-latest - variant: 3.0 - java: 8 - - os: windows-latest - variant: 4.0 - java: 8 - - os: macos-latest - variant: 2.5 - java: 8 - - os: macos-latest - variant: 3.0 - java: 8 - - os: macos-latest - variant: 4.0 - java: 8 + - os: 'windows-latest' + variant: '2.5' + java: '8' + - os: 'windows-latest' + variant: '3.0' + java: '8' + - os: 'windows-latest' + variant: '4.0' + java: '8' + - os: 'macos-latest' + variant: '2.5' + java: '8' + - os: 'macos-latest' + variant: '3.0' + java: '8' + - os: 'macos-latest' + variant: '4.0' + java: '8' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' with: - fetch-depth: 2 - - id: step-1 - name: Set up JDKs - uses: ./.github/actions/setup-build-env + fetch-depth: '2' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' with: - additional-java-version: ${{ matrix.java }} - - id: step-2 - name: Build Spock - uses: gradle/gradle-build-action@v2 + additional-java-version: '${{ matrix.java }}' + - id: 'step-2' + name: 'Build Spock' + uses: 'gradle/gradle-build-action@v2' with: - arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" + arguments: '--no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' env: - ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} - ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - id: step-3 - name: Upload to Codecov.io - uses: codecov/codecov-action@v3 + ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' + ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' + GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + - id: 'step-3' + name: 'Upload to Codecov.io' + uses: 'codecov/codecov-action@v3' diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index fb8f22b2e4..9484c55c0c 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3ea5247041..9e140048b9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,58 +2,58 @@ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. # Generated with https://github.com/typesafegithub/github-workflows-kt -name: Code scanning - action +name: 'Code scanning - action' on: push: branches: - '!dependabot/**' pull_request: {} schedule: - - cron: 0 15 * * TUE + - cron: '0 15 * * TUE' concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' cancel-in-progress: true jobs: check_yaml_consistency: - name: Check YAML consistency - runs-on: ubuntu-latest + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' steps: - - id: step-0 - name: Check out - uses: actions/checkout@v3 - - id: step-1 - name: Execute script - run: rm '.github/workflows/codeql-analysis.yml' && '.github/workflows/codeql-analysis.main.kts' - - id: step-2 - name: Consistency check - run: git diff --exit-code '.github/workflows/codeql-analysis.yml' + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/codeql-analysis.yml'' && ''.github/workflows/codeql-analysis.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/codeql-analysis.yml''' codeql-build: - name: CodeQL-Build - runs-on: ubuntu-latest + name: 'CodeQL-Build' + runs-on: 'ubuntu-latest' needs: - - check_yaml_consistency + - 'check_yaml_consistency' strategy: fail-fast: false matrix: variant: - - 2.5 - - 3.0 - - 4.0 + - '2.5' + - '3.0' + - '4.0' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 - - id: step-1 - name: Set up JDKs - uses: ./.github/actions/setup-build-env - - id: step-2 - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - - id: step-3 - name: Build Spock Classes - uses: gradle/gradle-build-action@v2 + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' + - id: 'step-2' + name: 'Initialize CodeQL' + uses: 'github/codeql-action/init@v3' + - id: 'step-3' + name: 'Build Spock Classes' + uses: 'gradle/gradle-build-action@v2' with: - arguments: --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}" - - id: step-4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + arguments: '--stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}"' + - id: 'step-4' + name: 'Perform CodeQL Analysis' + uses: 'github/codeql-action/analyze@v3' diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index ab882e029f..c1de36a6b3 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 1b344e6aad..01ced15136 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -2,33 +2,33 @@ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. # Generated with https://github.com/typesafegithub/github-workflows-kt -name: Validate Gradle Wrapper +name: 'Validate Gradle Wrapper' on: push: {} pull_request: {} jobs: check_yaml_consistency: - name: Check YAML consistency - runs-on: ubuntu-latest + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' steps: - - id: step-0 - name: Check out - uses: actions/checkout@v3 - - id: step-1 - name: Execute script - run: rm '.github/workflows/gradle-wrapper-validation.yml' && '.github/workflows/gradle-wrapper-validation.main.kts' - - id: step-2 - name: Consistency check - run: git diff --exit-code '.github/workflows/gradle-wrapper-validation.yml' + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/gradle-wrapper-validation.yml'' && ''.github/workflows/gradle-wrapper-validation.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/gradle-wrapper-validation.yml''' validation: - name: Validation - runs-on: ubuntu-latest + name: 'Validation' + runs-on: 'ubuntu-latest' needs: - - check_yaml_consistency + - 'check_yaml_consistency' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 - - id: step-1 - name: Validate Wrapper - uses: gradle/wrapper-validation-action@v1 + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Validate Wrapper' + uses: 'gradle/wrapper-validation-action@v1' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index f0a7f3d410..f7ee4df86d 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") @file:DependsOn("org.codehaus.groovy:groovy:3.0.15") import groovy.lang.Binding diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9835d3143..26bb7b049b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,166 +2,166 @@ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. # Generated with https://github.com/typesafegithub/github-workflows-kt -name: Build and Release Spock +name: 'Build and Release Spock' on: push: branches: - - master + - 'master' tags: - - spock-* + - 'spock-*' jobs: check_yaml_consistency: - name: Check YAML consistency - runs-on: ubuntu-latest + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' steps: - - id: step-0 - name: Check out - uses: actions/checkout@v3 - - id: step-1 - name: Execute script - run: rm '.github/workflows/release.yml' && '.github/workflows/release.main.kts' - - id: step-2 - name: Consistency check - run: git diff --exit-code '.github/workflows/release.yml' + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/release.yml'' && ''.github/workflows/release.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/release.yml''' build-and-verify: - name: Build and Verify - runs-on: ${{ matrix.os }} + name: 'Build and Verify' + runs-on: '${{ matrix.os }}' needs: - - check_yaml_consistency - if: github.repository == 'spockframework/spock' + - 'check_yaml_consistency' + if: 'github.repository == ''spockframework/spock''' strategy: fail-fast: false matrix: os: - - ubuntu-latest + - 'ubuntu-latest' variant: - - 2.5 - - 3.0 - - 4.0 + - '2.5' + - '3.0' + - '4.0' java: - - 8 - - 11 - - 17 + - '8' + - '11' + - '17' exclude: - - os: ubuntu-latest - variant: 2.5 - java: 17 + - os: 'ubuntu-latest' + variant: '2.5' + java: '17' include: - - os: windows-latest - variant: 2.5 - java: 8 - - os: windows-latest - variant: 3.0 - java: 8 - - os: windows-latest - variant: 4.0 - java: 8 - - os: macos-latest - variant: 2.5 - java: 8 - - os: macos-latest - variant: 3.0 - java: 8 - - os: macos-latest - variant: 4.0 - java: 8 + - os: 'windows-latest' + variant: '2.5' + java: '8' + - os: 'windows-latest' + variant: '3.0' + java: '8' + - os: 'windows-latest' + variant: '4.0' + java: '8' + - os: 'macos-latest' + variant: '2.5' + java: '8' + - os: 'macos-latest' + variant: '3.0' + java: '8' + - os: 'macos-latest' + variant: '4.0' + java: '8' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' with: - fetch-depth: 2 - - id: step-1 - name: Set up JDKs - uses: ./.github/actions/setup-build-env + fetch-depth: '2' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' with: - additional-java-version: ${{ matrix.java }} - - id: step-2 - name: Build Spock - uses: gradle/gradle-build-action@v2 + additional-java-version: '${{ matrix.java }}' + - id: 'step-2' + name: 'Build Spock' + uses: 'gradle/gradle-build-action@v2' with: - arguments: --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build + arguments: '--no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build' env: - ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} - ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - id: step-3 - name: Stop Daemon - run: ./gradlew --stop - - id: step-4 - name: Upload to Codecov.io - uses: codecov/codecov-action@v3 + ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' + ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' + GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + - id: 'step-3' + name: 'Stop Daemon' + run: './gradlew --stop' + - id: 'step-4' + name: 'Upload to Codecov.io' + uses: 'codecov/codecov-action@v3' release-spock: - name: Release Spock - runs-on: ${{ matrix.os }} + name: 'Release Spock' + runs-on: '${{ matrix.os }}' needs: - - build-and-verify - - check_yaml_consistency + - 'build-and-verify' + - 'check_yaml_consistency' strategy: matrix: os: - - ubuntu-latest + - 'ubuntu-latest' variant: - - 2.5 - - 3.0 - - 4.0 + - '2.5' + - '3.0' + - '4.0' java: - - 8 + - '8' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 - - id: step-1 - name: Set up JDKs - uses: ./.github/actions/setup-build-env + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' with: - additional-java-version: ${{ matrix.java }} - - id: step-2 - name: Publish Spock - uses: gradle/gradle-build-action@v2 + additional-java-version: '${{ matrix.java }}' + - id: 'step-2' + name: 'Publish Spock' + uses: 'gradle/gradle-build-action@v2' with: - arguments: --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish + arguments: '--no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_OSS_USER: ${{ secrets.SONATYPE_OSS_USER }} - SONATYPE_OSS_PASSWORD: ${{ secrets.SONATYPE_OSS_PASSWORD }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_GPG_PASSWORD }} - ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} - ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + SONATYPE_OSS_USER: '${{ secrets.SONATYPE_OSS_USER }}' + SONATYPE_OSS_PASSWORD: '${{ secrets.SONATYPE_OSS_PASSWORD }}' + SIGNING_PASSWORD: '${{ secrets.SIGNING_GPG_PASSWORD }}' + ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' + ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' + GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' publish-release-docs: - name: Publish Release Docs - runs-on: ${{ matrix.os }} + name: 'Publish Release Docs' + runs-on: '${{ matrix.os }}' needs: - - release-spock - - check_yaml_consistency + - 'release-spock' + - 'check_yaml_consistency' strategy: matrix: os: - - ubuntu-latest + - 'ubuntu-latest' variant: - - 4.0 + - '4.0' java: - - 17 + - '17' steps: - - id: step-0 - name: Checkout Repository - uses: actions/checkout@v3 - - id: step-1 - name: Set up JDKs - uses: ./.github/actions/setup-build-env + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v3' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' with: - additional-java-version: ${{ matrix.java }} - - id: step-2 - name: Create Temporary Branch - run: git checkout -b "docs-$GITHUB_SHA" - - id: step-3 - name: Publish Docs - uses: gradle/gradle-build-action@v2 + additional-java-version: '${{ matrix.java }}' + - id: 'step-2' + name: 'Create Temporary Branch' + run: 'git checkout -b "docs-$GITHUB_SHA"' + - id: 'step-3' + name: 'Publish Docs' + uses: 'gradle/gradle-build-action@v2' with: - arguments: --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs + arguments: '--no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORG_GRADLE_PROJECT_spockBuildCacheUsername: ${{ secrets.SPOCK_BUILD_CACHE_USERNAME }} - ORG_GRADLE_PROJECT_spockBuildCachePassword: ${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' + ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' + GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' From 8606f7b805d6c4f9e7079300bc4f1c0963b78cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 1 Jun 2023 18:08:48 +0200 Subject: [PATCH 10/30] Review feedback --- .github/workflows/README.adoc | 91 ++++++++++ .github/workflows/branches-and-prs.main.kts | 83 ++------- .github/workflows/codeql-analysis.main.kts | 24 +-- .github/workflows/common.main.kts | 159 ++++++++++++++++++ .../gradle-wrapper-validation.main.kts | 2 +- .github/workflows/release.main.kts | 127 ++++---------- .../preprocess-workflows.gradle | 4 + .../gradle/PreprocessWorkflowsPlugin.groovy | 57 +++++++ build.gradle | 7 +- gradle.properties | 3 + matrix.groovy | 2 - 11 files changed, 361 insertions(+), 198 deletions(-) create mode 100644 .github/workflows/README.adoc create mode 100755 .github/workflows/common.main.kts delete mode 100644 matrix.groovy diff --git a/.github/workflows/README.adoc b/.github/workflows/README.adoc new file mode 100644 index 0000000000..e3ad8dffc6 --- /dev/null +++ b/.github/workflows/README.adoc @@ -0,0 +1,91 @@ +== The YAML workflow files vs. the `*.main.kts` files + +The YAML workflow files are generated from the `*.main.kts` files. + +These use the https://github.com/typesafegithub/github-workflows-kt[github-workflows-kt] +Kotlin DSL library to conveniently and type-safely write GitHub Action workflow files. + +As there is no official built-in support in GitHub Actions yet until +https://github.com/orgs/community/discussions/15904 is considered, the YAML files +need to be generated manually. + +There is a safeguard check in all the generated files that this is not forgotten. +Running a workflow where the according `*.main.kts` produces a different output will +fail the execution. Additionally, the workflow that runs for pull requests checks +the consistency of all the YAML files as not all are run for pull requests. + + + +== Ways to generate the YAML workflow files + +There are multiple ways to generate the YAML files and all of them are fine: + +* If you are in a `sh` derivate like e.g. `bash` and Kotlin is installed and + available in the `PATH`, you can just call the `*.main.kts` script like any + other shell script: ++ +[source,bash] +---- +$ ./release.main.kts +---- + +* If Kotlin is installed somewhere you can call it with the `*.main.kts` script + as argument: ++ +[source,bash] +---- +$ path/to/kotlin release.main.kts +---- + +* From the IDE you can create a run configuration that executes the `*.main.kts` script. + +* There is a Gradle task `preprocessWorkflows` that generates all YAML files from the + according `*.main.kts` files. Additionally, there is also one task per workflow to + only generate that one: ++ +[source,bash] +---- +$ ./gradlew preprocessReleaseWorkflow +$ ./gradlew preprocessWorkflows +---- + + + +== Caveats + +There are currently three known caveats with the approach we follow. + +* https://youtrack.jetbrains.com/issue/KTIJ-16532 ++ +If you navigate to a file in the dependencies, only a decompiled file is opened, +even though the source JAR would be available. Also the quick documentation is missing. ++ +This can easily by mitigated by attaching the library to the normal project +dependencies while having the need to navigate the source files or while editing them, +which makes them properly viewable and documentation displayable in the editor. + +* https://youtrack.jetbrains.com/issue/KTIJ-14580 ++ +We use `@file:Import` to reduce code duplication by having common code in a common file. +Unfortunately, this triggers a Kotlin IntelliJ plugin bug where the imported file cannot +be loaded properly and so the things supplied by it like dependencies or common functions +are not available. This makes most of the workflow `*.main.kts` files red as hell in the +IDE currently. ++ +To reduce risk for eye-cancer while reading the `*.main.kts` scripts or to be able to +sanely edit them, temporarily add the `@file:DependsOn` from the imported file to the +importing file and wait a second, then remove the line again once you are done. + +* https://youtrack.jetbrains.com/issue/KT-42101 ++ +We use `@file:Import` to reduce code duplication by having common code in a common file. +Unfortunately, this triggers a Kotlin bug where the compilation cache becomes confused +if the imported file is changed without the importing file being changed too. ++ +If only the imported file is changed, it could happen that a old version is used, +or it could also happen that classes added by a `@file:DependsOn` in the imported file +are not available to the importing file. So if there was a change in the imported file, +you either need to also change the importing file, or to properly execute the script, +you need to delete the stale entry from the compilation cache which can be found at for example +`~/.cache/main.kts.compiled.cache/` on Linux and `%LOCALAPPDATA%\main.kts.compiled.cache\` +on Windows. Alternatively, you can also delete the whole cache directory. diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index fd0d0e0136..36e58fb99d 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -16,22 +16,17 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") -@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +@file:Import("common.main.kts") -import groovy.lang.Binding -import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.actions.Action.Outputs -import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push -import io.github.typesafegithub.workflows.dsl.expressions.Contexts +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow import io.github.typesafegithub.workflows.yaml.writeToFile @@ -51,7 +46,7 @@ workflow( targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( - group = "${expr { github.workflow }}-${expr("${Contexts.github.eventPullRequest.pull_request.number} || ${Contexts.github.ref}")}", + group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}", cancelInProgress = true ) ) { @@ -70,38 +65,12 @@ workflow( ) } - val (javaVersions, variants) = getMatrixAxes() job( id = "build-and-verify", name = "Build and Verify", - runsOn = RunnerType.Custom(expr("matrix.os")), - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "os" to listOf("ubuntu-latest"), - "variant" to variants, - "java" to javaVersions, - "exclude" to javaVersions - .filter { it.toInt() >= 17 } - .map { javaVersion -> - mapOf( - "os" to "ubuntu-latest", - "variant" to "2.5", - "java" to javaVersion - ) - }, - "include" to listOf("windows-latest", "macos-latest") - .flatMap { os -> variants.map { os to it } } - .map { (os, variant) -> - mapOf( - "os" to os, - "variant" to variant, - "java" to javaVersions.first() - ) - } - ) - ) + runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), + strategy = Strategy( + matrix = Matrix.full ) ) { uses( @@ -114,12 +83,9 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr("matrix.java") + additionalJavaVersion = expr(Matrix.java) ) ) - val SPOCK_BUILD_CACHE_USERNAME by Contexts.secrets - val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets - val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets uses( name = "Build Spock", action = GradleBuildActionV2( @@ -127,16 +93,12 @@ workflow( "--no-parallel", "--stacktrace", "ghActionsBuild", - """"-Dvariant=${expr("matrix.variant")}"""", - """"-DjavaVersion=${expr("matrix.java")}"""" + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.java)}"""" ).joinToString(" ") ), // secrets are not injected for pull requests - env = linkedMapOf( - "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), - "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), - "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) - ) + env = commonCredentials ) uses( name = "Upload to Codecov.io", @@ -144,28 +106,3 @@ workflow( ) } }.writeToFile() - -data class SetupBuildEnv( - val additionalJavaVersion: String? = null -) : LocalAction("./.github/actions/setup-build-env") { - override fun toYamlArguments() = - additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() - - override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) -} - -fun getMatrixAxes(): Pair, List> { - val binding = object : Binding() { - lateinit var javaVersions: List - lateinit var variants: List - - override fun setVariable(name: String?, value: Any?) { - when (name) { - "javaVersions" -> javaVersions = (value as List).map { it.toString() } - "variants" -> variants = value as List - } - } - } - GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) - return binding.javaVersions to binding.variants -} diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 9484c55c0c..556b912fe1 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") +@file:Import("common.main.kts") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 @@ -24,8 +24,6 @@ import io.github.typesafegithub.workflows.actions.github.CodeqlActionInitV2 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.actions.Action -import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.Cron import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push @@ -65,12 +63,9 @@ workflow( name = "CodeQL-Build", // CodeQL runs on UbuntuLatest, WindowsLatest, and MacOSLatest runsOn = UbuntuLatest, - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "variant" to listOf("2.5", "3.0", "4.0") - ) + strategy = Strategy( + matrix = Matrix( + variants = Matrix.axes.variants ) ) ) { @@ -123,7 +118,7 @@ workflow( "--stacktrace", "--no-build-cache", "testClasses", - """"-Dvariant=${expr("matrix.variant")}"""" + """"-Dvariant=${expr(Matrix.variant)}"""" ).joinToString(" ") ) ) @@ -133,12 +128,3 @@ workflow( ) } }.writeToFile() - -data class SetupBuildEnv( - val additionalJavaVersion: String? = null -) : LocalAction("./.github/actions/setup-build-env") { - override fun toYamlArguments() = - additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() - - override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) -} diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts new file mode 100755 index 0000000000..eefc0020ea --- /dev/null +++ b/.github/workflows/common.main.kts @@ -0,0 +1,159 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") + +import io.github.typesafegithub.workflows.domain.Job +import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY +import io.github.typesafegithub.workflows.domain.RunnerType +import io.github.typesafegithub.workflows.domain.actions.Action.Outputs +import io.github.typesafegithub.workflows.domain.actions.LocalAction +import io.github.typesafegithub.workflows.dsl.JobBuilder +import io.github.typesafegithub.workflows.dsl.WorkflowBuilder +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets +import io.github.typesafegithub.workflows.dsl.expressions.expr +import java.util.Properties + +val SPOCK_BUILD_CACHE_USERNAME by secrets +val SPOCK_BUILD_CACHE_PASSWORD by secrets +val GRADLE_ENTERPRISE_ACCESS_KEY by secrets + +val commonCredentials = linkedMapOf( + "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), + "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), + "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) +) + +data class Strategy( + val failFast: Boolean? = false, + val matrix: Matrix? = null +) { + fun toCustomArguments() = mapOf( + *listOfNotNull( + failFast?.let { "fail-fast" to failFast }, + matrix?.let { "matrix" to matrix.toCustomArguments() } + ).toTypedArray() + ) +} + +data class Matrix( + val operatingSystems: List? = null, + val variants: List? = null, + val javaVersions: List? = null, + val excludes: List>? = null, + val includes: List>? = null +) { + fun toCustomArguments() = mapOf( + *listOfNotNull( + operatingSystems?.let { "os" to operatingSystems }, + variants?.let { "variant" to variants }, + javaVersions?.let { "java" to javaVersions }, + excludes?.let { "exclude" to excludes }, + includes?.let { "include" to includes } + ).toTypedArray() + ) + + data class Axes( + val javaVersions: List, + val variants: List + ) + + companion object { + val operatingSystem = "matrix.os" + val variant = "matrix.variant" + val java = "matrix.java" + } +} + +fun WorkflowBuilder.job( + id: String, + name: String? = null, + runsOn: RunnerType, + needs: List> = emptyList(), + condition: String? = null, + strategy: Strategy? = null, + simpleStrategy: Map>? = null, + block: JobBuilder.() -> Unit +): Job = job( + id = id, + name = name, + runsOn = runsOn, + needs = needs, + condition = condition, + strategyMatrix = simpleStrategy, + _customArguments = mapOf( + *listOfNotNull( + strategy?.let { "strategy" to strategy.toCustomArguments() } + ).toTypedArray() + ), + block = block +) + +val Matrix.Companion.full + get() = Matrix( + operatingSystems = listOf("ubuntu-latest"), + variants = axes.variants, + javaVersions = axes.javaVersions, + excludes = axes.javaVersions + .filter { it.toInt() >= 17 } + .map { javaVersion -> + mapOf( + "os" to "ubuntu-latest", + "variant" to "2.5", + "java" to javaVersion + ) + }, + includes = listOf("windows-latest", "macos-latest") + .flatMap { os -> axes.variants.map { os to it } } + .map { (os, variant) -> + mapOf( + "os" to os, + "variant" to variant, + "java" to axes.javaVersions.first() + ) + } + ) + +val Matrix.Companion.axes by lazy { + Properties().let { properties -> + __FILE__ + .parentFile + .resolve("../../gradle.properties") + .inputStream() + .use { properties.load(it) } + + Matrix.Axes( + properties.getList("javaVersions"), + properties.getList("variants") + ) + } +} + +fun Properties.getList(key: String) = + getProperty(key).trim().split("""\s*+,\s*+""".toRegex()) + +data class SetupBuildEnv( + val additionalJavaVersion: String? = null +) : LocalAction("./.github/actions/setup-build-env") { + override fun toYamlArguments() = + additionalJavaVersion + ?.let { linkedMapOf("additional-java-version" to it) } + ?: linkedMapOf() + + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) +} diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index c1de36a6b3..066f367e3a 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") +@file:Import("common.main.kts") import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index f7ee4df86d..00cc2b74bd 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -16,21 +16,16 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") -@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +@file:Import("common.main.kts") -import groovy.lang.Binding -import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.RunnerType -import io.github.typesafegithub.workflows.domain.actions.Action -import io.github.typesafegithub.workflows.domain.actions.LocalAction import io.github.typesafegithub.workflows.domain.triggers.Push -import io.github.typesafegithub.workflows.dsl.expressions.Contexts import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow import io.github.typesafegithub.workflows.yaml.writeToFile @@ -46,47 +41,18 @@ workflow( sourceFile = __FILE__.toPath(), targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" ) { - val GITHUB_TOKEN by Contexts.secrets - val SONATYPE_OSS_USER by Contexts.secrets - val SONATYPE_OSS_PASSWORD by Contexts.secrets - val SIGNING_GPG_PASSWORD by Contexts.secrets - val SPOCK_BUILD_CACHE_USERNAME by Contexts.secrets - val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets - val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets + val GITHUB_TOKEN by secrets + val SONATYPE_OSS_USER by secrets + val SONATYPE_OSS_PASSWORD by secrets + val SIGNING_GPG_PASSWORD by secrets - val (javaVersions, variants) = getMatrixAxes() val buildAndVerify = job( id = "build-and-verify", name = "Build and Verify", - runsOn = RunnerType.Custom(expr("matrix.os")), + runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), condition = "${github.repository} == 'spockframework/spock'", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "os" to listOf("ubuntu-latest"), - "variant" to variants, - "java" to javaVersions, - "exclude" to javaVersions - .filter { it.toInt() >= 17 } - .map { javaVersion -> - mapOf( - "os" to "ubuntu-latest", - "variant" to "2.5", - "java" to javaVersion - ) - }, - "include" to listOf("windows-latest", "macos-latest") - .flatMap { os -> variants.map { os to it } } - .map { (os, variant) -> - mapOf( - "os" to os, - "variant" to variant, - "java" to javaVersions.first() - ) - } - ) - ) + strategy = Strategy( + matrix = Matrix.full ) ) { uses( @@ -99,7 +65,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr("matrix.java") + additionalJavaVersion = expr(Matrix.java) ) ) uses( @@ -109,16 +75,12 @@ workflow( "--no-parallel", "--stacktrace", "ghActionsBuild", - """"-Dvariant=${expr("matrix.variant")}"""", - """"-DjavaVersion=${expr("matrix.java")}"""", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.java)}"""", "-Dscan.tag.main-build" ).joinToString(" ") ), - env = linkedMapOf( - "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), - "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), - "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) - ) + env = commonCredentials ) run( name = "Stop Daemon", @@ -132,14 +94,14 @@ workflow( val releaseSpock = job( id = "release-spock", name = "Release Spock", - runsOn = RunnerType.Custom(expr("matrix.os")), + runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), needs = listOf(buildAndVerify), strategyMatrix = mapOf( "os" to listOf("ubuntu-latest"), // publish needs to be done for all versions - "variant" to variants, + "variant" to Matrix.axes.variants, // publish needs the min supported java version - "java" to javaVersions.take(1) + "java" to Matrix.axes.javaVersions.take(1) ) ) { uses( @@ -149,7 +111,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr("matrix.java") + additionalJavaVersion = expr(Matrix.java) ) ) uses( @@ -159,8 +121,8 @@ workflow( "--no-parallel", "--stacktrace", "ghActionsPublish", - """"-Dvariant=${expr("matrix.variant")}"""", - """"-DjavaVersion=${expr("matrix.java")}"""", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.java)}"""", "-Dscan.tag.main-publish" ).joinToString(" ") ), @@ -168,24 +130,21 @@ workflow( "GITHUB_TOKEN" to expr(GITHUB_TOKEN), "SONATYPE_OSS_USER" to expr(SONATYPE_OSS_USER), "SONATYPE_OSS_PASSWORD" to expr(SONATYPE_OSS_PASSWORD), - "SIGNING_PASSWORD" to expr(SIGNING_GPG_PASSWORD), - "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), - "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), - "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) - ) + "SIGNING_PASSWORD" to expr(SIGNING_GPG_PASSWORD) + ).apply { putAll(commonCredentials) } ) } job( id = "publish-release-docs", name = "Publish Release Docs", - runsOn = RunnerType.Custom(expr("matrix.os")), + runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), needs = listOf(releaseSpock), strategyMatrix = mapOf( "os" to listOf("ubuntu-latest"), // docs need the highest variant - "variant" to variants.takeLast(1), + "variant" to Matrix.axes.variants.takeLast(1), // docs need the highest java version - "java" to javaVersions.takeLast(1) + "java" to Matrix.axes.javaVersions.takeLast(1) ) ) { uses( @@ -195,7 +154,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr("matrix.java") + additionalJavaVersion = expr(Matrix.java) ) ) run( @@ -209,42 +168,14 @@ workflow( "--no-parallel", "--stacktrace", "ghActionsDocs", - """"-Dvariant=${expr("matrix.variant")}"""", - """"-DjavaVersion=${expr("matrix.java")}"""", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.java)}"""", "-Dscan.tag.main-docs" ).joinToString(" ") ), env = linkedMapOf( - "GITHUB_TOKEN" to expr(GITHUB_TOKEN), - "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), - "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), - "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) - ) + "GITHUB_TOKEN" to expr(GITHUB_TOKEN) + ).apply { putAll(commonCredentials) } ) } }.writeToFile() - -data class SetupBuildEnv( - val additionalJavaVersion: String? = null -) : LocalAction("./.github/actions/setup-build-env") { - override fun toYamlArguments() = - additionalJavaVersion?.let { linkedMapOf("additional-java-version" to it) } ?: linkedMapOf() - - override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) -} - -fun getMatrixAxes(): Pair, List> { - val binding = object : Binding() { - lateinit var javaVersions: List - lateinit var variants: List - - override fun setVariable(name: String?, value: Any?) { - when (name) { - "javaVersions" -> javaVersions = (value as List).map { it.toString() } - "variants" -> variants = value as List - } - } - } - GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) - return binding.javaVersions to binding.variants -} diff --git a/build-logic/preprocess-workflows/preprocess-workflows.gradle b/build-logic/preprocess-workflows/preprocess-workflows.gradle index 52e46d0ce4..23aff703d6 100644 --- a/build-logic/preprocess-workflows/preprocess-workflows.gradle +++ b/build-logic/preprocess-workflows/preprocess-workflows.gradle @@ -3,6 +3,10 @@ plugins { id 'idea' } +dependencies { + implementation('org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.20') +} + gradlePlugin { plugins { preprocessWorkflowsPlugin { diff --git a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy index a536f92f4a..07a7b270ea 100644 --- a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy +++ b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy @@ -23,6 +23,19 @@ import org.gradle.api.artifacts.ModuleDependency import org.gradle.api.tasks.JavaExec import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.jvm.toolchain.JavaToolchainService +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer +import org.jetbrains.kotlin.com.intellij.openapi.vfs.local.CoreLocalFileSystem +import org.jetbrains.kotlin.com.intellij.openapi.vfs.local.CoreLocalVirtualFile +import org.jetbrains.kotlin.com.intellij.psi.PsiManager +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry +import org.jetbrains.kotlin.psi.KtStringTemplateExpression + +import static org.jetbrains.kotlin.cli.common.CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY +import static org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles.JVM_CONFIG_FILES @CompileStatic class PreprocessWorkflowsPlugin implements Plugin { @@ -47,6 +60,9 @@ class PreprocessWorkflowsPlugin implements Plugin { it.inputs .file(workflowScript) .withPropertyName('workflowScript') + it.inputs + .files(getImportedFiles(project.file(workflowScript))) + .withPropertyName("importedFiles") it.outputs .file(new File(workflowScript.parent, "${workflowName}.yml")) .withPropertyName('workflowFile') @@ -65,4 +81,45 @@ class PreprocessWorkflowsPlugin implements Plugin { } } } + + private List getImportedFiles(File workflowScript) { + if (!workflowScript.file) { + return [] + } + + return PsiManager + .getInstance( + KotlinCoreEnvironment + .createForProduction( + Disposer.newDisposable(), + new CompilerConfiguration().tap { + it.put(MESSAGE_COLLECTOR_KEY, MessageCollector.@Companion.NONE) + }, + JVM_CONFIG_FILES + ) + .project + ) + .findFile( + new CoreLocalVirtualFile( + new CoreLocalFileSystem(), + workflowScript + ) + ) + .with { it as KtFile } + .fileAnnotationList + ?.annotationEntries + ?.findAll { it.shortName?.asString() == "Import" } + *.valueArgumentList + ?.collectMany { it?.arguments ?: [] } + *.argumentExpression + ?.findAll { it instanceof KtStringTemplateExpression } + ?.collect { it as KtStringTemplateExpression } + *.entries + *.first() + ?.findAll { it instanceof KtLiteralStringTemplateEntry } + ?.collect { it as KtLiteralStringTemplateEntry } + ?.collect { new File(workflowScript.parentFile, it.text) } + ?.collectMany { getImportedFiles(it) + it } + ?: [] + } } diff --git a/build.gradle b/build.gradle index 582b61b37d..c9fbf04cd1 100644 --- a/build.gradle +++ b/build.gradle @@ -15,16 +15,13 @@ plugins { description = "Spock Framework" -ext.javaVersions = null -ext.variants = null -apply from: 'matrix.groovy' -variants = variants.collect { it as BigDecimal } - ext { baseVersion = "2.4" snapshotVersion = true milestone = 0 + javaVersions = javaVersions.trim().split(/\s*+,\s*+/).collect { it as int } javaVersion = (System.getProperty("javaVersion") ?: 8) as int + variants = variants.trim().split(/\s*+,\s*+/).collect { it as BigDecimal } variant = System.getProperty("variant") as BigDecimal ?: variants.first() develocity.buildScan.tag "groovy-$variant" if (variant == 2.5) { diff --git a/gradle.properties b/gradle.properties index 40fd8b39b0..4e72c3583b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,6 @@ org.gradle.java.installations.fromEnv=JDK8,JDK11,JDK17,JDK21 org.gradle.parallel=true org.gradle.caching=true + +javaVersions=8, 11, 17 +variants=2.5, 3.0, 4.0 diff --git a/matrix.groovy b/matrix.groovy deleted file mode 100644 index 202bd3dda7..0000000000 --- a/matrix.groovy +++ /dev/null @@ -1,2 +0,0 @@ -javaVersions = [8, 11, 17] // ensure that latest version is actually built on GitHub Actions, otherwise no docs get published -variants = ['2.5', '3.0', '4.0'] From 170892d19058dd47b1564097c59062ef64374723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Fri, 9 Jun 2023 21:23:10 +0200 Subject: [PATCH 11/30] Review feedback v2 --- .github/workflows/README.adoc | 9 ++- .github/workflows/branches-and-prs.main.kts | 4 +- .github/workflows/common.main.kts | 56 ++++++++++++------- .github/workflows/release.main.kts | 12 ++-- .../gradle/PreprocessWorkflowsPlugin.groovy | 3 + 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/.github/workflows/README.adoc b/.github/workflows/README.adoc index e3ad8dffc6..0e9514a6a2 100644 --- a/.github/workflows/README.adoc +++ b/.github/workflows/README.adoc @@ -18,7 +18,8 @@ the consistency of all the YAML files as not all are run for pull requests. == Ways to generate the YAML workflow files -There are multiple ways to generate the YAML files and all of them are fine: +There are multiple ways to generate the YAML files and all of them are fine, +but be aware of the last one of the caveats below if you are not using the Gradle method: * If you are in a `sh` derivate like e.g. `bash` and Kotlin is installed and available in the `PATH`, you can just call the `*.main.kts` script like any @@ -89,3 +90,9 @@ you either need to also change the importing file, or to properly execute the sc you need to delete the stale entry from the compilation cache which can be found at for example `~/.cache/main.kts.compiled.cache/` on Linux and `%LOCALAPPDATA%\main.kts.compiled.cache\` on Windows. Alternatively, you can also delete the whole cache directory. ++ +Another option is to disable the compilation cache for the execution by setting the +environment variable `KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR` or the system property +`kotlin.main.kts.compiled.scripts.cache.dir` to an empty value, depending on the run +method you chose. The Gradle tasks already do that, so when using the Gradle tasks you +do not have this problem and it just works. diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 36e58fb99d..4ff1e52191 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -83,7 +83,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr(Matrix.java) + additionalJavaVersion = expr(Matrix.javaVersion) ) ) uses( @@ -94,7 +94,7 @@ workflow( "--stacktrace", "ghActionsBuild", """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.java)}"""" + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""" ).joinToString(" ") ), // secrets are not injected for pull requests diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index eefc0020ea..1742863719 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -55,16 +55,27 @@ data class Matrix( val operatingSystems: List? = null, val variants: List? = null, val javaVersions: List? = null, - val excludes: List>? = null, - val includes: List>? = null + val exclude: (Element.() -> Boolean)? = null, + val includes: List? = null ) { + private val originalElements by lazy { + (operatingSystems ?: listOf(null)) + .map { Element(operatingSystem = it) } + .flatMap { element -> (variants ?: listOf(null)).map { element.copy(variant = it) } } + .flatMap { element -> (javaVersions ?: listOf(null)).map { element.copy(javaVersion = it) } } + } + fun toCustomArguments() = mapOf( *listOfNotNull( operatingSystems?.let { "os" to operatingSystems }, variants?.let { "variant" to variants }, javaVersions?.let { "java" to javaVersions }, - excludes?.let { "exclude" to excludes }, - includes?.let { "include" to includes } + exclude?.let { + "exclude" to originalElements + .filter(exclude) + .map { it.toCustomArguments() } + }, + includes?.let { "include" to includes.map { it.toCustomArguments() } } ).toTypedArray() ) @@ -73,10 +84,24 @@ data class Matrix( val variants: List ) + data class Element( + val operatingSystem: String? = null, + val variant: String? = null, + val javaVersion: String? = null + ) { + fun toCustomArguments() = mapOf( + *listOfNotNull( + operatingSystem?.let { "os" to operatingSystem }, + variant?.let { "variant" to variant }, + javaVersion?.let { "java" to javaVersion } + ).toTypedArray() + ) + } + companion object { val operatingSystem = "matrix.os" val variant = "matrix.variant" - val java = "matrix.java" + val javaVersion = "matrix.java" } } @@ -109,24 +134,15 @@ val Matrix.Companion.full operatingSystems = listOf("ubuntu-latest"), variants = axes.variants, javaVersions = axes.javaVersions, - excludes = axes.javaVersions - .filter { it.toInt() >= 17 } - .map { javaVersion -> - mapOf( - "os" to "ubuntu-latest", - "variant" to "2.5", - "java" to javaVersion - ) - }, + exclude = { (variant == "2.5") && (javaVersion!!.toInt() >= 17) }, includes = listOf("windows-latest", "macos-latest") - .flatMap { os -> axes.variants.map { os to it } } - .map { (os, variant) -> - mapOf( - "os" to os, - "variant" to variant, - "java" to axes.javaVersions.first() + .map { + Matrix.Element( + operatingSystem = it, + javaVersion = axes.javaVersions.first() ) } + .flatMap { element -> axes.variants.map { element.copy(variant = it) } } ) val Matrix.Companion.axes by lazy { diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 00cc2b74bd..37aceddd4c 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -65,7 +65,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr(Matrix.java) + additionalJavaVersion = expr(Matrix.javaVersion) ) ) uses( @@ -76,7 +76,7 @@ workflow( "--stacktrace", "ghActionsBuild", """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.java)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", "-Dscan.tag.main-build" ).joinToString(" ") ), @@ -111,7 +111,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr(Matrix.java) + additionalJavaVersion = expr(Matrix.javaVersion) ) ) uses( @@ -122,7 +122,7 @@ workflow( "--stacktrace", "ghActionsPublish", """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.java)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", "-Dscan.tag.main-publish" ).joinToString(" ") ), @@ -154,7 +154,7 @@ workflow( uses( name = "Set up JDKs", action = SetupBuildEnv( - additionalJavaVersion = expr(Matrix.java) + additionalJavaVersion = expr(Matrix.javaVersion) ) ) run( @@ -169,7 +169,7 @@ workflow( "--stacktrace", "ghActionsDocs", """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.java)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", "-Dscan.tag.main-docs" ).joinToString(" ") ), diff --git a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy index 07a7b270ea..666399da5e 100644 --- a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy +++ b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy @@ -75,6 +75,9 @@ class PreprocessWorkflowsPlugin implements Plugin { it.args('-no-stdlib', '-no-reflect') it.args('-classpath', kotlinScriptClasspath.asPath) it.args('-script', workflowScript.absolutePath) + + // work-around for https://youtrack.jetbrains.com/issue/KT-42101 + it.systemProperty('kotlin.main.kts.compiled.scripts.cache.dir', '') } preprocessWorkflows.configure { it.dependsOn(preprocessWorkflow) From fc2312867bb4311e23dda2bf8c3431ff72efb89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 15 Aug 2023 05:02:41 +0200 Subject: [PATCH 12/30] Catch up changes from master --- .github/workflows/branches-and-prs.main.kts | 4 +++- .github/workflows/branches-and-prs.yml | 1 + .github/workflows/codeql-analysis.main.kts | 2 ++ .github/workflows/codeql-analysis.yml | 1 + .github/workflows/common.main.kts | 2 +- .github/workflows/gradle-wrapper-validation.main.kts | 4 +++- .github/workflows/gradle-wrapper-validation.yml | 1 + 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 4ff1e52191..17a0ce5fe3 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -24,6 +24,7 @@ import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github @@ -40,7 +41,8 @@ workflow( "gh-pages" ) ), - PullRequest() + PullRequest(), + MergeGroup() ), sourceFile = __FILE__.toPath(), targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index e852b3108e..6b3814dcc8 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -9,6 +9,7 @@ on: - 'master' - 'gh-pages' pull_request: {} + merge_group: {} concurrency: group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' cancel-in-progress: true diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 556b912fe1..5c1d7923fe 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -25,6 +25,7 @@ import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.Cron +import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.domain.triggers.Schedule @@ -40,6 +41,7 @@ workflow( branches = listOf("!dependabot/**") ), PullRequest(), + MergeGroup(), Schedule( listOf( Cron( diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9e140048b9..6e89e1d13d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,6 +8,7 @@ on: branches: - '!dependabot/**' pull_request: {} + merge_group: {} schedule: - cron: '0 15 * * TUE' concurrency: diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index 1742863719..a47c93e323 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.44.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.49.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 066f367e3a..a31406a13f 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -21,6 +21,7 @@ import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.workflow @@ -30,7 +31,8 @@ workflow( name = "Validate Gradle Wrapper", on = listOf( Push(), - PullRequest() + PullRequest(), + MergeGroup() ), sourceFile = __FILE__.toPath(), targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 01ced15136..6f14f90bdf 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -6,6 +6,7 @@ name: 'Validate Gradle Wrapper' on: push: {} pull_request: {} + merge_group: {} jobs: check_yaml_consistency: name: 'Check YAML consistency' From 7049f8d5a0a0d6f4025f5ca7ab8644d5782fbf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 22 Aug 2023 14:18:44 +0200 Subject: [PATCH 13/30] Update github-workflows-kt version to 0.50.0 --- .github/workflows/common.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index a47c93e323..2ff8b3ff25 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.49.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.50.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY From 93aa39ee072a9dec741df69663bb035e0297792a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 22 Aug 2023 14:19:20 +0200 Subject: [PATCH 14/30] Set group for GHA tasks to 'github actions' --- .../spockframework/gradle/PreprocessWorkflowsPlugin.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy index 666399da5e..d04c8161fc 100644 --- a/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy +++ b/build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy @@ -50,13 +50,17 @@ class PreprocessWorkflowsPlugin implements Plugin { } ) - def preprocessWorkflows = project.tasks.register('preprocessWorkflows') + def preprocessWorkflows = project.tasks.register('preprocessWorkflows') { + it.group = 'github actions' + } project.file('.github/workflows').eachFileMatch(~/.*\.main\.kts$/) { workflowScript -> def workflowName = workflowScript.name - ~/\.main\.kts$/ def pascalCasedWorkflowName = workflowName .replaceAll(/-\w/) { String it -> it[1].toUpperCase() } .replaceFirst(/^\w/) { String it -> it[0].toUpperCase() } def preprocessWorkflow = project.tasks.register("preprocess${pascalCasedWorkflowName}Workflow", JavaExec) { + it.group = 'github actions' + it.inputs .file(workflowScript) .withPropertyName('workflowScript') From f2e5f7170f1c376ce38ffa41e4aa3ca474065c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 19 Sep 2023 01:25:32 +0200 Subject: [PATCH 15/30] Catch up changes from master --- .github/workflows/branches-and-prs.main.kts | 8 ++++---- .github/workflows/branches-and-prs.yml | 6 +++--- .github/workflows/codeql-analysis.main.kts | 4 ++-- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/common.main.kts | 2 +- .github/workflows/gradle-wrapper-validation.main.kts | 4 ++-- .github/workflows/gradle-wrapper-validation.yml | 4 ++-- .github/workflows/release.main.kts | 10 +++++----- .github/workflows/release.yml | 8 ++++---- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 17a0ce5fe3..874c136b9c 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -18,7 +18,7 @@ @file:Import("common.main.kts") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency @@ -59,7 +59,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3() + action = CheckoutV4() ) run( name = "Regenerate all workflow YAMLs and check for modifications", @@ -77,9 +77,9 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3( + action = CheckoutV4( // Codecov needs fetch-depth > 1 - fetchDepth = CheckoutV3.FetchDepth.Value(2) + fetchDepth = CheckoutV4.FetchDepth.Value(2) ) ) uses( diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 6b3814dcc8..389e251294 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -20,7 +20,7 @@ jobs: steps: - id: 'step-0' name: 'Check out' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Execute script' run: 'rm ''.github/workflows/branches-and-prs.yml'' && ''.github/workflows/branches-and-prs.main.kts''' @@ -35,7 +35,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Regenerate all workflow YAMLs and check for modifications' run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c ''{} && git diff --exit-code''' @@ -83,7 +83,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' with: fetch-depth: '2' - id: 'step-1' diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 5c1d7923fe..461b552144 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -18,7 +18,7 @@ @file:Import("common.main.kts") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 import io.github.typesafegithub.workflows.actions.github.CodeqlActionInitV2 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 @@ -73,7 +73,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3() + action = CheckoutV4() ) // Manually added: Install and setup JDK uses( diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6e89e1d13d..38b819a9a7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,7 +21,7 @@ jobs: steps: - id: 'step-0' name: 'Check out' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Execute script' run: 'rm ''.github/workflows/codeql-analysis.yml'' && ''.github/workflows/codeql-analysis.main.kts''' @@ -43,7 +43,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Set up JDKs' uses: './.github/actions/setup-build-env' diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index 2ff8b3ff25..b6073ec09e 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.50.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.1.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index a31406a13f..865ae821db 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -18,7 +18,7 @@ @file:Import("common.main.kts") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.MergeGroup @@ -44,7 +44,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3() + action = CheckoutV4() ) uses( name = "Validate Wrapper", diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 6f14f90bdf..090623a7f8 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -14,7 +14,7 @@ jobs: steps: - id: 'step-0' name: 'Check out' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Execute script' run: 'rm ''.github/workflows/gradle-wrapper-validation.yml'' && ''.github/workflows/gradle-wrapper-validation.main.kts''' @@ -29,7 +29,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Validate Wrapper' uses: 'gradle/wrapper-validation-action@v1' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 37aceddd4c..768e801800 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -18,8 +18,8 @@ @file:Import("common.main.kts") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4.FetchDepth import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.RunnerType @@ -57,7 +57,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3( + action = CheckoutV4( // Codecov needs fetch-depth > 1 fetchDepth = FetchDepth.Value(2) ) @@ -106,7 +106,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3() + action = CheckoutV4() ) uses( name = "Set up JDKs", @@ -149,7 +149,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV3() + action = CheckoutV4() ) uses( name = "Set up JDKs", diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26bb7b049b..e58cede111 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: steps: - id: 'step-0' name: 'Check out' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Execute script' run: 'rm ''.github/workflows/release.yml'' && ''.github/workflows/release.main.kts''' @@ -68,7 +68,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' with: fetch-depth: '2' - id: 'step-1' @@ -110,7 +110,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Set up JDKs' uses: './.github/actions/setup-build-env' @@ -146,7 +146,7 @@ jobs: steps: - id: 'step-0' name: 'Checkout Repository' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-1' name: 'Set up JDKs' uses: './.github/actions/setup-build-env' From 6119c3f73a8cd8878976e50511be7815476043a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 11 Oct 2023 22:21:39 +0200 Subject: [PATCH 16/30] Catch up changes from master --- .github/workflows/branches-and-prs.yml | 4 ++++ .github/workflows/release.yml | 6 +++++- gradle.properties | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 389e251294..be074fc56c 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -57,10 +57,14 @@ jobs: - '8' - '11' - '17' + - '21' exclude: - os: 'ubuntu-latest' variant: '2.5' java: '17' + - os: 'ubuntu-latest' + variant: '2.5' + java: '21' include: - os: 'windows-latest' variant: '2.5' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e58cede111..996791cb06 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,10 +42,14 @@ jobs: - '8' - '11' - '17' + - '21' exclude: - os: 'ubuntu-latest' variant: '2.5' java: '17' + - os: 'ubuntu-latest' + variant: '2.5' + java: '21' include: - os: 'windows-latest' variant: '2.5' @@ -142,7 +146,7 @@ jobs: variant: - '4.0' java: - - '17' + - '21' steps: - id: 'step-0' name: 'Checkout Repository' diff --git a/gradle.properties b/gradle.properties index 4e72c3583b..bcb9b1726a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,5 +20,5 @@ org.gradle.java.installations.fromEnv=JDK8,JDK11,JDK17,JDK21 org.gradle.parallel=true org.gradle.caching=true -javaVersions=8, 11, 17 +javaVersions=8, 11, 17, 21 variants=2.5, 3.0, 4.0 From 04d9237dd9b83cc1a6bf2e11d75fe72f3e561f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Fri, 13 Oct 2023 17:02:13 +0200 Subject: [PATCH 17/30] Update github-workflows-kt version to 1.3.0 --- .github/workflows/common.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index b6073ec09e..983cdc921a 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.1.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.3.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY From c3c1406f794bd0cbc477cc02ed2b103d7677a6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 31 Oct 2023 14:55:33 +0100 Subject: [PATCH 18/30] Update github-workflows-kt version to 1.4.0 --- .github/workflows/common.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index 983cdc921a..30e9f23578 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.3.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.4.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY From 23b171a8ccf07178edd15e78fa1c4e75cbe8f242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 31 Oct 2023 14:56:33 +0100 Subject: [PATCH 19/30] Catch up changes from master --- .github/workflows/branches-and-prs.main.kts | 20 +++---- .github/workflows/branches-and-prs.yml | 4 +- .github/workflows/codeql-analysis.main.kts | 18 +++--- .github/workflows/codeql-analysis.yml | 4 +- .github/workflows/release.main.kts | 64 ++++++++++----------- .github/workflows/release.yml | 12 +--- 6 files changed, 52 insertions(+), 70 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 874c136b9c..77b81f1918 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -20,7 +20,6 @@ import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 -import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest @@ -88,17 +87,16 @@ workflow( additionalJavaVersion = expr(Matrix.javaVersion) ) ) - uses( + run( name = "Build Spock", - action = GradleBuildActionV2( - arguments = listOf( - "--no-parallel", - "--stacktrace", - "ghActionsBuild", - """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.javaVersion)}"""" - ).joinToString(" ") - ), + command = listOf( + "./gradlew", + "--no-parallel", + "--stacktrace", + "ghActionsBuild", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""" + ).joinToString(" "), // secrets are not injected for pull requests env = commonCredentials ) diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index be074fc56c..b4198d2a91 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -97,13 +97,11 @@ jobs: additional-java-version: '${{ matrix.java }}' - id: 'step-2' name: 'Build Spock' - uses: 'gradle/gradle-build-action@v2' - with: - arguments: '--no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' env: ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' - id: 'step-3' name: 'Upload to Codecov.io' uses: 'codecov/codecov-action@v3' diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index 461b552144..a3ddee7a11 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -21,7 +21,6 @@ import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 import io.github.typesafegithub.workflows.actions.github.CodeqlActionInitV2 -import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.Cron @@ -113,16 +112,15 @@ workflow( // Manually added: build // we have to disable build cache for now as it seems to be necessary for the compiler to run during the build // https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-the-codeql-workflow#no-code-found-during-the-build - uses( + run( name = "Build Spock Classes", - action = GradleBuildActionV2( - arguments = listOf( - "--stacktrace", - "--no-build-cache", - "testClasses", - """"-Dvariant=${expr(Matrix.variant)}"""" - ).joinToString(" ") - ) + command = listOf( + "./gradlew", + "--stacktrace", + "--no-build-cache", + "testClasses", + """"-Dvariant=${expr(Matrix.variant)}"""" + ).joinToString(" ") ) uses( name = "Perform CodeQL Analysis", diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 38b819a9a7..755b3faf1b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -52,9 +52,7 @@ jobs: uses: 'github/codeql-action/init@v3' - id: 'step-3' name: 'Build Spock Classes' - uses: 'gradle/gradle-build-action@v2' - with: - arguments: '--stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}"' + run: './gradlew --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}"' - id: 'step-4' name: 'Perform CodeQL Analysis' uses: 'github/codeql-action/analyze@v3' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 768e801800..2cc3d42810 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -21,7 +21,6 @@ import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.actions.CheckoutV4.FetchDepth import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 -import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github @@ -68,18 +67,17 @@ workflow( additionalJavaVersion = expr(Matrix.javaVersion) ) ) - uses( + run( name = "Build Spock", - action = GradleBuildActionV2( - arguments = listOf( - "--no-parallel", - "--stacktrace", - "ghActionsBuild", - """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", - "-Dscan.tag.main-build" - ).joinToString(" ") - ), + command = listOf( + "./gradlew", + "--no-parallel", + "--stacktrace", + "ghActionsBuild", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", + "-Dscan.tag.main-build" + ).joinToString(" "), env = commonCredentials ) run( @@ -114,18 +112,17 @@ workflow( additionalJavaVersion = expr(Matrix.javaVersion) ) ) - uses( + run( name = "Publish Spock", - action = GradleBuildActionV2( - arguments = listOf( - "--no-parallel", - "--stacktrace", - "ghActionsPublish", - """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", - "-Dscan.tag.main-publish" - ).joinToString(" ") - ), + command = listOf( + "./gradlew", + "--no-parallel", + "--stacktrace", + "ghActionsPublish", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", + "-Dscan.tag.main-publish" + ).joinToString(" "), env = linkedMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN), "SONATYPE_OSS_USER" to expr(SONATYPE_OSS_USER), @@ -161,18 +158,17 @@ workflow( name = "Create Temporary Branch", command = "git checkout -b \"docs-\$GITHUB_SHA\"" ) - uses( + run( name = "Publish Docs", - action = GradleBuildActionV2( - arguments = listOf( - "--no-parallel", - "--stacktrace", - "ghActionsDocs", - """"-Dvariant=${expr(Matrix.variant)}"""", - """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", - "-Dscan.tag.main-docs" - ).joinToString(" ") - ), + command = listOf( + "./gradlew", + "--no-parallel", + "--stacktrace", + "ghActionsDocs", + """"-Dvariant=${expr(Matrix.variant)}"""", + """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", + "-Dscan.tag.main-docs" + ).joinToString(" "), env = linkedMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN) ).apply { putAll(commonCredentials) } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 996791cb06..07215258b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,13 +82,11 @@ jobs: additional-java-version: '${{ matrix.java }}' - id: 'step-2' name: 'Build Spock' - uses: 'gradle/gradle-build-action@v2' - with: - arguments: '--no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build' env: ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build' - id: 'step-3' name: 'Stop Daemon' run: './gradlew --stop' @@ -122,9 +120,6 @@ jobs: additional-java-version: '${{ matrix.java }}' - id: 'step-2' name: 'Publish Spock' - uses: 'gradle/gradle-build-action@v2' - with: - arguments: '--no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish' env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' SONATYPE_OSS_USER: '${{ secrets.SONATYPE_OSS_USER }}' @@ -133,6 +128,7 @@ jobs: ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish' publish-release-docs: name: 'Publish Release Docs' runs-on: '${{ matrix.os }}' @@ -161,11 +157,9 @@ jobs: run: 'git checkout -b "docs-$GITHUB_SHA"' - id: 'step-3' name: 'Publish Docs' - uses: 'gradle/gradle-build-action@v2' - with: - arguments: '--no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs' env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs' From 80aae4f87969efccf789e8517ded8df89a414454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 6 Mar 2024 03:50:51 +0100 Subject: [PATCH 20/30] Update github-workflows-kt version to 1.12.0 --- .github/workflows/common.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index 30e9f23578..c1015268bb 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.4.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.12.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY From 4e0201381417ab9db2cb257f77eba1f9dcd0ce7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 6 Mar 2024 03:58:27 +0100 Subject: [PATCH 21/30] Catch up changes from master --- .github/workflows/branches-and-prs.main.kts | 4 ++-- .github/workflows/branches-and-prs.yml | 2 +- .github/workflows/gradle-wrapper-validation.main.kts | 4 ++-- .github/workflows/gradle-wrapper-validation.yml | 2 +- .github/workflows/release.main.kts | 8 ++++++-- .github/workflows/release.yml | 5 ++++- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 77b81f1918..6f19beeec6 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -19,7 +19,7 @@ @file:Import("common.main.kts") import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 +import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV4 import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest @@ -102,7 +102,7 @@ workflow( ) uses( name = "Upload to Codecov.io", - action = CodecovActionV3() + action = CodecovActionV4() ) } }.writeToFile() diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index b4198d2a91..49d1f431af 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -104,4 +104,4 @@ jobs: run: './gradlew --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' - id: 'step-3' name: 'Upload to Codecov.io' - uses: 'codecov/codecov-action@v3' + uses: 'codecov/codecov-action@v4' diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 865ae821db..65b6c64275 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -19,7 +19,7 @@ @file:Import("common.main.kts") import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 +import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV2 import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest @@ -48,7 +48,7 @@ workflow( ) uses( name = "Validate Wrapper", - action = WrapperValidationActionV1() + action = WrapperValidationActionV2() ) } }.writeToFile() diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 090623a7f8..640778a470 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -32,4 +32,4 @@ jobs: uses: 'actions/checkout@v4' - id: 'step-1' name: 'Validate Wrapper' - uses: 'gradle/wrapper-validation-action@v1' + uses: 'gradle/wrapper-validation-action@v2' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 2cc3d42810..0a2250e2c7 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -20,7 +20,7 @@ import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 import io.github.typesafegithub.workflows.actions.actions.CheckoutV4.FetchDepth -import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 +import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV4 import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github @@ -86,7 +86,7 @@ workflow( ) uses( name = "Upload to Codecov.io", - action = CodecovActionV3() + action = CodecovActionV4() ) } val releaseSpock = job( @@ -158,6 +158,10 @@ workflow( name = "Create Temporary Branch", command = "git checkout -b \"docs-\$GITHUB_SHA\"" ) + run( + name = "Install GraphViz", + command = "sudo apt update && sudo apt install --yes graphviz" + ) run( name = "Publish Docs", command = listOf( diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07215258b8..2ea966193b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,7 +92,7 @@ jobs: run: './gradlew --stop' - id: 'step-4' name: 'Upload to Codecov.io' - uses: 'codecov/codecov-action@v3' + uses: 'codecov/codecov-action@v4' release-spock: name: 'Release Spock' runs-on: '${{ matrix.os }}' @@ -156,6 +156,9 @@ jobs: name: 'Create Temporary Branch' run: 'git checkout -b "docs-$GITHUB_SHA"' - id: 'step-3' + name: 'Install GraphViz' + run: 'sudo apt update && sudo apt install --yes graphviz' + - id: 'step-4' name: 'Publish Docs' env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' From 17bff51daab61538a4cc3752fc4c2b08e3700380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 6 Mar 2024 04:22:40 +0100 Subject: [PATCH 22/30] Update Kotlin code style settings --- .editorconfig | 3 +++ gradle.properties | 1 + 2 files changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index be09a3f654..9ed5bb081a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,5 +16,8 @@ indent_size = 2 trim_trailing_whitespace = false [*.{kt,kts}] +indent_size = 4 ij_kotlin_allow_trailing_comma = false ij_kotlin_allow_trailing_comma_on_call_site = false +ktlint_code_style = intellij_idea +ktlint_standard_function-signature = disabled diff --git a/gradle.properties b/gradle.properties index bcb9b1726a..c9c1afe330 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,3 +22,4 @@ org.gradle.caching=true javaVersions=8, 11, 17, 21 variants=2.5, 3.0, 4.0 +kotlin.code.style=official From 13a604112dc92d1087cc4f6044632dbdea6d7160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 18 Mar 2024 03:47:56 +0100 Subject: [PATCH 23/30] Catch up changes from master --- .github/workflows/docs-pr.main.kts | 97 ++++++++++++++++++++++++++++++ .github/workflows/docs-pr.yml | 77 +++++++++++++++--------- 2 files changed, 146 insertions(+), 28 deletions(-) create mode 100755 .github/workflows/docs-pr.main.kts diff --git a/.github/workflows/docs-pr.main.kts b/.github/workflows/docs-pr.main.kts new file mode 100755 index 0000000000..95194c59a7 --- /dev/null +++ b/.github/workflows/docs-pr.main.kts @@ -0,0 +1,97 @@ +#!/usr/bin/env kotlin + +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:Import("common.main.kts") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 +import io.github.typesafegithub.workflows.actions.actions.UploadArtifactV4 +import io.github.typesafegithub.workflows.domain.Concurrency +import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.triggers.MergeGroup +import io.github.typesafegithub.workflows.domain.triggers.PullRequest +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github +import io.github.typesafegithub.workflows.dsl.expressions.expr +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Verify Docs", + on = listOf( + Push( + branchesIgnore = listOf( + "master", + "gh-pages" + ) + ), + PullRequest(), + MergeGroup() + ), + sourceFile = __FILE__.toPath(), + targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", + // https://stackoverflow.com/a/72408109/16358266 + concurrency = Concurrency( + group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}", + cancelInProgress = true + ) +) { + job( + id = "docs-and-javadoc", + name = "Docs and JavaDoc", + runsOn = UbuntuLatest, + ) { + uses( + name = "Checkout Repository", + action = CheckoutV4( + fetchDepth = CheckoutV4.FetchDepth.Value(1) + ) + ) + uses( + name = "Set up JDKs", + action = SetupBuildEnv( + additionalJavaVersion = Matrix.axes.javaVersions.last() + ) + ) + run( + name = "Install GraphViz", + command = "sudo apt update && sudo apt install --yes graphviz" + ) + run( + name = "Build Docs", + command = listOf( + "./gradlew", + "--no-parallel", + "--stacktrace", + "asciidoctor", + "javadoc", + """"-Dvariant=${Matrix.axes.variants.last()}"""", + """"-DjavaVersion=${Matrix.axes.javaVersions.last()}"""" + ).joinToString(" ") + ) + uses( + name = "Archive and upload docs", + action = UploadArtifactV4( + name = "docs", + path = listOf( + "build/docs/**", + "build/javadoc/**" + ) + ) + ) + } +}.writeToFile() diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index 518b745d9d..eda461fa1d 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -1,38 +1,59 @@ -name: 'Verify Docs' +# This file was generated using Kotlin DSL (.github/workflows/docs-pr.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt +name: 'Verify Docs' on: push: branches-ignore: - - master - - gh-pages - pull_request: - merge_group: - -# https://stackoverflow.com/a/72408109/16358266 + - 'master' + - 'gh-pages' + pull_request: {} + merge_group: {} concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' cancel-in-progress: true - jobs: + check_yaml_consistency: + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' + steps: + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v4' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/docs-pr.yml'' && ''.github/workflows/docs-pr.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/docs-pr.yml''' docs-and-javadoc: + name: 'Docs and JavaDoc' runs-on: 'ubuntu-latest' + needs: + - 'check_yaml_consistency' steps: - - uses: actions/checkout@v4 - with: - # Codecov needs fetch-depth > 1 - fetch-depth: 2 - - name: 'Set up JDKs' - uses: ./.github/actions/setup-build-env - with: - additional-java-version: 21 - - name: 'Install GraphViz' - run: sudo apt update && sudo apt install --yes graphviz - - name: 'Build Docs' - run: ./gradlew --stacktrace asciidoctor javadoc "-Dvariant=4.0" "-DjavaVersion=21" - - name: 'Archive and upload docs' - uses: actions/upload-artifact@v4 - with: - name: docs - path: | - build/docs/** - build/javadoc/** + - id: 'step-0' + name: 'Checkout Repository' + uses: 'actions/checkout@v4' + with: + fetch-depth: '1' + - id: 'step-1' + name: 'Set up JDKs' + uses: './.github/actions/setup-build-env' + with: + additional-java-version: '21' + - id: 'step-2' + name: 'Install GraphViz' + run: 'sudo apt update && sudo apt install --yes graphviz' + - id: 'step-3' + name: 'Build Docs' + run: './gradlew --no-parallel --stacktrace asciidoctor javadoc "-Dvariant=4.0" "-DjavaVersion=21"' + - id: 'step-4' + name: 'Archive and upload docs' + uses: 'actions/upload-artifact@v4' + with: + name: 'docs' + path: |- + build/docs/** + build/javadoc/** From c2c813175ab95c89567059da39423b1c8c87da1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Sat, 20 Apr 2024 02:48:28 +0200 Subject: [PATCH 24/30] Catch up changes from master --- .github/workflows/branches-and-prs.main.kts | 1 - .github/workflows/branches-and-prs.yml | 6 ++---- .github/workflows/common.main.kts | 8 ++------ .github/workflows/docs-pr.main.kts | 1 - .github/workflows/docs-pr.yml | 2 +- .../workflows/gradle-wrapper-validation.main.kts | 2 +- .github/workflows/gradle-wrapper-validation.yml | 2 +- .github/workflows/release.main.kts | 1 - .github/workflows/release.yml | 14 ++++---------- 9 files changed, 11 insertions(+), 26 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 6f19beeec6..9394ec7ccb 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -91,7 +91,6 @@ workflow( name = "Build Spock", command = listOf( "./gradlew", - "--no-parallel", "--stacktrace", "ghActionsBuild", """"-Dvariant=${expr(Matrix.variant)}"""", diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 49d1f431af..43b24e0810 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -98,10 +98,8 @@ jobs: - id: 'step-2' name: 'Build Spock' env: - ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' - ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' - GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' - run: './gradlew --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' + DEVELOCITY_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"' - id: 'step-3' name: 'Upload to Codecov.io' uses: 'codecov/codecov-action@v4' diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index c1015268bb..f11b5614df 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.12.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.14.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY @@ -29,14 +29,10 @@ import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets import io.github.typesafegithub.workflows.dsl.expressions.expr import java.util.Properties -val SPOCK_BUILD_CACHE_USERNAME by secrets -val SPOCK_BUILD_CACHE_PASSWORD by secrets val GRADLE_ENTERPRISE_ACCESS_KEY by secrets val commonCredentials = linkedMapOf( - "ORG_GRADLE_PROJECT_spockBuildCacheUsername" to expr(SPOCK_BUILD_CACHE_USERNAME), - "ORG_GRADLE_PROJECT_spockBuildCachePassword" to expr(SPOCK_BUILD_CACHE_PASSWORD), - "GRADLE_ENTERPRISE_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) + "DEVELOCITY_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) ) data class Strategy( diff --git a/.github/workflows/docs-pr.main.kts b/.github/workflows/docs-pr.main.kts index 95194c59a7..0f60290eb6 100755 --- a/.github/workflows/docs-pr.main.kts +++ b/.github/workflows/docs-pr.main.kts @@ -75,7 +75,6 @@ workflow( name = "Build Docs", command = listOf( "./gradlew", - "--no-parallel", "--stacktrace", "asciidoctor", "javadoc", diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index eda461fa1d..dc5e4cda86 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -48,7 +48,7 @@ jobs: run: 'sudo apt update && sudo apt install --yes graphviz' - id: 'step-3' name: 'Build Docs' - run: './gradlew --no-parallel --stacktrace asciidoctor javadoc "-Dvariant=4.0" "-DjavaVersion=21"' + run: './gradlew --stacktrace asciidoctor javadoc "-Dvariant=4.0" "-DjavaVersion=21"' - id: 'step-4' name: 'Archive and upload docs' uses: 'actions/upload-artifact@v4' diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 65b6c64275..0fac7efb2d 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -48,7 +48,7 @@ workflow( ) uses( name = "Validate Wrapper", - action = WrapperValidationActionV2() + action = WrapperValidationActionV2(_customVersion = "v3") ) } }.writeToFile() diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 640778a470..44ecb48135 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -32,4 +32,4 @@ jobs: uses: 'actions/checkout@v4' - id: 'step-1' name: 'Validate Wrapper' - uses: 'gradle/wrapper-validation-action@v2' + uses: 'gradle/wrapper-validation-action@v3' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 0a2250e2c7..0a39b79de6 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -71,7 +71,6 @@ workflow( name = "Build Spock", command = listOf( "./gradlew", - "--no-parallel", "--stacktrace", "ghActionsBuild", """"-Dvariant=${expr(Matrix.variant)}"""", diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ea966193b..eee4a24c29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,10 +83,8 @@ jobs: - id: 'step-2' name: 'Build Spock' env: - ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' - ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' - GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' - run: './gradlew --no-parallel --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build' + DEVELOCITY_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + run: './gradlew --stacktrace ghActionsBuild "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-build' - id: 'step-3' name: 'Stop Daemon' run: './gradlew --stop' @@ -125,9 +123,7 @@ jobs: SONATYPE_OSS_USER: '${{ secrets.SONATYPE_OSS_USER }}' SONATYPE_OSS_PASSWORD: '${{ secrets.SONATYPE_OSS_PASSWORD }}' SIGNING_PASSWORD: '${{ secrets.SIGNING_GPG_PASSWORD }}' - ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' - ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' - GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + DEVELOCITY_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' run: './gradlew --no-parallel --stacktrace ghActionsPublish "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-publish' publish-release-docs: name: 'Publish Release Docs' @@ -162,7 +158,5 @@ jobs: name: 'Publish Docs' env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - ORG_GRADLE_PROJECT_spockBuildCacheUsername: '${{ secrets.SPOCK_BUILD_CACHE_USERNAME }}' - ORG_GRADLE_PROJECT_spockBuildCachePassword: '${{ secrets.SPOCK_BUILD_CACHE_PASSWORD }}' - GRADLE_ENTERPRISE_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' + DEVELOCITY_ACCESS_KEY: '${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}' run: './gradlew --no-parallel --stacktrace ghActionsDocs "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}" -Dscan.tag.main-docs' From d8ea1ceee5cefad37f9dfd417e870d14bf21442f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 16 May 2024 12:21:16 +0200 Subject: [PATCH 25/30] Catch up changes from master --- .github/workflows/branches-and-prs.yml | 40 +++++++++++---------- .github/workflows/common.main.kts | 12 +++---- .github/workflows/release.main.kts | 10 +++--- .github/workflows/release.yml | 48 ++++++++++++++------------ 4 files changed, 59 insertions(+), 51 deletions(-) diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 43b24e0810..251d67e7e5 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -47,8 +47,6 @@ jobs: strategy: fail-fast: false matrix: - os: - - 'ubuntu-latest' variant: - '2.5' - '3.0' @@ -58,32 +56,38 @@ jobs: - '11' - '17' - '21' + - '22' + os: + - 'ubuntu-latest' exclude: - - os: 'ubuntu-latest' - variant: '2.5' + - variant: '2.5' java: '17' - - os: 'ubuntu-latest' - variant: '2.5' + os: 'ubuntu-latest' + - variant: '2.5' java: '21' + os: 'ubuntu-latest' + - variant: '2.5' + java: '22' + os: 'ubuntu-latest' include: - - os: 'windows-latest' - variant: '2.5' + - variant: '2.5' java: '8' - - os: 'windows-latest' - variant: '3.0' + os: 'windows-latest' + - variant: '3.0' java: '8' - - os: 'windows-latest' - variant: '4.0' + os: 'windows-latest' + - variant: '4.0' java: '8' - - os: 'macos-latest' - variant: '2.5' + os: 'windows-latest' + - variant: '2.5' java: '8' - - os: 'macos-latest' - variant: '3.0' + os: 'macos-latest' + - variant: '3.0' java: '8' - - os: 'macos-latest' - variant: '4.0' + os: 'macos-latest' + - variant: '4.0' java: '8' + os: 'macos-latest' steps: - id: 'step-0' name: 'Checkout Repository' diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index f11b5614df..9b1eb453f4 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -61,11 +61,11 @@ data class Matrix( .flatMap { element -> (javaVersions ?: listOf(null)).map { element.copy(javaVersion = it) } } } - fun toCustomArguments() = mapOf( + fun toCustomArguments() = linkedMapOf( *listOfNotNull( - operatingSystems?.let { "os" to operatingSystems }, variants?.let { "variant" to variants }, javaVersions?.let { "java" to javaVersions }, + operatingSystems?.let { "os" to operatingSystems }, exclude?.let { "exclude" to originalElements .filter(exclude) @@ -85,11 +85,11 @@ data class Matrix( val variant: String? = null, val javaVersion: String? = null ) { - fun toCustomArguments() = mapOf( + fun toCustomArguments() = linkedMapOf( *listOfNotNull( - operatingSystem?.let { "os" to operatingSystem }, variant?.let { "variant" to variant }, - javaVersion?.let { "java" to javaVersion } + javaVersion?.let { "java" to javaVersion }, + operatingSystem?.let { "os" to operatingSystem } ).toTypedArray() ) } @@ -129,7 +129,7 @@ val Matrix.Companion.full get() = Matrix( operatingSystems = listOf("ubuntu-latest"), variants = axes.variants, - javaVersions = axes.javaVersions, + javaVersions = axes.javaVersions + "22", exclude = { (variant == "2.5") && (javaVersion!!.toInt() >= 17) }, includes = listOf("windows-latest", "macos-latest") .map { diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 0a39b79de6..c71a78edc2 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -94,11 +94,11 @@ workflow( runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), needs = listOf(buildAndVerify), strategyMatrix = mapOf( - "os" to listOf("ubuntu-latest"), // publish needs to be done for all versions "variant" to Matrix.axes.variants, // publish needs the min supported java version - "java" to Matrix.axes.javaVersions.take(1) + "java" to Matrix.axes.javaVersions.take(1), + "os" to listOf("ubuntu-latest") ) ) { uses( @@ -135,12 +135,12 @@ workflow( name = "Publish Release Docs", runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), needs = listOf(releaseSpock), - strategyMatrix = mapOf( - "os" to listOf("ubuntu-latest"), + strategyMatrix = linkedMapOf( // docs need the highest variant "variant" to Matrix.axes.variants.takeLast(1), // docs need the highest java version - "java" to Matrix.axes.javaVersions.takeLast(1) + "java" to Matrix.axes.javaVersions.takeLast(1), + "os" to listOf("ubuntu-latest") ) ) { uses( diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eee4a24c29..a5b41b49f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,8 +32,6 @@ jobs: strategy: fail-fast: false matrix: - os: - - 'ubuntu-latest' variant: - '2.5' - '3.0' @@ -43,32 +41,38 @@ jobs: - '11' - '17' - '21' + - '22' + os: + - 'ubuntu-latest' exclude: - - os: 'ubuntu-latest' - variant: '2.5' + - variant: '2.5' java: '17' - - os: 'ubuntu-latest' - variant: '2.5' + os: 'ubuntu-latest' + - variant: '2.5' java: '21' + os: 'ubuntu-latest' + - variant: '2.5' + java: '22' + os: 'ubuntu-latest' include: - - os: 'windows-latest' - variant: '2.5' + - variant: '2.5' java: '8' - - os: 'windows-latest' - variant: '3.0' + os: 'windows-latest' + - variant: '3.0' java: '8' - - os: 'windows-latest' - variant: '4.0' + os: 'windows-latest' + - variant: '4.0' java: '8' - - os: 'macos-latest' - variant: '2.5' + os: 'windows-latest' + - variant: '2.5' java: '8' - - os: 'macos-latest' - variant: '3.0' + os: 'macos-latest' + - variant: '3.0' java: '8' - - os: 'macos-latest' - variant: '4.0' + os: 'macos-latest' + - variant: '4.0' java: '8' + os: 'macos-latest' steps: - id: 'step-0' name: 'Checkout Repository' @@ -99,14 +103,14 @@ jobs: - 'check_yaml_consistency' strategy: matrix: - os: - - 'ubuntu-latest' variant: - '2.5' - '3.0' - '4.0' java: - '8' + os: + - 'ubuntu-latest' steps: - id: 'step-0' name: 'Checkout Repository' @@ -133,12 +137,12 @@ jobs: - 'check_yaml_consistency' strategy: matrix: - os: - - 'ubuntu-latest' variant: - '4.0' java: - '21' + os: + - 'ubuntu-latest' steps: - id: 'step-0' name: 'Checkout Repository' From 267d269f9bbfbd5b075dbfe9fb0aa80bc95ae093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 16 May 2024 12:23:25 +0200 Subject: [PATCH 26/30] Only use zulu on arm macOS --- .github/actions/setup-jdks/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-jdks/action.yml b/.github/actions/setup-jdks/action.yml index 5afb6795da..eaf6567301 100644 --- a/.github/actions/setup-jdks/action.yml +++ b/.github/actions/setup-jdks/action.yml @@ -21,7 +21,7 @@ runs: uses: actions/setup-java@v4 with: # Temurin JDK 8 for macos on ARM is not available: https://github.com/adoptium/adoptium/issues/96 - distribution: ${{ runner.os == 'macOS' && 'zulu' || 'temurin' }} + distribution: ${{ ((runner.os == 'macOS') && (runner.arch == 'ARM64')) && 'zulu' || 'temurin' }} java-version: 8 - name: Prepare JDK8 env var shell: bash From c02372f06e4865ae184fcd8edb67e8564cfac35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 22 May 2024 16:42:37 +0200 Subject: [PATCH 27/30] Update github-workflows-kt version to 2.0.0 --- .github/workflows/branches-and-prs.main.kts | 5 ++--- .github/workflows/codeql-analysis.main.kts | 5 ++--- .github/workflows/common.main.kts | 8 ++++---- .github/workflows/docs-pr.main.kts | 5 ++--- .github/workflows/gradle-wrapper-validation.main.kts | 5 ++--- .github/workflows/release.main.kts | 11 +++++------ 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 9394ec7ccb..0d21351ef4 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -29,7 +29,6 @@ import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.writeToFile workflow( name = "Verify Branches and PRs", @@ -43,7 +42,7 @@ workflow( PullRequest(), MergeGroup() ), - sourceFile = __FILE__.toPath(), + sourceFile = __FILE__, targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( @@ -104,4 +103,4 @@ workflow( action = CodecovActionV4() ) } -}.writeToFile() +} diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index a3ddee7a11..f03d00fa04 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -31,7 +31,6 @@ import io.github.typesafegithub.workflows.domain.triggers.Schedule import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.writeToFile workflow( name = "Code scanning - action", @@ -51,7 +50,7 @@ workflow( ) ) ), - sourceFile = __FILE__.toPath(), + sourceFile = __FILE__, targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( @@ -127,4 +126,4 @@ workflow( action = CodeqlActionAnalyzeV2(_customVersion = "v3") ) } -}.writeToFile() +} diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index 9b1eb453f4..bc1058b04a 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,7 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.14.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY @@ -31,7 +31,7 @@ import java.util.Properties val GRADLE_ENTERPRISE_ACCESS_KEY by secrets -val commonCredentials = linkedMapOf( +val commonCredentials = mapOf( "DEVELOCITY_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY) ) @@ -61,7 +61,7 @@ data class Matrix( .flatMap { element -> (javaVersions ?: listOf(null)).map { element.copy(javaVersion = it) } } } - fun toCustomArguments() = linkedMapOf( + fun toCustomArguments() = mapOf( *listOfNotNull( variants?.let { "variant" to variants }, javaVersions?.let { "java" to javaVersions }, @@ -85,7 +85,7 @@ data class Matrix( val variant: String? = null, val javaVersion: String? = null ) { - fun toCustomArguments() = linkedMapOf( + fun toCustomArguments() = mapOf( *listOfNotNull( variant?.let { "variant" to variant }, javaVersion?.let { "java" to javaVersion }, diff --git a/.github/workflows/docs-pr.main.kts b/.github/workflows/docs-pr.main.kts index 0f60290eb6..5cdab7973f 100755 --- a/.github/workflows/docs-pr.main.kts +++ b/.github/workflows/docs-pr.main.kts @@ -28,7 +28,6 @@ import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.writeToFile workflow( name = "Verify Docs", @@ -42,7 +41,7 @@ workflow( PullRequest(), MergeGroup() ), - sourceFile = __FILE__.toPath(), + sourceFile = __FILE__, targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml", // https://stackoverflow.com/a/72408109/16358266 concurrency = Concurrency( @@ -93,4 +92,4 @@ workflow( ) ) } -}.writeToFile() +} diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index 0fac7efb2d..fea0eaac0a 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -25,7 +25,6 @@ import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.writeToFile workflow( name = "Validate Gradle Wrapper", @@ -34,7 +33,7 @@ workflow( PullRequest(), MergeGroup() ), - sourceFile = __FILE__.toPath(), + sourceFile = __FILE__, targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" ) { job( @@ -51,4 +50,4 @@ workflow( action = WrapperValidationActionV2(_customVersion = "v3") ) } -}.writeToFile() +} diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index c71a78edc2..d660ffaa95 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -27,7 +27,6 @@ import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets import io.github.typesafegithub.workflows.dsl.expressions.expr import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.writeToFile workflow( name = "Build and Release Spock", @@ -37,7 +36,7 @@ workflow( tags = listOf("spock-*") ) ), - sourceFile = __FILE__.toPath(), + sourceFile = __FILE__, targetFileName = "${__FILE__.name.substringBeforeLast(".main.kts")}.yml" ) { val GITHUB_TOKEN by secrets @@ -122,7 +121,7 @@ workflow( """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", "-Dscan.tag.main-publish" ).joinToString(" "), - env = linkedMapOf( + env = mutableMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN), "SONATYPE_OSS_USER" to expr(SONATYPE_OSS_USER), "SONATYPE_OSS_PASSWORD" to expr(SONATYPE_OSS_PASSWORD), @@ -135,7 +134,7 @@ workflow( name = "Publish Release Docs", runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)), needs = listOf(releaseSpock), - strategyMatrix = linkedMapOf( + strategyMatrix = mapOf( // docs need the highest variant "variant" to Matrix.axes.variants.takeLast(1), // docs need the highest java version @@ -172,9 +171,9 @@ workflow( """"-DjavaVersion=${expr(Matrix.javaVersion)}"""", "-Dscan.tag.main-docs" ).joinToString(" "), - env = linkedMapOf( + env = mutableMapOf( "GITHUB_TOKEN" to expr(GITHUB_TOKEN) ).apply { putAll(commonCredentials) } ) } -}.writeToFile() +} From 1520e8d6096304b5ad3a1e4de00015253710c9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Sun, 4 Aug 2024 04:40:49 +0200 Subject: [PATCH 28/30] Update github-workflows-kt version to 2.3.0 and Maven-based bindings --- .github/workflows/branches-and-prs.main.kts | 16 ++++++++++------ .github/workflows/codeql-analysis.main.kts | 19 +++++++++++-------- .github/workflows/common.main.kts | 3 ++- .github/workflows/docs-pr.main.kts | 14 +++++++++----- .../gradle-wrapper-validation.main.kts | 11 +++++++---- .github/workflows/release.main.kts | 17 ++++++++++------- 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 0d21351ef4..849dac6f68 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -17,9 +17,13 @@ */ @file:Import("common.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("codecov:codecov-action:v4") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV4 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.actions.Checkout.FetchDepth +import io.github.typesafegithub.workflows.actions.codecov.CodecovAction import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest @@ -57,7 +61,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4() + action = Checkout() ) run( name = "Regenerate all workflow YAMLs and check for modifications", @@ -75,9 +79,9 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4( + action = Checkout( // Codecov needs fetch-depth > 1 - fetchDepth = CheckoutV4.FetchDepth.Value(2) + fetchDepth = FetchDepth.Value(2) ) ) uses( @@ -100,7 +104,7 @@ workflow( ) uses( name = "Upload to Codecov.io", - action = CodecovActionV4() + action = CodecovAction() ) } } diff --git a/.github/workflows/codeql-analysis.main.kts b/.github/workflows/codeql-analysis.main.kts index f03d00fa04..1c9e1e5562 100755 --- a/.github/workflows/codeql-analysis.main.kts +++ b/.github/workflows/codeql-analysis.main.kts @@ -17,10 +17,14 @@ */ @file:Import("common.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("github:codeql-action__analyze:v3") +@file:DependsOn("github:codeql-action__init:v3") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyzeV2 -import io.github.typesafegithub.workflows.actions.github.CodeqlActionInitV2 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.github.CodeqlActionAnalyze +import io.github.typesafegithub.workflows.actions.github.CodeqlActionInit import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.Cron @@ -71,7 +75,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4() + action = Checkout() ) // Manually added: Install and setup JDK uses( @@ -81,8 +85,7 @@ workflow( // Initializes the CodeQL tools for scanning uses( name = "Initialize CodeQL", - action = CodeqlActionInitV2( - _customVersion = "v3" + action = CodeqlActionInit( // Override language selection by uncommenting this and choosing your languages // languages = listOf("go", "javascript", "csharp", "python", "cpp", "java"), ) @@ -91,7 +94,7 @@ workflow( // If this step fails, then you should remove it and run the build manually (see below). // uses( // name = "Autobuild", - // action = CodeqlActionAutobuildV2() + // action = CodeqlActionAutobuild() // ) // // ℹī¸ Command-line programs to run using the OS shell. @@ -123,7 +126,7 @@ workflow( ) uses( name = "Perform CodeQL Analysis", - action = CodeqlActionAnalyzeV2(_customVersion = "v3") + action = CodeqlActionAnalyze() ) } } diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts index bc1058b04a..6bbb90052d 100755 --- a/.github/workflows/common.main.kts +++ b/.github/workflows/common.main.kts @@ -16,7 +16,8 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0") +@file:Repository("https://repo.maven.apache.org/maven2/") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.3.0") import io.github.typesafegithub.workflows.domain.Job import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY diff --git a/.github/workflows/docs-pr.main.kts b/.github/workflows/docs-pr.main.kts index 5cdab7973f..1334f7566f 100755 --- a/.github/workflows/docs-pr.main.kts +++ b/.github/workflows/docs-pr.main.kts @@ -17,9 +17,13 @@ */ @file:Import("common.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("actions:upload-artifact:v4") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.actions.UploadArtifactV4 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.actions.Checkout.FetchDepth +import io.github.typesafegithub.workflows.actions.actions.UploadArtifact import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.MergeGroup @@ -56,8 +60,8 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4( - fetchDepth = CheckoutV4.FetchDepth.Value(1) + action = Checkout( + fetchDepth = FetchDepth.Value(1) ) ) uses( @@ -83,7 +87,7 @@ workflow( ) uses( name = "Archive and upload docs", - action = UploadArtifactV4( + action = UploadArtifact( name = "docs", path = listOf( "build/docs/**", diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/gradle-wrapper-validation.main.kts index fea0eaac0a..52a2718f50 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/gradle-wrapper-validation.main.kts @@ -17,9 +17,12 @@ */ @file:Import("common.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("gradle:wrapper-validation-action:v3") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV2 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationAction import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.MergeGroup import io.github.typesafegithub.workflows.domain.triggers.PullRequest @@ -43,11 +46,11 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4() + action = Checkout() ) uses( name = "Validate Wrapper", - action = WrapperValidationActionV2(_customVersion = "v3") + action = WrapperValidationAction() ) } } diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index d660ffaa95..d3e052a9bf 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -17,10 +17,13 @@ */ @file:Import("common.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("codecov:codecov-action:v4") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4.FetchDepth -import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV4 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.actions.Checkout.FetchDepth +import io.github.typesafegithub.workflows.actions.codecov.CodecovAction import io.github.typesafegithub.workflows.domain.RunnerType import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github @@ -55,7 +58,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4( + action = Checkout( // Codecov needs fetch-depth > 1 fetchDepth = FetchDepth.Value(2) ) @@ -84,7 +87,7 @@ workflow( ) uses( name = "Upload to Codecov.io", - action = CodecovActionV4() + action = CodecovAction() ) } val releaseSpock = job( @@ -102,7 +105,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4() + action = Checkout() ) uses( name = "Set up JDKs", @@ -144,7 +147,7 @@ workflow( ) { uses( name = "Checkout Repository", - action = CheckoutV4() + action = Checkout() ) uses( name = "Set up JDKs", From 2ffa40180fedff5bffd7bb1ce45e41a3055cecc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 8 Aug 2024 22:41:25 +0200 Subject: [PATCH 29/30] Fix typo in workflow readme --- .github/workflows/README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/README.adoc b/.github/workflows/README.adoc index 0e9514a6a2..379f4b1171 100644 --- a/.github/workflows/README.adoc +++ b/.github/workflows/README.adoc @@ -83,7 +83,7 @@ We use `@file:Import` to reduce code duplication by having common code in a comm Unfortunately, this triggers a Kotlin bug where the compilation cache becomes confused if the imported file is changed without the importing file being changed too. + -If only the imported file is changed, it could happen that a old version is used, +If only the imported file is changed, it could happen that an old version is used, or it could also happen that classes added by a `@file:DependsOn` in the imported file are not available to the importing file. So if there was a change in the imported file, you either need to also change the importing file, or to properly execute the script, From 9ad73eb9c19bb7f79942e7c1dfb5b75f7953cb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 12 Aug 2024 13:46:50 +0200 Subject: [PATCH 30/30] Improve all-workflows consistency check --- .github/workflows/branches-and-prs.main.kts | 13 ++++++++++--- .github/workflows/branches-and-prs.yml | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 849dac6f68..b1e519b4b3 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -56,7 +56,7 @@ workflow( ) { job( id = "check_all_workflow_yaml_consistency", - name = "Check all Workflow YAML consistency", + name = "Check all Workflow YAML Consistency", runsOn = UbuntuLatest ) { uses( @@ -64,8 +64,15 @@ workflow( action = Checkout() ) run( - name = "Regenerate all workflow YAMLs and check for modifications", - command = """find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c '{} && git diff --exit-code'""" + name = "Regenerate all Workflow YAMLs", + command = """find .github/workflows -mindepth 1 -maxdepth 1 -name '*.main.kts' -exec {} \;""" + ) + run( + name = "Check for Modifications", + command = """ + git add --intent-to-add . + git diff --exit-code + """.trimIndent() ) } diff --git a/.github/workflows/branches-and-prs.yml b/.github/workflows/branches-and-prs.yml index 251d67e7e5..11187c2024 100644 --- a/.github/workflows/branches-and-prs.yml +++ b/.github/workflows/branches-and-prs.yml @@ -28,7 +28,7 @@ jobs: name: 'Consistency check' run: 'git diff --exit-code ''.github/workflows/branches-and-prs.yml''' check_all_workflow_yaml_consistency: - name: 'Check all Workflow YAML consistency' + name: 'Check all Workflow YAML Consistency' runs-on: 'ubuntu-latest' needs: - 'check_yaml_consistency' @@ -37,8 +37,13 @@ jobs: name: 'Checkout Repository' uses: 'actions/checkout@v4' - id: 'step-1' - name: 'Regenerate all workflow YAMLs and check for modifications' - run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name "*.main.kts" | xargs -ri sh -c ''{} && git diff --exit-code''' + name: 'Regenerate all Workflow YAMLs' + run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name ''*.main.kts'' -exec {} \;' + - id: 'step-2' + name: 'Check for Modifications' + run: |- + git add --intent-to-add . + git diff --exit-code build-and-verify: name: 'Build and Verify' runs-on: '${{ matrix.os }}'