Skip to content

Commit 9c2ca8f

Browse files
committed
1 parent f552c34 commit 9c2ca8f

3 files changed

Lines changed: 236 additions & 126 deletions

File tree

.github/workflows/build.yml

Lines changed: 173 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,228 @@
1-
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2-
# - validate Gradle Wrapper,
3-
# - run 'test' and 'verifyPlugin' tasks,
4-
# - run Qodana inspections,
5-
# - run 'buildPlugin' task and prepare artifact for the further tests,
6-
# - run 'runPluginVerifier' task,
7-
# - create a draft release.
1+
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
2+
# - Validate Gradle Wrapper.
3+
# - Run 'test' and 'verifyPlugin' tasks.
4+
# - Run Qodana inspections.
5+
# - Run the 'buildPlugin' task and prepare artifact for further tests.
6+
# - Run the 'runPluginVerifier' task.
7+
# - Create a draft release.
88
#
9-
# Workflow is triggered on push and pull_request events.
9+
# The workflow is triggered on push and pull_request events.
1010
#
1111
# GitHub Actions reference: https://help.github.com/en/actions
1212
#
1313
## JBIJPPTPL
1414

1515
name: Build
1616
on:
17-
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
17+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
1818
push:
19-
branches: [main]
19+
branches: [ main ]
2020
# Trigger the workflow on any pull request
2121
pull_request:
2222

23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
26+
2327
jobs:
2428

25-
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
26-
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
27-
# Build plugin and provide the artifact for the next workflow jobs
29+
# Prepare the environment and build the plugin
2830
build:
2931
name: Build
3032
runs-on: ubuntu-latest
31-
outputs:
32-
version: ${{ steps.properties.outputs.version }}
33-
changelog: ${{ steps.properties.outputs.changelog }}
3433
steps:
3534

36-
# Check out current repository
37-
- name: Fetch Sources
38-
uses: actions/checkout@v2.4.0
35+
# Free GitHub Actions Environment Disk Space
36+
- name: Maximize Build Space
37+
uses: jlumbroso/free-disk-space@v1.3.1
38+
with:
39+
tool-cache: false
40+
large-packages: false
3941

40-
# Validate wrapper
41-
- name: Gradle Wrapper Validation
42-
uses: gradle/wrapper-validation-action@v1.0.4
42+
# Check out the current repository
43+
- name: Fetch Sources
44+
uses: actions/checkout@v5
4345

44-
# Setup Java 11 environment for the next steps
46+
# Set up the Java environment for the next steps
4547
- name: Setup Java
46-
uses: actions/setup-java@v2
48+
uses: actions/setup-java@v5
4749
with:
4850
distribution: zulu
49-
java-version: 11
50-
cache: gradle
51+
java-version: 21
52+
53+
# Setup Gradle
54+
- name: Setup Gradle
55+
uses: gradle/actions/setup-gradle@v5
5156

52-
# Set environment variables
53-
- name: Export Properties
54-
id: properties
57+
# Build plugin
58+
- name: Build plugin
59+
run: ./gradlew buildPlugin
60+
61+
# Prepare plugin archive content for creating artifact
62+
- name: Prepare Plugin Artifact
63+
id: artifact
5564
shell: bash
5665
run: |
57-
PROPERTIES="$(./gradlew properties --console=plain -q)"
58-
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
59-
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
60-
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
61-
CHANGELOG="${CHANGELOG//'%'/'%25'}"
62-
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
63-
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
66+
cd ${{ github.workspace }}/build/distributions
67+
FILENAME=`ls *.zip`
68+
unzip "$FILENAME" -d content
69+
70+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
71+
72+
# Store an already-built plugin as an artifact for downloading
73+
- name: Upload artifact
74+
uses: actions/upload-artifact@v5
75+
with:
76+
name: ${{ steps.artifact.outputs.filename }}
77+
path: ./build/distributions/content/*/*
6478

65-
echo "::set-output name=version::$VERSION"
66-
echo "::set-output name=name::$NAME"
67-
echo "::set-output name=changelog::$CHANGELOG"
68-
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
79+
# Run tests and upload a code coverage report
80+
test:
81+
name: Test
82+
needs: [ build ]
83+
runs-on: ubuntu-latest
84+
steps:
85+
86+
# Free GitHub Actions Environment Disk Space
87+
- name: Maximize Build Space
88+
uses: jlumbroso/free-disk-space@v1.3.1
89+
with:
90+
tool-cache: false
91+
large-packages: false
92+
93+
# Check out the current repository
94+
- name: Fetch Sources
95+
uses: actions/checkout@v5
96+
97+
# Set up the Java environment for the next steps
98+
- name: Setup Java
99+
uses: actions/setup-java@v5
100+
with:
101+
distribution: zulu
102+
java-version: 21
69103

70-
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
104+
# Setup Gradle
105+
- name: Setup Gradle
106+
uses: gradle/actions/setup-gradle@v5
107+
with:
108+
cache-read-only: true
71109

72110
# Run tests
73111
- name: Run Tests
74-
run: ./gradlew test
112+
run: ./gradlew check
75113

76114
# Collect Tests Result of failed tests
77115
- name: Collect Tests Result
78116
if: ${{ failure() }}
79-
uses: actions/upload-artifact@v2
117+
uses: actions/upload-artifact@v5
80118
with:
81119
name: tests-result
82120
path: ${{ github.workspace }}/build/reports/tests
83121

84-
# Cache Plugin Verifier IDEs
85-
- name: Setup Plugin Verifier IDEs Cache
86-
uses: actions/cache@v2.1.7
122+
# Upload the Kover report to CodeCov
123+
- name: Upload Code Coverage Report
124+
uses: codecov/codecov-action@v5
125+
with:
126+
files: ${{ github.workspace }}/build/reports/kover/report.xml
127+
token: ${{ secrets.CODECOV_TOKEN }}
128+
129+
# Run Qodana inspections and provide a report
130+
inspectCode:
131+
name: Inspect code
132+
needs: [ build ]
133+
runs-on: ubuntu-latest
134+
permissions:
135+
contents: write
136+
checks: write
137+
pull-requests: write
138+
steps:
139+
140+
# Free GitHub Actions Environment Disk Space
141+
- name: Maximize Build Space
142+
uses: jlumbroso/free-disk-space@v1.3.1
143+
with:
144+
tool-cache: false
145+
large-packages: false
146+
147+
# Check out the current repository
148+
- name: Fetch Sources
149+
uses: actions/checkout@v5
150+
with:
151+
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
152+
fetch-depth: 0 # a full history is required for pull request analysis
153+
154+
# Set up the Java environment for the next steps
155+
- name: Setup Java
156+
uses: actions/setup-java@v5
157+
with:
158+
distribution: zulu
159+
java-version: 21
160+
161+
# Run Qodana inspections
162+
- name: Qodana - Code Inspection
163+
uses: JetBrains/qodana-action@v2025.1.1
164+
with:
165+
cache-default-branch-only: true
166+
167+
# Run plugin structure verification along with IntelliJ Plugin Verifier
168+
verify:
169+
name: Verify plugin
170+
needs: [ build ]
171+
runs-on: ubuntu-latest
172+
steps:
173+
174+
# Free GitHub Actions Environment Disk Space
175+
- name: Maximize Build Space
176+
uses: jlumbroso/free-disk-space@v1.3.1
177+
with:
178+
tool-cache: false
179+
large-packages: false
180+
181+
# Check out the current repository
182+
- name: Fetch Sources
183+
uses: actions/checkout@v5
184+
185+
# Set up the Java environment for the next steps
186+
- name: Setup Java
187+
uses: actions/setup-java@v5
188+
with:
189+
distribution: zulu
190+
java-version: 21
191+
192+
# Setup Gradle
193+
- name: Setup Gradle
194+
uses: gradle/actions/setup-gradle@v5
87195
with:
88-
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
89-
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
196+
cache-read-only: true
90197

91198
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
92199
- name: Run Plugin Verification tasks
93-
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
200+
run: ./gradlew verifyPlugin
94201

95202
# Collect Plugin Verifier Result
96203
- name: Collect Plugin Verifier Result
97204
if: ${{ always() }}
98-
uses: actions/upload-artifact@v2
205+
uses: actions/upload-artifact@v5
99206
with:
100207
name: pluginVerifier-result
101208
path: ${{ github.workspace }}/build/reports/pluginVerifier
102209

103-
# Prepare plugin archive content for creating artifact
104-
- name: Prepare Plugin Artifact
105-
id: artifact
106-
shell: bash
107-
run: |
108-
cd ${{ github.workspace }}/build/distributions
109-
FILENAME=`ls *.zip`
110-
unzip "$FILENAME" -d content
111-
112-
echo "::set-output name=filename::${FILENAME:0:-4}"
113-
114-
# Store already-built plugin as an artifact for downloading
115-
- name: Upload artifact
116-
uses: actions/upload-artifact@v2.2.4
117-
with:
118-
name: ${{ steps.artifact.outputs.filename }}
119-
path: ./build/distributions/content/*/*
120-
121210
# Prepare a draft release for GitHub Releases page for the manual verification
122-
# If accepted and published, release workflow would be triggered
211+
# If accepted and published, the release workflow would be triggered
123212
releaseDraft:
124-
name: Release Draft
213+
name: Release draft
125214
if: github.event_name != 'pull_request'
126-
needs: build
215+
needs: [ build, test, inspectCode, verify ]
127216
runs-on: ubuntu-latest
217+
permissions:
218+
contents: write
128219
steps:
129220

130-
# Check out current repository
221+
# Check out the current repository
131222
- name: Fetch Sources
132-
uses: actions/checkout@v2.4.0
223+
uses: actions/checkout@v5
133224

134-
# Remove old release drafts by using the curl request for the available releases with draft flag
225+
# Remove old release drafts by using the curl request for the available releases with a draft flag
135226
- name: Remove Old Release Drafts
136227
env:
137228
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -140,15 +231,16 @@ jobs:
140231
--jq '.[] | select(.draft == true) | .id' \
141232
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
142233
143-
# Create new release draft - which is not publicly visible and requires manual acceptance
234+
# Create a new release draft which is not publicly visible and requires manual acceptance
144235
- name: Create Release Draft
145236
env:
146237
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147238
run: |
148-
gh release create v${{ needs.build.outputs.version }} \
239+
VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ')
240+
RELEASE_NOTE="./build/tmp/release_note.txt"
241+
./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE
242+
243+
gh release create $VERSION \
149244
--draft \
150-
--title "v${{ needs.build.outputs.version }}" \
151-
--notes "$(cat << 'EOM'
152-
${{ needs.build.outputs.changelog }}
153-
EOM
154-
)"
245+
--title $VERSION \
246+
--notes-file $RELEASE_NOTE

0 commit comments

Comments
 (0)