Skip to content

Commit bebc618

Browse files
committed
Refactor GHA workflows to share more code and report on test results.
1 parent 7a17aa0 commit bebc618

File tree

7 files changed

+185
-98
lines changed

7 files changed

+185
-98
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Setup Build Environment'
2+
description: 'Sets up Java, Elixir, and Gradle for IntelliJ plugin builds'
3+
inputs:
4+
elixir-version:
5+
description: 'Elixir version'
6+
required: false
7+
default: '1.13.4'
8+
otp-version:
9+
description: 'OTP version'
10+
required: false
11+
default: '24.3.4.6'
12+
idea-version:
13+
description: 'IntelliJ IDEA version'
14+
required: false
15+
default: ''
16+
skip-gradle-cache:
17+
description: 'Skip Gradle cache'
18+
required: false
19+
default: 'false'
20+
skip-jcef:
21+
description: 'Skip JCEF package (set to true for release/verifyPlugin jobs)'
22+
required: false
23+
default: 'false'
24+
25+
runs:
26+
using: composite
27+
steps:
28+
- name: Setup JBR 21
29+
uses: actions/setup-java@v5
30+
with:
31+
distribution: 'jetbrains'
32+
java-version: 21
33+
java-package: ${{ inputs.skip-jcef == 'false' && 'jdk+jcef' || 'jdk' }}
34+
35+
- name: Setup Gradle
36+
uses: gradle/actions/setup-gradle@v5
37+
38+
- name: Set up Elixir
39+
env:
40+
ImageOS: ubuntu22
41+
if: ${{ inputs.elixir-version != '' }}
42+
uses: erlef/setup-beam@v1
43+
with:
44+
otp-version: ${{ inputs.otp-version }}
45+
elixir-version: ${{ inputs.elixir-version }}
46+
47+
- name: Export environment variables
48+
shell: bash
49+
run: |
50+
if [ -n "${{ inputs.elixir-version }}" ]; then
51+
echo "OTP_RELEASE=${{ inputs.otp-version }}" >> $GITHUB_ENV
52+
echo "ERLANG_SDK_HOME=$(erl -eval 'io:format("~s", [code:root_dir()]).' -noshell -run init stop)" >> $GITHUB_ENV
53+
fi
54+
chmod +x gradlew
55+
if [ -n "${{ inputs.idea-version }}" ]; then
56+
echo "ORG_GRADLE_PROJECT_ideaVersion=${{ inputs.idea-version }}" >> $GITHUB_ENV
57+
fi

.github/actions/setup-jbr/action.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/publish-canary.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ jobs:
1111
- name: Check out repository 💾
1212
uses: actions/checkout@v5
1313

14-
- name: Setup JetBrains Runtime (JBR) ☕
15-
uses: ./.github/actions/setup-jbr
14+
- name: Setup Build Environment ☕
15+
uses: ./.github/actions/setup-env
16+
with:
17+
elixir-version: ''
1618

1719
- name: Download release asset 📦
1820
id: download_asset

.github/workflows/release.yml

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,43 @@ on:
66
- main
77

88
jobs:
9-
test:
10-
runs-on: ubuntu-latest
9+
test-and-verify:
10+
uses: ./.github/workflows/shared-test.yml
11+
with:
12+
elixir-version: '1.13.4'
13+
otp-version: '24.3.4.6'
1114

12-
steps:
13-
- uses: actions/checkout@v5
14-
- name: Setup JetBrains Runtime (JBR)
15-
uses: ./.github/actions/setup-jbr
16-
- name: Set up Elixir
17-
uses: erlef/setup-beam@v1
18-
with:
19-
otp-version: 24.3.4.6
20-
elixir-version: 1.13.0
21-
- name: Export OTP_RELEASE
22-
run: echo "OTP_RELEASE=24.3.4.6" >> $GITHUB_ENV
23-
- name: Export ERLANG_SDK_HOME
24-
run: echo "ERLANG_SDK_HOME=`erl -eval 'io:format("~s", [code:root_dir()]).' -noshell -run init stop`" >> $GITHUB_ENV
25-
- name: Grant execute permission for gradlew
26-
run: chmod +x gradlew
27-
- name: Compile Tests with Gradle
28-
run: ./gradlew --stacktrace compileTestJava
29-
- name: Get Elixir Source
30-
run: ./gradlew --stacktrace getElixir
31-
- name: Release Quoter
32-
run: ./gradlew --stacktrace releaseQuoter
33-
- name: Test with Gradle
34-
run: ./gradlew --stacktrace test
35-
verifyPlugin:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v5
39-
- name: Setup JetBrains Runtime (JBR)
40-
uses: ./.github/actions/setup-jbr
41-
- name: Grant execute permission for gradlew
42-
run: chmod +x gradlew
43-
- name: Run Plugin Verifier
44-
run: ./gradlew --stacktrace verifyPlugin
4515
release:
46-
needs: [ test, verifyPlugin ]
16+
needs: [ test-and-verify ]
4717
runs-on: ubuntu-latest
4818
steps:
4919
- uses: actions/checkout@v5
50-
- name: Setup JetBrains Runtime (JBR)
51-
uses: ./.github/actions/setup-jbr
52-
- name: Grant execute permission for gradlew
53-
run: chmod +x gradlew
20+
21+
- name: Setup Build Environment
22+
uses: ./.github/actions/setup-env
23+
with:
24+
elixir-version: ''
25+
skip-jcef: 'true'
26+
5427
- name: Build with Gradle
5528
run: ./gradlew buildPlugin
29+
5630
- name: Export ASSET_PATH
57-
run: echo "ASSET_PATH=`ls -1 build/distributions/intellij-elixir-*.zip`" >> $GITHUB_ENV
31+
run: echo "ASSET_PATH=$(ls -1 build/distributions/intellij-elixir-*.zip)" >> $GITHUB_ENV
32+
5833
- name: Export ASSET_NAME
5934
run: echo "ASSET_NAME=${ASSET_PATH#build/distributions/}" >> $GITHUB_ENV
35+
6036
- name: Export TAG
6137
run: |
6238
version_suffix_zip=${ASSET_NAME#intellij-elixir-}
6339
echo "TAG=v${version_suffix_zip%.zip}" >> $GITHUB_ENV
40+
6441
- name: Tag Commit
6542
uses: hole19/git-tag-action@master
6643
env:
67-
# TAG set above with `set-env name=TAG`
6844
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
6946
- name: Create Release
7047
id: create_release
7148
uses: actions/create-release@latest
@@ -75,6 +52,7 @@ jobs:
7552
tag_name: ${{ env.TAG }}
7653
release_name: ${{ env.TAG }}
7754
prerelease: true
55+
7856
- name: Upload Release Asset
7957
uses: actions/upload-release-asset@v1
8058
env:

.github/workflows/shared-test.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Shared Test Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
elixir-version:
7+
description: 'Elixir version to use'
8+
required: false
9+
type: string
10+
default: '1.13.4'
11+
otp-version:
12+
description: 'OTP version to use'
13+
required: false
14+
type: string
15+
default: '24.3.4.6'
16+
idea-version:
17+
description: 'IntelliJ IDEA version for testing'
18+
required: false
19+
type: string
20+
default: '253.28294.169'
21+
upload-reports:
22+
description: 'Upload test reports as artifacts'
23+
required: false
24+
type: boolean
25+
default: false
26+
27+
jobs:
28+
test:
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- uses: actions/checkout@v5
33+
34+
- name: Setup Build Environment
35+
uses: ./.github/actions/setup-env
36+
with:
37+
elixir-version: ${{ inputs.elixir-version }}
38+
otp-version: ${{ inputs.otp-version }}
39+
idea-version: ${{ inputs.idea-version }}
40+
41+
- name: Compile Tests with Gradle
42+
run: ./gradlew --stacktrace compileTestJava
43+
44+
- name: Get Elixir Source
45+
run: ./gradlew --stacktrace getElixir
46+
47+
- name: Release Quoter
48+
run: ./gradlew --stacktrace releaseQuoter
49+
50+
- name: Test with Gradle
51+
run: ./gradlew --stacktrace test
52+
53+
- name: Publish Test Results
54+
uses: EnricoMi/publish-unit-test-result-action@v2
55+
if: always()
56+
with:
57+
files: '**/build/test-results/**/*.xml'
58+
check_name: Test Results
59+
60+
- name: Upload Test Reports
61+
uses: actions/upload-artifact@v4
62+
if: ${{ always() && inputs.upload-reports }}
63+
with:
64+
name: test-reports
65+
path: |
66+
**/build/reports/tests/**
67+
**/build/test-results/**
68+
retention-days: 30
69+
70+
verifyPlugin:
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- uses: actions/checkout@v5
75+
76+
- name: Setup Build Environment
77+
uses: ./.github/actions/setup-env
78+
with:
79+
elixir-version: ''
80+
81+
- name: Run Plugin Verifier
82+
run: ./gradlew --stacktrace verifyPlugin

.github/workflows/test.yml

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,10 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10-
test:
11-
runs-on: ubuntu-latest
12-
13-
strategy:
14-
matrix:
15-
ideaVersion: [ "2024.3.6" ]
16-
17-
steps:
18-
- uses: actions/checkout@v5
19-
- name: Setup JetBrains Runtime (JBR)
20-
uses: ./.github/actions/setup-jbr
21-
- name: Set up Elixir
22-
uses: erlef/setup-beam@v1
23-
with:
24-
otp-version: 24.3.4.6
25-
elixir-version: 1.13.4
26-
- name: Export OTP_RELEASE
27-
run: echo "OTP_RELEASE=24.3.4.6" >> $GITHUB_ENV
28-
- name: Export ERLANG_SDK_HOME
29-
run: echo "ERLANG_SDK_HOME=`erl -eval 'io:format("~s", [code:root_dir()]).' -noshell -run init stop`" >> $GITHUB_ENV
30-
- name: Grant execute permission for gradlew
31-
run: chmod +x gradlew
32-
- name: Export ideaVersion to gradle
33-
run: echo "ORG_GRADLE_PROJECT_ideaVersion=${{matrix.ideaVersion}}" >> $GITHUB_ENV
34-
- name: Compile Tests with Gradle
35-
run: ./gradlew --stacktrace compileTestJava
36-
- name: Get Elixir Source
37-
run: ./gradlew --stacktrace getElixir
38-
- name: Release Quoter
39-
run: ./gradlew --stacktrace releaseQuoter
40-
- name: Test with Gradle
41-
run: ./gradlew --stacktrace test
42-
verifyPlugin:
43-
runs-on: ubuntu-latest
44-
45-
steps:
46-
- uses: actions/checkout@v5
47-
- name: Setup JetBrains Runtime (JBR)
48-
uses: ./.github/actions/setup-jbr
49-
- name: Grant execute permission for gradlew
50-
run: chmod +x gradlew
51-
- name: Run Plugin Verifier
52-
run: ./gradlew --stacktrace verifyPlugin
10+
test-and-verify:
11+
uses: ./.github/workflows/shared-test.yml
12+
with:
13+
elixir-version: '1.13.4'
14+
otp-version: '24.3.4.6'
15+
idea-version: '2024.3.6'
16+
upload-reports: true

build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,21 @@ tasks.named<Test>("test") {
309309
}
310310
}
311311

312+
// Configure test-logger plugin for better console output
313+
testlogger {
314+
theme = com.adarshr.gradle.testlogger.theme.ThemeType.MOCHA
315+
showExceptions = true
316+
showStackTraces = true
317+
showFullStackTraces = false
318+
showCauses = true
319+
slowThreshold = 2000
320+
showSummary = true
321+
showStandardStreams = false
322+
showPassedStandardStreams = false
323+
showSkippedStandardStreams = false
324+
showFailedStandardStreams = true
325+
}
326+
312327
// Get the list of platforms from gradle.properties
313328
val runIdePlatformsList = providers.gradleProperty("runIdePlatforms").get().split(",")
314329

0 commit comments

Comments
 (0)