From 61143739965721ba7035a09ac2210f889e212d6a Mon Sep 17 00:00:00 2001 From: StefMa Date: Tue, 14 Jan 2025 15:34:28 +0100 Subject: [PATCH 1/3] Add pkl workflows for GitHub Action --- .../pkl-workflows/CheckActionsConverted.pkl | 37 ++++++++++ .github/pkl-workflows/Checks.pkl | 67 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 .github/pkl-workflows/CheckActionsConverted.pkl create mode 100644 .github/pkl-workflows/Checks.pkl diff --git a/.github/pkl-workflows/CheckActionsConverted.pkl b/.github/pkl-workflows/CheckActionsConverted.pkl new file mode 100644 index 000000000..40810c24a --- /dev/null +++ b/.github/pkl-workflows/CheckActionsConverted.pkl @@ -0,0 +1,37 @@ +amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.4#/GitHubAction.pkl" + +name = "Check Pkl Actions Converted" + +on { + push {} +} + +jobs { + ["check-actions-converted"] { + name = "Check Actions converted" + `runs-on` = "ubuntu-latest" + steps { + new { + name = "Checkout" + uses = "actions/checkout@v4" + } + new { + name = "Install pkl" + uses = "pkl-community/setup-pkl@v0" + with { + ["pkl-version"] = "0.27.0" + } + } + new { + name = "Convert pkl actions to yaml" + run = """ + pkl eval .github/pkl-workflows/*.pkl -o .github/workflows/%{moduleName}.generated.yml + """ + } + new { + name = "Verify if pkl actions are converted" + run = "git diff --exit-code" + } + } + } +} diff --git a/.github/pkl-workflows/Checks.pkl b/.github/pkl-workflows/Checks.pkl new file mode 100644 index 000000000..cf5cc66a3 --- /dev/null +++ b/.github/pkl-workflows/Checks.pkl @@ -0,0 +1,67 @@ +amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.4#/GitHubAction.pkl" + +name = "Checks" + +on { + push { + branches { + "main" + } + } + pull_request {} +} + +jobs { + ["gradle-checks"] { + permissions = new { + checks = "write" + } + strategy { + matrix { + ["os"] { + "ubuntu-latest" + "windows-latest" + } + ["jdk"] { + "17" + "21" + } + } + } + `runs-on` = "${{ matrix.os }}" + steps { + new { + name = "Checkout" + uses = "actions/checkout@v4" + with { + ["fetch-depth"] = 0 + } + } + new { + name = "Setup JDK" + uses = "actions/setup-java@v4" + with { + ["distribution"] = "adopt" + ["java-version"] = "${{ matrix.jdk }}" + } + } + new { + name = "Setup Gradle" + uses = "gradle/actions/setup-gradle@v4" + } + new { + name = "Gradle check" + run = "./gradlew --info --stacktrace check" + } + new { + name = "Report test results" + uses = "mikepenz/action-junit-report@v5" + `if` = "${{ always() }}" + with { + ["check_name"] = "Test Results JDK ${{ matrix.jdk }} on ${{ matrix.os }}" + ["report_paths"] = "**/build/test-results/test/*.xml" + } + } + } + } +} From 9d6888b16a6a469814b559b1bbaabc1baead34f3 Mon Sep 17 00:00:00 2001 From: StefMa Date: Wed, 15 Jan 2025 08:47:23 +0100 Subject: [PATCH 2/3] Translate pkl actions --- .../CheckActionsConverted.generated.yml | 21 ++++++++++ .github/workflows/Checks.generated.yml | 42 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/CheckActionsConverted.generated.yml create mode 100644 .github/workflows/Checks.generated.yml diff --git a/.github/workflows/CheckActionsConverted.generated.yml b/.github/workflows/CheckActionsConverted.generated.yml new file mode 100644 index 000000000..eeb7c8446 --- /dev/null +++ b/.github/workflows/CheckActionsConverted.generated.yml @@ -0,0 +1,21 @@ +# Do not modify! +# This file was generated from a template using https://github.com/StefMa/pkl-gha + +name: Check Pkl Actions Converted +'on': + push: {} +jobs: + check-actions-converted: + name: Check Actions converted + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install pkl + uses: pkl-community/setup-pkl@v0 + with: + pkl-version: 0.27.0 + - name: Convert pkl actions to yaml + run: pkl eval .github/pkl-workflows/*.pkl -o .github/workflows/%{moduleName}.generated.yml + - name: Verify if pkl actions are converted + run: git diff --exit-code diff --git a/.github/workflows/Checks.generated.yml b/.github/workflows/Checks.generated.yml new file mode 100644 index 000000000..1e460e107 --- /dev/null +++ b/.github/workflows/Checks.generated.yml @@ -0,0 +1,42 @@ +# Do not modify! +# This file was generated from a template using https://github.com/StefMa/pkl-gha + +name: Checks +'on': + pull_request: {} + push: + branches: + - main +jobs: + gradle-checks: + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + jdk: + - '17' + - '21' + permissions: + checks: write + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: adopt + java-version: ${{ matrix.jdk }} + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Gradle check + run: ./gradlew --info --stacktrace check + - name: Report test results + if: ${{ always() }} + uses: mikepenz/action-junit-report@v5 + with: + check_name: Test Results JDK ${{ matrix.jdk }} on ${{ matrix.os }} + report_paths: '**/build/test-results/test/*.xml' From 4b9994e53dbfc26dbef012755860c0063cf865fd Mon Sep 17 00:00:00 2001 From: StefMa Date: Wed, 15 Jan 2025 08:48:32 +0100 Subject: [PATCH 3/3] Demonstrate GitHub Action Run --- .github/pkl-workflows/Checks.pkl | 6 +----- .github/workflows/Checks.generated.yml | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/pkl-workflows/Checks.pkl b/.github/pkl-workflows/Checks.pkl index cf5cc66a3..2dba734c5 100644 --- a/.github/pkl-workflows/Checks.pkl +++ b/.github/pkl-workflows/Checks.pkl @@ -3,11 +3,7 @@ amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0 name = "Checks" on { - push { - branches { - "main" - } - } + push {} pull_request {} } diff --git a/.github/workflows/Checks.generated.yml b/.github/workflows/Checks.generated.yml index 1e460e107..40c354682 100644 --- a/.github/workflows/Checks.generated.yml +++ b/.github/workflows/Checks.generated.yml @@ -4,9 +4,7 @@ name: Checks 'on': pull_request: {} - push: - branches: - - main + push: {} jobs: gradle-checks: strategy: