-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.yml
380 lines (358 loc) · 15.1 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
version: 2.1
executors:
ubuntu_executor:
machine:
# https://circleci.com/developer/images?imageType=machine
image: ubuntu-2204:2024.01.1
resource_class: large
working_directory: ~/git-machete-intellij-plugin
commands:
install_github_cli:
steps:
- run:
name: Install GitHub CLI
# language=sh
command: |
# Install the latest version of GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
| sudo tee /etc/apt/sources.list.d/github-cli.list
sudo apt-get update
sudo apt-get install gh -y
restore_gradle_cache:
steps:
- restore_cache:
# Adding `-v<N>` suffix to enable easy cache invalidation when needed:
# just change to `-v<N+1>` (remember to also update `save_cache` key).
keys:
# First, try finding a cache entry with the same set of libraries
# that also comes from the same branch (so as to make the best use of Gradle compilation cache).
- gradle-deps-v12-{{ checksum "gradle/libs.versions.toml" }}-{{ .Branch }}
# If the above key is not found, try finding a cache entry with the same set of libraries
# coming from another branch (Gradle compilation cache might then be less useful).
- gradle-deps-v12-{{ checksum "gradle/libs.versions.toml" }}-
# As a last resort, take any available cache entry.
- gradle-deps-v12-
collect_ui_test_artifacts:
steps:
- run:
name: Collect artifacts when an exception occurs
# language=sh
command: |
if ! ( [ -d ~/.ideprobe-uitests/artifacts ] && [ -n "$(ls -A ~/.ideprobe-uitests/artifacts)" ] ); then exit 0; fi
for f in $(ls -d ~/.ideprobe-uitests/artifacts/*/) ; do cd $f ; zip -r "../$(basename ${f}).zip" . ; done
mkdir -p ~/artifacts
find ~/.ideprobe-uitests/artifacts -name '*.zip' | xargs cp --target-directory ~/artifacts
for f in $(find ~/.ideprobe-uitests/idea-logs/intellij-instance-*/logs/idea.log) ; do
target="~/artifacts/$(echo $f | sed 's/.*\/\(intellij-instance-.*\)\/logs\/idea.log/\1.log/')"
eval "cp $f $target"
done
when: on_fail
- store_artifacts:
path: ~/artifacts
destination: .
- store_test_results:
path: build/test-results/
reconfigure_origin_remote:
steps:
- run:
name: Reconfigure origin remote to https
# language=sh
command: git remote set-url origin https://${GITHUB_TOKEN}@github.com/VirtusLab/git-machete-intellij-plugin.git
create_pull_request_if_files_changed:
parameters:
branch_name_prefix:
type: string
branch_name_command:
type: string
commit_message_prefix:
type: string
commit_message_command:
type: string
default: 'echo ""'
labels: # comma-separated
type: string
steps:
- install_github_cli
- run:
name: Create a pull request if project files changed
# language=sh
command: |
if git diff --quiet HEAD; then
echo "No changes to project files after running the task, aborting"
exit 0
fi
branch_name="<<parameters.branch_name_prefix>>/$(<<parameters.branch_name_command>>)"
if git ls-remote --exit-code --heads origin "$branch_name" &> /dev/null; then
git restore . # so that the uncommitted changes don't propagate to the next step
echo "Branch $branch_name already exists in the remote, aborting"
exit 0
fi
git checkout -b "$branch_name"
git commit -a -m "<<parameters.commit_message_prefix>> $(<<parameters.commit_message_command>>)"
git push origin "$branch_name"
gh pr create -f \
--base "$CIRCLE_BRANCH" \
--label "<<parameters.labels>>"
git checkout "$CIRCLE_BRANCH"
jobs:
build:
executor: ubuntu_executor
steps:
- checkout
- install_github_cli
- run:
name: Install other dependencies for pre-build checks
# language=sh
command: |
sudo apt-get update
sudo apt-get install shellcheck -y
npm install --global remark-cli remark-lint-no-dead-urls remark-validate-links
remark --help
- run:
name: Run pre-build checks
command: ./scripts/run-pre-build-checks
- restore_gradle_cache
- run:
name: Start Gradle daemon
command: ./gradlew
- run:
name: Check formatting
command: ./gradlew spotlessCheck
- run:
name: Compile production code
command: ./gradlew classes
- run:
name: Run static code analyzer
command: ./gradlew --warn checkstyleMain checkstyleTestFixtures
- run:
name: Check Javadoc correctness
command: ./gradlew javadoc
- when:
condition:
matches:
pattern: "^(.*ide(-)?probe.*)$"
value: << pipeline.git.branch >>
steps:
- run:
name: Install sbt
# language=sh
command: |
apt update
apt-get install apt-transport-https gnupg -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
apt-get update
apt-get install sbt
- run:
name: Publish ide-probe snapshots locally
# language=sh
command: |
cd ..
# Let's use the latest `master` commit by default. Note that ide-probe has no `develop` branch,
# hence `master` serves as a "logical develop" where all PRs are merged and wait to be included in a release.
# Of course, this repository/branch can be modified at will here in code during the development,
# to pull in snapshots of in-development branches from forks.
git clone https://github.com/VirtusLab/ide-probe.git -b master
cd ide-probe/
sbt api_2_13/publishM2 driver_2_13/publishM2 junit-driver_2_13/publishM2 robot-driver_2_13/publishM2 probe-plugin_2_13/publishM2
- run:
name: Compile tests
command: ./gradlew testClasses
- run:
name: Run unit & integration tests
command: ./gradlew test
# Unfortunately, wildcards for test result paths aren't supported by CircleCI yet.
- store_test_results:
path: branchLayout/impl/build/test-results/test/
- store_test_results:
path: backend/impl/build/test-results/test/
- store_test_results:
path: frontend/base/build/test-results/test/
- store_test_results:
path: build/test-results/
- run:
name: Build plugin artifact
command: ./gradlew buildPlugin
- run:
name: Sign plugin artifact
command: ./gradlew signPlugin
- store_artifacts:
path: build/distributions/
destination: .
- run:
name: Verify binary compatibility with supported IntelliJ versions
command: ./gradlew verifyPlugin
- when:
condition:
not:
equal: [ master, << pipeline.git.branch >> ]
steps:
- run:
name: Remove IntelliJ artifacts to reduce cache size
# language=sh
command: |
du -h -d1 ~/.gradle/caches/modules-2/files-2.1/ | sort -h
echo '---------'
rm -rf ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/
rm -rf ~/.gradle/caches/modules-2/files-2.1/idea/
rm -rf ~/.gradle/caches/.tmp/
rm -rf ~/.gradle/caches/*/transforms/
du -h -d3 ~/.gradle/ | sort -h
- save_cache:
paths: [ ~/.gradle/ ]
key: gradle-deps-v12-{{ checksum "gradle/libs.versions.toml" }}-{{ .Branch }}
ui-tests-recent:
executor: ubuntu_executor
steps:
- checkout
- restore_gradle_cache
- run:
name: Run UI tests against an EAP of the latest supported major IntelliJ version (if applicable)
command: ./gradlew -PvirtualDisplay -Pagainst=eapOfLatestSupportedMajor uiTest
- run:
name: Run UI tests against the latest stable IntelliJ version
command: ./gradlew -PvirtualDisplay -Pagainst=latestStable uiTest
- collect_ui_test_artifacts
ui-tests-earlier:
executor: ubuntu_executor
steps:
- run: echo # there always needs to be at least one step left once conditions are evaluated
- when:
# Note that the condition needs to be put on the steps (instead of the entire job)
# for the sake of branch protection rules in GitHub, which require a specific set of checks to pass.
# If `ui-tests-earlier` wasn't placed in the required checks, then the entire job would be mostly pointless;
# if the condition was on a job instead, then the check wouldn't be satisfied outside the selected branches
# where ui-tests-earlier were executed.
# Similarly, `ui-tests-earlier` job is a prerequisite of `publish` job.
condition:
# Practice shows that the risk of UI tests failing on `latestMinorsOfOldSupportedMajors`
# once both binary compatibility checks and UI tests for latest versions passed is close to zero.
# Hence, to speed up the builds, we only run them for develop/master/hotfix/release branches and not on PRs.
# Also, we run on branches related to ide-probe or UI tests, as indicated by their name.
matches:
pattern: "^(.+/ci-.+|develop|hotfix/.+|.*ide(-)?probe.*|master|release/.+|.*ui(-)?test.*)$"
value: << pipeline.git.branch >>
steps:
- checkout
- restore_gradle_cache
- run:
name: Run UI tests against earlier supported major IntelliJ versions
command: ./gradlew -PvirtualDisplay -Pagainst=latestMinorsOfOldSupportedMajors uiTest
- collect_ui_test_artifacts
publish-plugin:
executor: ubuntu_executor
steps:
- checkout
- restore_gradle_cache
- run:
# Publishing should be the first step since if it fails, we should NOT proceed with opening GitHub release etc.
name: Publish plugin to Jetbrains Marketplace
command: ./gradlew publishPlugin
- reconfigure_origin_remote
- install_github_cli
- run:
name: Push git tag
# language=sh
command: |
source scripts/utils.sh
tag=v$(extract_version_from_current_wd)
git tag "$tag"
git push origin "$tag"
- run:
name: Create GitHub release
# Implicit usage of ${GITHUB_TOKEN} by gh
# language=sh
command: |
source scripts/utils.sh
tag=v$(extract_version_from_current_wd)
change_notes=$(./gradlew getChangelog --no-header -q)
gh release create \
$tag \
"$(./gradlew -q printSignedPluginZipPath)" \
--title "$tag" \
--notes "$change_notes"
- run:
name: Close GitHub milestone
# Implicit usage of ${GITHUB_TOKEN} by gh
# language=sh
command: |
source scripts/utils.sh
milestone=v$(extract_version_from_current_wd)
scripts/close-github-milestone "$milestone"
check-for-updates:
executor: ubuntu_executor
steps:
- checkout
- run:
name: Configure git user information
# language=sh
command: |
git config user.email "[email protected]"
git config user.name "Git Machete Bot"
- reconfigure_origin_remote
- run:
# These updates are unlikely to ever be supported by dependabot.
name: Check for updates of IntelliJ versions
command: ./gradlew updateIntellijVersions
- create_pull_request_if_files_changed:
branch_name_prefix: update-intellij-versions
branch_name_command: md5sum intellij-versions.properties | cut -d' ' -f 1
commit_message_prefix: 'Update IntelliJ versions:'
# language=sh
commit_message_command: >
git diff | grep '^+[^#+]' |
sed 's/Majors=.*/Majors/' |
sed 's/+//g' |
sed 's/=/ to /g' |
sed 's/to $/to EMPTY/g' |
tr '\n' ',' |
sed 's/,$//' |
sed 's/,/, /g'
labels: "intellij range"
- run:
# These updates don't seem to be supported by dependabot as of August 2023,
# see https://github.com/dependabot/dependabot-core/issues/2223
name: Check for updates of Gradle
# language=sh
command: |
latest_gradle_version=$(curl -fsSL https://services.gradle.org/versions/current | jq -r .version)
./gradlew wrapper --gradle-version=$latest_gradle_version # this only updates gradle-wrapper.properties
./gradlew wrapper --gradle-version=$latest_gradle_version # to actually pull the new wrapper script/jar
echo "$latest_gradle_version" > /tmp/gradle-version
- create_pull_request_if_files_changed:
branch_name_prefix: update-gradle
branch_name_command: cat /tmp/gradle-version
commit_message_prefix: Update Gradle wrapper to
commit_message_command: cat /tmp/gradle-version
labels: build
workflows:
version: 2
build-and-ui-tests:
jobs:
- build
# There's a 1-hour time limit on a job execution, so let's split the UI tests into 2 separate jobs
- ui-tests-recent
- ui-tests-earlier
- publish-plugin:
requires:
- build
- ui-tests-recent
- ui-tests-earlier
filters:
branches:
only:
- master
check-for-updates:
triggers:
- schedule:
cron: "0 0 * * *" # everyday at midnight UTC
filters:
branches:
only:
- develop
jobs:
- check-for-updates