Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "meta" job to skip "Sources" if sources.json is already up-to-date #8

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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