Skip to content

Commit 3a0eff8

Browse files
committed
Action cache control and refactoring
1 parent 1cf1249 commit 3a0eff8

File tree

3 files changed

+57
-91
lines changed

3 files changed

+57
-91
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
22
# - Validate Gradle Wrapper.
33
# - Run 'test' and 'verifyPlugin' tasks.
4-
# - Run Qodana inspections.
54
# - Run the 'buildPlugin' task and prepare artifact for further tests.
65
# - Run the 'runPluginVerifier' task.
7-
# - Create a draft release.
86
#
97
# The workflow is triggered on push and pull_request events.
108
#
@@ -14,217 +12,186 @@
1412

1513
name: Build
1614
on:
17-
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
1815
push:
19-
branches: [ main ]
20-
# Trigger the workflow on any pull request
16+
branches:
17+
- 'main'
2118
pull_request:
2219

2320
concurrency:
2421
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2522
cancel-in-progress: true
26-
23+
2724
jobs:
2825

29-
# Prepare environment and build the plugin
3026
build:
3127
name: Build
3228
runs-on: ubuntu-24.04
3329
outputs:
34-
version: ${{ steps.properties.outputs.version }}
35-
changelog: ${{ steps.properties.outputs.changelog }}
3630
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
3731
steps:
38-
39-
# Check out the current repository
4032
- name: Fetch Sources
4133
uses: actions/checkout@v4
4234

43-
# Validate wrapper
4435
- name: Gradle Wrapper Validation
4536
uses: gradle/actions/wrapper-validation@v4
4637

47-
# Set up Java environment for the next steps
4838
- name: Setup Java
4939
uses: actions/setup-java@v4
5040
with:
5141
distribution: zulu
5242
java-version: 17
5343

54-
# Setup Gradle
5544
- name: Setup Gradle
5645
uses: gradle/actions/setup-gradle@v4
5746

58-
# Generate Lexer and Parser
47+
- name: Export Properties
48+
id: properties
49+
shell: bash
50+
run: |
51+
PROPERTIES="$(./gradlew properties --console=plain -q)"
52+
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
53+
54+
- name: Cache Lexer and Parser
55+
uses: actions/cache@v4
56+
id: cache-lexer-parser
57+
with:
58+
path: ${{ github.workspace }}/src/main/gen
59+
key: lexer-parser-${{ hashFiles('**/Sql.bnf','**/Sql.flex') }}
60+
restore-keys: |
61+
lexer-parser-
62+
5963
- name: Generate Lexer
64+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
6065
run: ./gradlew generateLexer
6166

6267
- name: Generate Parser
68+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
6369
run: ./gradlew generateParser
6470

65-
# Build plugin
71+
- name: Build Gradle
72+
run: ./gradlew build -x test
73+
6674
- name: Build plugin
67-
run: ./gradlew buildPlugin -PpluginVersion=0.3.1-${{ github.run_number }}
75+
run: ./gradlew buildPlugin -PpluginVersion=${{ github.run_number }}
6876

69-
# Prepare plugin archive content for creating artifact
7077
- name: Prepare Plugin Artifact
7178
id: artifact
7279
shell: bash
7380
run: |
7481
cd ${{ github.workspace }}/build/distributions
75-
FILENAME=`ls *.zip`
82+
FILENAME=$(ls *.zip)
7683
unzip "$FILENAME" -d content
77-
7884
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
7985
80-
# Store already-built plugin as an artifact for downloading
8186
- name: Upload artifact
8287
uses: actions/upload-artifact@v4
8388
with:
8489
name: ${{ steps.artifact.outputs.filename }}
8590
path: ./build/distributions/content/*/*
8691

87-
# Run tests and upload a code coverage report
8892
test:
8993
name: Test
9094
needs: [ build ]
9195
runs-on: ubuntu-24.04
9296
steps:
93-
94-
# Check out the current repository
9597
- name: Fetch Sources
9698
uses: actions/checkout@v4
9799

98-
# Set up Java environment for the next steps
99100
- name: Setup Java
100101
uses: actions/setup-java@v4
101102
with:
102103
distribution: zulu
103104
java-version: 17
104105

105-
# Setup Gradle
106106
- name: Setup Gradle
107107
uses: gradle/actions/setup-gradle@v4
108+
with:
109+
cache-read-only: true
110+
111+
- name: Cache Lexer and Parser
112+
uses: actions/cache@v4
113+
id: cache-lexer-parser
114+
with:
115+
path: ${{ github.workspace }}/src/main/gen
116+
key: lexer-parser-${{ hashFiles('**/Sql.bnf','**/Sql.flex') }}
117+
restore-keys: |
118+
lexer-parser-
108119
109-
# Generate Lexer and Parser
110120
- name: Generate Lexer
121+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
111122
run: ./gradlew generateLexer
112123

113124
- name: Generate Parser
125+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
114126
run: ./gradlew generateParser
115127

116128
# Run tests
117129
- name: Run Tests
118130
run: ./gradlew check
119131

120-
# Collect Tests Result of failed tests
121132
- name: Collect Tests Result
122133
if: ${{ failure() }}
123134
uses: actions/upload-artifact@v4
124135
with:
125136
name: tests-result
126137
path: ${{ github.workspace }}/build/reports/tests
127138

128-
# Upload the Kover report to CodeCov
129139
- name: Upload Code Coverage Report
130140
uses: codecov/codecov-action@v5
131141
with:
132142
files: ${{ github.workspace }}/build/reports/kover/report.xml
133143

134-
# Run Qodana inspections and provide report
135-
inspectCode:
136-
name: Inspect code
137-
needs: [ build ]
138-
runs-on: ubuntu-24.04
139-
permissions:
140-
contents: write
141-
checks: write
142-
pull-requests: write
143-
steps:
144-
145-
# Free GitHub Actions Environment Disk Space
146-
- name: Maximize Build Space
147-
uses: jlumbroso/free-disk-space@main
148-
with:
149-
tool-cache: false
150-
large-packages: false
151-
152-
# Check out the current repository
153-
- name: Fetch Sources
154-
uses: actions/checkout@v4
155-
with:
156-
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
157-
fetch-depth: 0 # a full history is required for pull request analysis
158-
159-
# Set up Java environment for the next steps
160-
- name: Setup Java
161-
uses: actions/setup-java@v4
162-
with:
163-
distribution: zulu
164-
java-version: 17
165-
166-
# Generate Lexer and Parser
167-
- name: Generate Lexer
168-
run: ./gradlew generateLexer
169-
170-
- name: Generate Parser
171-
run: ./gradlew generateParser
172-
173-
# Run Qodana inspections
174-
- name: Qodana - Code Inspection
175-
uses: JetBrains/[email protected]
176-
with:
177-
cache-default-branch-only: true
178-
upload-result: true
179-
180-
# Run plugin structure verification along with IntelliJ Plugin Verifier
181144
verify:
182145
name: Verify plugin
183146
needs: [ build ]
184147
runs-on: ubuntu-24.04
185148
steps:
186-
187-
# Free GitHub Actions Environment Disk Space
188149
- name: Maximize Build Space
189150
uses: jlumbroso/free-disk-space@main
190151
with:
191152
tool-cache: false
192153
large-packages: false
193154

194-
# Check out the current repository
195155
- name: Fetch Sources
196156
uses: actions/checkout@v4
197157

198-
# Set up Java environment for the next steps
199158
- name: Setup Java
200159
uses: actions/setup-java@v4
201160
with:
202161
distribution: zulu
203162
java-version: 17
204163

205-
# Setup Gradle
206164
- name: Setup Gradle
207165
uses: gradle/actions/setup-gradle@v4
166+
with:
167+
cache-read-only: true
168+
169+
- name: Cache Lexer and Parser
170+
uses: actions/cache@v4
171+
id: cache-lexer-parser
172+
with:
173+
path: ${{ github.workspace }}/src/main/gen
174+
key: lexer-parser-${{ hashFiles('**/Sql.bnf','**/Sql.flex') }}
175+
restore-keys: |
176+
lexer-parser-
208177
209-
# Generate Lexer and Parser
210178
- name: Generate Lexer
179+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
211180
run: ./gradlew generateLexer
212181

213182
- name: Generate Parser
183+
if: steps.cache-lexer-parser.outputs.cache-hit != 'true'
214184
run: ./gradlew generateParser
215185

216-
# Cache Plugin Verifier IDEs
217186
- name: Setup Plugin Verifier IDEs Cache
218187
uses: actions/cache@v4
219188
with:
220189
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
221190
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
222191

223-
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
224192
- name: Run Plugin Verification tasks
225193
run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
226194

227-
# Collect Plugin Verifier Result
228195
- name: Collect Plugin Verifier Result
229196
if: ${{ always() }}
230197
uses: actions/upload-artifact@v4

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
# Setup Gradle
3535
- name: Setup Gradle
3636
uses: gradle/actions/setup-gradle@v4
37+
with:
38+
cache-read-only: true
3739

3840
# Generate Lexer and Parser
3941
- name: Generate Lexer

.github/workflows/update_changelog.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
# Setup Gradle
5454
- name: Setup Gradle
5555
uses: gradle/actions/setup-gradle@v4
56+
with:
57+
cache-read-only: true
5658

5759
- name: Run Gradle updateChangelog
5860
id: updateChangelog
@@ -82,12 +84,7 @@ jobs:
8284
env:
8385
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8486
run: |
85-
if ${{ env.EXIST_CHANGELOG == 'false' }} ; then
86-
gh label create "$LABEL" \
87-
--description "Pull requests with release changelog update" \
88-
--force \
89-
|| true
90-
87+
if ${{ env.EXIST_CHANGELOG == 'false' }} ; then
9188
gh pr create \
9289
--title "Changelog update - \`$NEW_VERSION\`" \
9390
--body "Current pull request contains patched \`CHANGELOG.md\` for the \`$NEW_VERSION\` version.Please merge this Pull Request once you have completed all the changes you want included in the latest version." \

0 commit comments

Comments
 (0)