Skip to content

Commit faba29d

Browse files
committed
upgrade build workflow
1 parent 88ee92a commit faba29d

File tree

1 file changed

+148
-63
lines changed

1 file changed

+148
-63
lines changed

.github/workflows/build.yml

Lines changed: 148 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,123 @@
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: [master]
19+
branches: [ master ]
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 environment and build the plugin
2830
build:
2931
name: Build
3032
runs-on: ubuntu-latest
3133
outputs:
3234
version: ${{ steps.properties.outputs.version }}
3335
changelog: ${{ steps.properties.outputs.changelog }}
36+
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
3437
steps:
3538

36-
37-
38-
# Check out current repository
39+
# Check out the current repository
3940
- name: Fetch Sources
4041
uses: actions/checkout@v4
4142

4243
# Validate wrapper
4344
- name: Gradle Wrapper Validation
44-
uses: gradle/wrapper-validation-action@v3
45+
uses: gradle/actions/wrapper-validation@v3
4546

46-
# Setup Java 17 environment for the next steps
47+
# Set up Java environment for the next steps
4748
- name: Setup Java
4849
uses: actions/setup-java@v4
4950
with:
5051
distribution: zulu
5152
java-version: 17
5253

54+
# Setup Gradle
55+
- name: Setup Gradle
56+
uses: gradle/actions/setup-gradle@v4
57+
5358
# Set environment variables
5459
- name: Export Properties
5560
id: properties
5661
shell: bash
5762
run: |
5863
PROPERTIES="$(./gradlew properties --console=plain -q)"
5964
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
60-
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
6165
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
62-
CHANGELOG="${CHANGELOG//'%'/'%25'}"
63-
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
64-
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
6566
66-
echo "::set-output name=version::$VERSION"
67-
echo "::set-output name=name::$NAME"
68-
echo "::set-output name=changelog::$CHANGELOG"
69-
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
67+
echo "version=$VERSION" >> $GITHUB_OUTPUT
68+
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
69+
70+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
71+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
72+
echo "EOF" >> $GITHUB_OUTPUT
73+
74+
# Build plugin
75+
- name: Build plugin
76+
run: ./gradlew buildPlugin
77+
78+
# Prepare plugin archive content for creating artifact
79+
- name: Prepare Plugin Artifact
80+
id: artifact
81+
shell: bash
82+
run: |
83+
cd ${{ github.workspace }}/build/distributions
84+
FILENAME=`ls *.zip`
85+
unzip "$FILENAME" -d content
86+
87+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
88+
89+
# Store already-built plugin as an artifact for downloading
90+
- name: Upload artifact
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: ${{ steps.artifact.outputs.filename }}
94+
path: ./build/distributions/content/*/*
95+
96+
# Run tests and upload a code coverage report
97+
test:
98+
name: Test
99+
needs: [ build ]
100+
runs-on: ubuntu-latest
101+
steps:
102+
103+
# Check out the current repository
104+
- name: Fetch Sources
105+
uses: actions/checkout@v4
70106

71-
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
107+
# Set up Java environment for the next steps
108+
- name: Setup Java
109+
uses: actions/setup-java@v4
110+
with:
111+
distribution: zulu
112+
java-version: 17
113+
114+
# Setup Gradle
115+
- name: Setup Gradle
116+
uses: gradle/actions/setup-gradle@v4
72117

73118
# Run tests
74119
- name: Run Tests
75-
run: ./gradlew test
120+
run: ./gradlew check
76121

77122
# Collect Tests Result of failed tests
78123
- name: Collect Tests Result
@@ -82,31 +127,89 @@ jobs:
82127
name: tests-result
83128
path: ${{ github.workspace }}/build/reports/tests
84129

130+
# Upload the Kover report to CodeCov
131+
- name: Upload Code Coverage Report
132+
uses: codecov/codecov-action@v4
133+
with:
134+
files: ${{ github.workspace }}/build/reports/kover/report.xml
135+
136+
# Run Qodana inspections and provide report
137+
inspectCode:
138+
name: Inspect code
139+
needs: [ build ]
140+
runs-on: ubuntu-latest
141+
permissions:
142+
contents: write
143+
checks: write
144+
pull-requests: write
145+
steps:
146+
85147
# Free GitHub Actions Environment Disk Space
86148
- name: Maximize Build Space
87-
uses: jlumbroso/free-disk-space@v1.3.1
149+
uses: jlumbroso/free-disk-space@main
88150
with:
89151
tool-cache: false
90152
large-packages: false
91153

92-
- name: Clean up disk space
93-
run: |
94-
sudo rm -rf /usr/share/dotnet
95-
sudo rm -rf /usr/local/lib/android
96-
sudo rm -rf /opt/ghc
154+
# Check out the current repository
155+
- name: Fetch Sources
156+
uses: actions/checkout@v4
157+
with:
158+
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
159+
fetch-depth: 0 # a full history is required for pull request analysis
160+
161+
# Set up Java environment for the next steps
162+
- name: Setup Java
163+
uses: actions/setup-java@v4
164+
with:
165+
distribution: zulu
166+
java-version: 17
167+
168+
# Run Qodana inspections
169+
- name: Qodana - Code Inspection
170+
uses: JetBrains/[email protected]
171+
with:
172+
cache-default-branch-only: true
173+
174+
# Run plugin structure verification along with IntelliJ Plugin Verifier
175+
verify:
176+
name: Verify plugin
177+
needs: [ build ]
178+
runs-on: ubuntu-latest
179+
steps:
180+
181+
# Free GitHub Actions Environment Disk Space
182+
- name: Maximize Build Space
183+
uses: jlumbroso/free-disk-space@main
184+
with:
185+
tool-cache: false
186+
large-packages: false
187+
188+
# Check out the current repository
189+
- name: Fetch Sources
190+
uses: actions/checkout@v4
191+
192+
# Set up Java environment for the next steps
193+
- name: Setup Java
194+
uses: actions/setup-java@v4
195+
with:
196+
distribution: zulu
197+
java-version: 17
198+
199+
# Setup Gradle
200+
- name: Setup Gradle
201+
uses: gradle/actions/setup-gradle@v4
97202

98203
# Cache Plugin Verifier IDEs
99204
- name: Setup Plugin Verifier IDEs Cache
100205
uses: actions/cache@v4
101206
with:
102-
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
207+
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
103208
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
104209

105210
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
106211
- name: Run Plugin Verification tasks
107-
run: |
108-
sudo df -h
109-
./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
212+
run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
110213

111214
# Collect Plugin Verifier Result
112215
- name: Collect Plugin Verifier Result
@@ -116,40 +219,22 @@ jobs:
116219
name: pluginVerifier-result
117220
path: ${{ github.workspace }}/build/reports/pluginVerifier
118221

119-
# Prepare plugin archive content for creating artifact
120-
- name: Prepare Plugin Artifact
121-
id: artifact
122-
shell: bash
123-
run: |
124-
cd ${{ github.workspace }}/build/distributions
125-
FILENAME=`ls *.zip`
126-
unzip "$FILENAME" -d content
127-
128-
echo "::set-output name=filename::${FILENAME:0:-4}"
129-
130-
# Store already-built plugin as an artifact for downloading
131-
- name: Upload artifact
132-
uses: actions/upload-artifact@v4
133-
with:
134-
name: ${{ steps.artifact.outputs.filename }}
135-
path: ./build/distributions/content/*/*
136-
137222
# Prepare a draft release for GitHub Releases page for the manual verification
138223
# If accepted and published, release workflow would be triggered
139224
releaseDraft:
140-
name: Release Draft
225+
name: Release draft
141226
if: github.event_name != 'pull_request'
142-
needs: build
227+
needs: [ build, test, inspectCode, verify ]
143228
runs-on: ubuntu-latest
144229
permissions:
145230
contents: write
146231
steps:
147232

148-
# Check out current repository
233+
# Check out the current repository
149234
- name: Fetch Sources
150235
uses: actions/checkout@v4
151236

152-
# Remove old release drafts by using the curl request for the available releases with draft flag
237+
# Remove old release drafts by using the curl request for the available releases with a draft flag
153238
- name: Remove Old Release Drafts
154239
env:
155240
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -158,15 +243,15 @@ jobs:
158243
--jq '.[] | select(.draft == true) | .id' \
159244
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
160245
161-
# Create new release draft - which is not publicly visible and requires manual acceptance
246+
# Create a new release draft which is not publicly visible and requires manual acceptance
162247
- name: Create Release Draft
163248
env:
164249
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165250
run: |
166-
gh release create v${{ needs.build.outputs.version }} \
251+
gh release create "v${{ needs.build.outputs.version }}" \
167252
--draft \
168253
--title "v${{ needs.build.outputs.version }}" \
169254
--notes "$(cat << 'EOM'
170255
${{ needs.build.outputs.changelog }}
171256
EOM
172-
)"
257+
)"

0 commit comments

Comments
 (0)