Skip to content

Commit

Permalink
Merge pull request #8 from infosiftr/skip-sources
Browse files Browse the repository at this point in the history
Update "meta" job to skip "Sources" if `sources.json` is already up-to-date
  • Loading branch information
yosifkit authored Dec 13, 2023
2 parents 6b4184d + 511d173 commit 6b0ba20
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions Jenkinsfile.update
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,39 @@ node {
sh 'bashbrew --library .doi/library fetch $(cat subset.txt)' // TODO --all
}
stage('Sources') {
sh '.scripts/sources.sh $(cat subset.txt) > sources.json'
sh '''
# we only need to regenerate "sources.json" if ".doi", ".scripts", or "subset.txt" have changed since we last generated it
needsUpdate=
if ! git diff --exit-code .doi .scripts; then
# if .doi or .scripts updated in this job ("git submodule update" above)
needsUpdate=1
else
# if subset.txt, .doi, or .scripts updated outside this job (merged PR, etc)
sourcesCommit="$(git log -1 --format='format:%H' -- sources.json)"
for f in subset.txt .doi .scripts; do
commit="$(git log -1 --format='format:%H' -- "$f")"
if ! git merge-base --is-ancestor "$commit" "$sourcesCommit"; then
needsUpdate=1
break
fi
done
fi
if [ -n "$needsUpdate" ]; then
.scripts/sources.sh $(cat subset.txt) > sources.json
fi
'''
}
stage('Builds') {
sh '.scripts/builds.sh sources.json > builds.json'
}
}
stage('Commit') {
sh '''
git add -A .
git commit -m 'Update and regenerate' || :
# only commit submodule updates if our JSON has changed (see https://github.com/docker-library/meta-scripts/pull/8)
if ! git diff --exit-code sources.json builds.json; then
git add -A .
git commit -m 'Update and regenerate'
fi
'''
}
sshagent(['docker-library-bot']) {
Expand Down

0 comments on commit 6b0ba20

Please sign in to comment.