Skip to content

Commit 4a95ff6

Browse files
committed
Run the melting-pot as part of CI
1 parent ca1984a commit 4a95ff6

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.github/build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
11
#!/bin/sh
22
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/master/ci-build.sh
33
sh ci-build.sh
4+
5+
# Record the last time of cache modification before running melting-pot
6+
cache_modified_pre=0
7+
cache_modified_post=0
8+
9+
if [ -f "~/.cache/scijava/melting-pot" ]; then
10+
cache_modified_pre=$(find ~/.cache/scijava/melting-pot -printf '%T@\n' | sort -r | head -n 1)
11+
cache_modified_pre=${cache_modified_pre%.*}
12+
fi
13+
14+
# run melting-pot
15+
sh tests/run.sh
16+
17+
# Record the last time of cache modification after running melting-pot
18+
if [ -f "~/.cache/scijava/melting-pot" ]; then
19+
cache_modified_post=$(find ~/.cache/scijava/melting-pot -printf '%T@\n' | sort -r | head -n 1)
20+
cache_modified_post=${cache_modified_post%.*}
21+
fi
22+
23+
# Determine if cache needs to be re-generated
24+
if [ "$cache_modified_post" -gt "$cache_modified_pre" ]; then
25+
echo "update-cache=true" >> $GITHUB_ENV
26+
else
27+
echo "update-cache=false" >> $GITHUB_ENV
28+
fi

.github/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/sh
22
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/master/ci-setup-github-actions.sh
33
sh ci-setup-github-actions.sh
4+
5+
# xmllint needed for melting pot
6+
sudo apt-get install libxml2-utils

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,19 @@ jobs:
2222
java-version: '8'
2323
distribution: 'zulu'
2424
cache: 'maven'
25+
2526
- name: Set up CI environment
2627
run: .github/setup.sh
28+
29+
- name: Restore the cache
30+
id: restore-cache
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/.cache/scijava/melting-pot
34+
key: ${{ runner.os }}-cache
35+
2736
- name: Execute the build
37+
id: execute-build
2838
run: .github/build.sh
2939
env:
3040
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
@@ -33,3 +43,19 @@ jobs:
3343
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
3444
OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
3545
SIGNING_ASC: ${{ secrets.SIGNING_ASC }}
46+
47+
- name: Delete cache
48+
if: env.update-cache == 'true'
49+
id: delete-cache
50+
run: |
51+
gh api --method DELETE -H "Accept: application/vnd.github+json" /repos/scijava/pom-scijava/actions/caches?key=${{ runner.os }}-cache
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
54+
55+
- name: Update cache post-delete
56+
if: env.update-cache == 'true'
57+
id: update-cache
58+
uses: actions/cache@v3
59+
with:
60+
path: ~/.cache/scijava/melting-pot
61+
key: ${{ runner.os }}-cache

0 commit comments

Comments
 (0)