|
1 | 1 | # GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: |
2 | 2 | # - Validate Gradle Wrapper. |
3 | 3 | # - Run 'test' and 'verifyPlugin' tasks. |
4 | | -# - Run Qodana inspections. |
5 | 4 | # - Run the 'buildPlugin' task and prepare artifact for further tests. |
6 | 5 | # - Run the 'runPluginVerifier' task. |
7 | | -# - Create a draft release. |
8 | 6 | # |
9 | 7 | # The workflow is triggered on push and pull_request events. |
10 | 8 | # |
|
14 | 12 |
|
15 | 13 | name: Build |
16 | 14 | on: |
17 | | - # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) |
18 | 15 | push: |
19 | | - branches: [ main ] |
20 | | - # Trigger the workflow on any pull request |
| 16 | + branches: |
| 17 | + - 'main' |
21 | 18 | pull_request: |
22 | 19 |
|
23 | 20 | concurrency: |
24 | 21 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
25 | 22 | cancel-in-progress: true |
26 | | - |
| 23 | + |
27 | 24 | jobs: |
28 | 25 |
|
29 | | - # Prepare environment and build the plugin |
30 | 26 | build: |
31 | 27 | name: Build |
32 | 28 | runs-on: ubuntu-24.04 |
33 | 29 | outputs: |
34 | | - version: ${{ steps.properties.outputs.version }} |
35 | | - changelog: ${{ steps.properties.outputs.changelog }} |
36 | 30 | pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} |
37 | 31 | steps: |
38 | | - |
39 | | - # Check out the current repository |
40 | 32 | - name: Fetch Sources |
41 | 33 | uses: actions/checkout@v4 |
42 | 34 |
|
43 | | - # Validate wrapper |
44 | 35 | - name: Gradle Wrapper Validation |
45 | 36 | uses: gradle/actions/wrapper-validation@v4 |
46 | 37 |
|
47 | | - # Set up Java environment for the next steps |
48 | 38 | - name: Setup Java |
49 | 39 | uses: actions/setup-java@v4 |
50 | 40 | with: |
51 | 41 | distribution: zulu |
52 | 42 | java-version: 17 |
53 | 43 |
|
54 | | - # Setup Gradle |
55 | 44 | - name: Setup Gradle |
56 | 45 | uses: gradle/actions/setup-gradle@v4 |
57 | 46 |
|
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 | +
|
59 | 63 | - name: Generate Lexer |
| 64 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
60 | 65 | run: ./gradlew generateLexer |
61 | 66 |
|
62 | 67 | - name: Generate Parser |
| 68 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
63 | 69 | run: ./gradlew generateParser |
64 | 70 |
|
65 | | - # Build plugin |
| 71 | + - name: Build Gradle |
| 72 | + run: ./gradlew build -x test |
| 73 | + |
66 | 74 | - name: Build plugin |
67 | | - run: ./gradlew buildPlugin -PpluginVersion=0.3.1-${{ github.run_number }} |
| 75 | + run: ./gradlew buildPlugin -PpluginVersion=${{ github.run_number }} |
68 | 76 |
|
69 | | - # Prepare plugin archive content for creating artifact |
70 | 77 | - name: Prepare Plugin Artifact |
71 | 78 | id: artifact |
72 | 79 | shell: bash |
73 | 80 | run: | |
74 | 81 | cd ${{ github.workspace }}/build/distributions |
75 | | - FILENAME=`ls *.zip` |
| 82 | + FILENAME=$(ls *.zip) |
76 | 83 | unzip "$FILENAME" -d content |
77 | | -
|
78 | 84 | echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT |
79 | 85 |
|
80 | | - # Store already-built plugin as an artifact for downloading |
81 | 86 | - name: Upload artifact |
82 | 87 | uses: actions/upload-artifact@v4 |
83 | 88 | with: |
84 | 89 | name: ${{ steps.artifact.outputs.filename }} |
85 | 90 | path: ./build/distributions/content/*/* |
86 | 91 |
|
87 | | - # Run tests and upload a code coverage report |
88 | 92 | test: |
89 | 93 | name: Test |
90 | 94 | needs: [ build ] |
91 | 95 | runs-on: ubuntu-24.04 |
92 | 96 | steps: |
93 | | - |
94 | | - # Check out the current repository |
95 | 97 | - name: Fetch Sources |
96 | 98 | uses: actions/checkout@v4 |
97 | 99 |
|
98 | | - # Set up Java environment for the next steps |
99 | 100 | - name: Setup Java |
100 | 101 | uses: actions/setup-java@v4 |
101 | 102 | with: |
102 | 103 | distribution: zulu |
103 | 104 | java-version: 17 |
104 | 105 |
|
105 | | - # Setup Gradle |
106 | 106 | - name: Setup Gradle |
107 | 107 | 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- |
108 | 119 |
|
109 | | - # Generate Lexer and Parser |
110 | 120 | - name: Generate Lexer |
| 121 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
111 | 122 | run: ./gradlew generateLexer |
112 | 123 |
|
113 | 124 | - name: Generate Parser |
| 125 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
114 | 126 | run: ./gradlew generateParser |
115 | 127 |
|
116 | 128 | # Run tests |
117 | 129 | - name: Run Tests |
118 | 130 | run: ./gradlew check |
119 | 131 |
|
120 | | - # Collect Tests Result of failed tests |
121 | 132 | - name: Collect Tests Result |
122 | 133 | if: ${{ failure() }} |
123 | 134 | uses: actions/upload-artifact@v4 |
124 | 135 | with: |
125 | 136 | name: tests-result |
126 | 137 | path: ${{ github.workspace }}/build/reports/tests |
127 | 138 |
|
128 | | - # Upload the Kover report to CodeCov |
129 | 139 | - name: Upload Code Coverage Report |
130 | 140 | uses: codecov/codecov-action@v5 |
131 | 141 | with: |
132 | 142 | files: ${{ github.workspace }}/build/reports/kover/report.xml |
133 | 143 |
|
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 | | - |
176 | | - with: |
177 | | - cache-default-branch-only: true |
178 | | - upload-result: true |
179 | | - |
180 | | - # Run plugin structure verification along with IntelliJ Plugin Verifier |
181 | 144 | verify: |
182 | 145 | name: Verify plugin |
183 | 146 | needs: [ build ] |
184 | 147 | runs-on: ubuntu-24.04 |
185 | 148 | steps: |
186 | | - |
187 | | - # Free GitHub Actions Environment Disk Space |
188 | 149 | - name: Maximize Build Space |
189 | 150 | uses: jlumbroso/free-disk-space@main |
190 | 151 | with: |
191 | 152 | tool-cache: false |
192 | 153 | large-packages: false |
193 | 154 |
|
194 | | - # Check out the current repository |
195 | 155 | - name: Fetch Sources |
196 | 156 | uses: actions/checkout@v4 |
197 | 157 |
|
198 | | - # Set up Java environment for the next steps |
199 | 158 | - name: Setup Java |
200 | 159 | uses: actions/setup-java@v4 |
201 | 160 | with: |
202 | 161 | distribution: zulu |
203 | 162 | java-version: 17 |
204 | 163 |
|
205 | | - # Setup Gradle |
206 | 164 | - name: Setup Gradle |
207 | 165 | 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- |
208 | 177 |
|
209 | | - # Generate Lexer and Parser |
210 | 178 | - name: Generate Lexer |
| 179 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
211 | 180 | run: ./gradlew generateLexer |
212 | 181 |
|
213 | 182 | - name: Generate Parser |
| 183 | + if: steps.cache-lexer-parser.outputs.cache-hit != 'true' |
214 | 184 | run: ./gradlew generateParser |
215 | 185 |
|
216 | | - # Cache Plugin Verifier IDEs |
217 | 186 | - name: Setup Plugin Verifier IDEs Cache |
218 | 187 | uses: actions/cache@v4 |
219 | 188 | with: |
220 | 189 | path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides |
221 | 190 | key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} |
222 | 191 |
|
223 | | - # Run Verify Plugin task and IntelliJ Plugin Verifier tool |
224 | 192 | - name: Run Plugin Verification tasks |
225 | 193 | run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} |
226 | 194 |
|
227 | | - # Collect Plugin Verifier Result |
228 | 195 | - name: Collect Plugin Verifier Result |
229 | 196 | if: ${{ always() }} |
230 | 197 | uses: actions/upload-artifact@v4 |
|
0 commit comments