Skip to content

Commit e97758d

Browse files
Excavator: Render CircleCI file using template specified in .circleci/template.sh
1 parent 4e757b9 commit e97758d

File tree

1 file changed

+77
-76
lines changed

1 file changed

+77
-76
lines changed

.circleci/config.yml

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,30 @@
33
# To manually manage the CircleCI configuration for this project, remove the .circleci/template.sh file.
44

55
version: 2.1
6+
7+
aliases:
8+
- &check-no-files-changed
9+
run:
10+
name: Check that no git-tracked files were modified
11+
command: |
12+
FILES_MODIFIED="$(git status --porcelain)"
13+
if [[ -n "$FILES_MODIFIED" ]]; then
14+
echo "The following files were modified or added during the build process:"
15+
echo "$FILES_MODIFIED"
16+
echo "This will likely prevent successful publishing. Please run the build locally and include these changes in your pull request. (If new files are created, consider whether they should be checked in or .gitignored.)"
17+
exit 1
18+
fi
19+
620
jobs:
7-
compile:
21+
22+
check:
823
docker: [{ image: 'cimg/openjdk:11.0.10-node' }]
924
resource_class: large
1025
environment:
1126
CIRCLE_TEST_REPORTS: /home/circleci/junit
1227
CIRCLE_ARTIFACTS: /home/circleci/artifacts
1328
GRADLE_OPTS: -Dorg.gradle.workers.max=2 -Dorg.gradle.jvmargs='-Xmx2g --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
14-
_JAVA_OPTIONS: -XX:ActiveProcessorCount=4 -XX:MaxRAM=8g -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
29+
_JAVA_OPTIONS: -XX:ActiveProcessorCount=4 -XX:MaxRAM=8g -XX:+CrashOnOutOfMemoryError -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
1530
steps:
1631
- checkout
1732
- run:
@@ -38,66 +53,31 @@ jobs:
3853
3954
echo "Detected tag build, deleting all tags except '$CIRCLE_TAG' which point to HEAD: [${TAGS_TO_DELETE/$'\n'/,}]"
4055
echo "$TAGS_TO_DELETE" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done
41-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
42-
- restore_cache: { key: 'compile-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
43-
- run: ./gradlew --parallel --stacktrace classes testClasses -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
44-
- save_cache:
45-
key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
46-
paths: [ ~/.gradle/wrapper ]
47-
- save_cache:
48-
key: 'compile-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
49-
paths: [ ~/.gradle/caches ]
50-
- store_test_results: { path: ~/junit }
51-
- store_artifacts: { path: ~/artifacts }
56+
- restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
57+
- restore_cache: { key: 'check-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
58+
- run:
59+
name: check-setup
60+
command: |
61+
if [ -x .circleci/check-setup.sh ]; then
62+
echo "Running check-setup" && .circleci/check-setup.sh && echo "check-setup complete"
63+
fi
64+
- run: ./gradlew --parallel --stacktrace --continue --max-workers=2 check -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
65+
- *check-no-files-changed
5266
- persist_to_workspace:
5367
root: /home/circleci
54-
paths: [ project, .gradle/init.gradle ]
55-
56-
check:
57-
docker: [{ image: 'cimg/openjdk:11.0.10-node' }]
58-
resource_class: medium
59-
environment:
60-
CIRCLE_TEST_REPORTS: /home/circleci/junit
61-
CIRCLE_ARTIFACTS: /home/circleci/artifacts
62-
GRADLE_OPTS: -Dorg.gradle.workers.max=1 -Dorg.gradle.jvmargs='-Xmx2g --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
63-
_JAVA_OPTIONS: -XX:ActiveProcessorCount=2 -XX:MaxRAM=4g -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
64-
steps:
65-
- attach_workspace: { at: /home/circleci }
66-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
67-
- restore_cache: { key: 'check-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
68-
- run: ./gradlew --parallel --stacktrace --continue check idea -x test -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
68+
paths: [ project ]
6969
- save_cache:
70-
key: 'check-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
71-
paths: [ ~/.gradle/caches ]
72-
- run:
73-
command: mkdir -p ~/junit && find . -type f -regex ".*/build/.*TEST.*xml" -exec cp --parents {} ~/junit/ \;
74-
when: always
75-
- store_test_results: { path: ~/junit }
76-
- store_artifacts: { path: ~/artifacts }
77-
78-
unit-test:
79-
docker: [{ image: 'cimg/openjdk:11.0.10-node' }]
80-
resource_class: large
81-
environment:
82-
CIRCLE_TEST_REPORTS: /home/circleci/junit
83-
CIRCLE_ARTIFACTS: /home/circleci/artifacts
84-
GRADLE_OPTS: -Dorg.gradle.workers.max=2 -Dorg.gradle.jvmargs='-Xmx2g --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
85-
_JAVA_OPTIONS: -XX:ActiveProcessorCount=4 -XX:MaxRAM=8g -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
86-
steps:
87-
- attach_workspace: { at: /home/circleci }
88-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
89-
- restore_cache: { key: 'unit-test-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
90-
- run: ./gradlew --parallel --stacktrace --continue --max-workers=2 test -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
70+
key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
71+
paths: [ ~/.gradle/wrapper ]
9172
- save_cache:
92-
key: 'unit-test-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
73+
key: 'check-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
9374
paths: [ ~/.gradle/caches ]
9475
- run:
9576
command: mkdir -p ~/junit && find . -type f -regex ".*/build/.*TEST.*xml" -exec cp --parents {} ~/junit/ \;
9677
when: always
9778
- store_test_results: { path: ~/junit }
9879
- store_artifacts: { path: ~/artifacts }
9980

100-
10181
build:
10282
machine: { docker_layer_caching: true }
10383
environment:
@@ -106,18 +86,25 @@ jobs:
10686
_JAVA_OPTIONS: -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false -Xmx8192m
10787
JAVA_HOME: /opt/java11
10888
steps:
109-
- attach_workspace: { at: /home/circleci }
110-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
111-
- restore_cache: { key: 'build-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
89+
- checkout
90+
- restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
91+
- restore_cache: { key: 'build-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
11292
- run:
11393
name: Install Java 11
11494
command: |
11595
sudo mkdir -p /opt/java && cd /opt/java && sudo chown -R circleci:circleci .
116-
curl https://cdn.azul.com/zulu/bin/zulu11.54.23-ca-jdk11.0.14-linux_x64.tar.gz | tar -xzf - -C /opt/java
96+
curl https://cdn.azul.com/zulu/bin/zulu11.68.17-ca-jdk11.0.21-linux_x64.tar.gz | tar -xzf - -C /opt/java
11797
sudo ln -s /opt/java/zulu*/ /opt/java11
98+
- run:
99+
name: build-setup
100+
command: |
101+
if [ -x .circleci/build-setup.sh ]; then
102+
echo "Running build-setup" && .circleci/build-setup.sh && echo "build-setup complete"
103+
fi
118104
- run: ./gradlew --parallel --stacktrace build -x test -x check -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
105+
- *check-no-files-changed
119106
- save_cache:
120-
key: 'build-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
107+
key: 'build-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
121108
paths: [ ~/.gradle/caches ]
122109
- run:
123110
command: mkdir -p ~/junit && find . -type f -regex ".*/build/.*TEST.*xml" -exec cp --parents {} ~/junit/ \; || true
@@ -132,17 +119,41 @@ jobs:
132119
CIRCLE_TEST_REPORTS: /home/circleci/junit
133120
CIRCLE_ARTIFACTS: /home/circleci/artifacts
134121
GRADLE_OPTS: -Dorg.gradle.workers.max=1 -Dorg.gradle.jvmargs='-Xmx2g --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
135-
_JAVA_OPTIONS: -XX:ActiveProcessorCount=2 -XX:MaxRAM=4g -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
122+
_JAVA_OPTIONS: -XX:ActiveProcessorCount=2 -XX:MaxRAM=4g -XX:+CrashOnOutOfMemoryError -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
136123
steps:
137-
- attach_workspace: { at: /home/circleci }
138-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
139-
- restore_cache: { key: 'trial-publish-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
124+
- checkout
125+
- run:
126+
name: delete_unrelated_tags
127+
command: |
128+
ALL_TAGS=$(git tag --points-at HEAD)
129+
130+
if [ -z "$ALL_TAGS" ]; then
131+
echo "No-op as there are no tags on the current commit ($(git rev-parse HEAD))"
132+
exit 0
133+
fi
134+
135+
if [ -z "${CIRCLE_TAG:+x}" ]; then
136+
echo "Non-tag build, deleting all tags which point to HEAD: [${ALL_TAGS/$'\n'/,}]"
137+
echo "$ALL_TAGS" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done
138+
exit 0
139+
fi
140+
141+
TAGS_TO_DELETE=$(echo "$ALL_TAGS" | grep -v "^$CIRCLE_TAG$" || :)
142+
if [ -z "$TAGS_TO_DELETE" ]; then
143+
echo "No-op as exactly one tag ($CIRCLE_TAG) points to HEAD"
144+
exit 0
145+
fi
146+
147+
echo "Detected tag build, deleting all tags except '$CIRCLE_TAG' which point to HEAD: [${TAGS_TO_DELETE/$'\n'/,}]"
148+
echo "$TAGS_TO_DELETE" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done
149+
- restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
150+
- restore_cache: { key: 'trial-publish-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
140151
- run: ./gradlew --stacktrace publishToMavenLocal -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
141152
- run:
142153
command: git status --porcelain
143154
when: always
144155
- save_cache:
145-
key: 'trial-publish-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
156+
key: 'trial-publish-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
146157
paths: [ ~/.gradle/caches ]
147158
- store_test_results: { path: ~/junit }
148159
- store_artifacts: { path: ~/artifacts }
@@ -154,18 +165,18 @@ jobs:
154165
CIRCLE_TEST_REPORTS: /home/circleci/junit
155166
CIRCLE_ARTIFACTS: /home/circleci/artifacts
156167
GRADLE_OPTS: -Dorg.gradle.workers.max=1 -Dorg.gradle.jvmargs='-Xmx2g --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
157-
_JAVA_OPTIONS: -XX:ActiveProcessorCount=2 -XX:MaxRAM=4g -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
168+
_JAVA_OPTIONS: -XX:ActiveProcessorCount=2 -XX:MaxRAM=4g -XX:+CrashOnOutOfMemoryError -XX:ErrorFile=/home/circleci/artifacts/hs_err_pid%p.log -XX:HeapDumpPath=/home/circleci/artifacts
158169
steps:
159170
- attach_workspace: { at: /home/circleci }
160-
- restore_cache: { key: 'gradle-wrapper-v2-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
161-
- restore_cache: { key: 'publish-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
171+
- restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
172+
- restore_cache: { key: 'publish-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
162173
- deploy:
163174
command: ./gradlew --parallel --stacktrace --continue publish -Porg.gradle.java.installations.fromEnv=JAVA_8_HOME,JAVA_11_HOME,JAVA_15_HOME,JAVA_17_HOME,JAVA_HOME
164175
- run:
165176
command: git status --porcelain
166177
when: always
167178
- save_cache:
168-
key: 'publish-gradle-cache-v2-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
179+
key: 'publish-gradle-cache-v1-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
169180
paths: [ ~/.gradle/caches ]
170181
- store_test_results: { path: ~/junit }
171182
- store_artifacts: { path: ~/artifacts }
@@ -175,25 +186,15 @@ workflows:
175186
version: 2
176187
build:
177188
jobs:
178-
- compile:
179-
filters: { tags: { only: /.*/ } }
180-
181-
- unit-test:
182-
requires: [ compile ]
183-
filters: { tags: { only: /.*/ } }
184-
185189
- check:
186-
requires: [ compile ]
187190
filters: { tags: { only: /.*/ } }
188191

189192
- build:
190-
requires: [ compile ]
191193
filters: { tags: { only: /.*/ } }
192194

193195
- trial-publish:
194-
requires: [ compile ]
195196
filters: { branches: { ignore: develop } }
196197

197198
- publish:
198-
requires: [ unit-test, check, build, trial-publish ]
199+
requires: [ check, build, trial-publish ]
199200
filters: { tags: { only: /.*/ }, branches: { only: develop } }

0 commit comments

Comments
 (0)