Skip to content

Commit

Permalink
tests: allow to override artifact nb filename format archived by Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
tlvu committed Oct 31, 2024
1 parent 5f13ec9 commit c9c8d50
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Note this is another run, will double the time and no guaranty to have same erro

post {
always {
archiveArtifacts(artifacts: 'buildout/*.ipynb', fingerprint: true, allowEmptyArchive: true)
archiveArtifacts(artifacts: 'buildout/**/*.ipynb', fingerprint: true, allowEmptyArchive: true)
archiveArtifacts(artifacts: 'buildout/env-dump/', fingerprint: true)
}
unsuccessful { // Run if the current builds status is "Aborted", "Failure" or "Unstable"
Expand Down
21 changes: 21 additions & 0 deletions downloadrepos
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ downloadrepos_main() {
fi
}


# Choose artifact filename format under buildout/ dir that is archived by Jenkins.
#
# The corresponding .output.ipynb will also have the same filename format.
#
# Override this function in CONFIG_OVERRIDE_SCRIPT_URL to choose another
# format, see demo in test-override/jenkins-params-external-repos.include.sh.
#
# Ex: when given 'pavics-sdi-master/docs/source/notebooks/regridding.ipynb',
# the current implementation will return
# 'pavics-sdi-master__docs__source__notebooks__regridding.ipynb', which means
# there will be
# "buildout/pavics-sdi-master__docs__source__notebooks__regridding.ipynb" and
# "buildout/pavics-sdi-master__docs__source__notebooks__regridding.output.ipynb"
#
# USAGE: artifact_filename="$(choose_artifact_filename "$original_nb_filename")"
choose_artifact_filename() {
echo "$1" | sed "s@/@__@g"
}


if [ -z "$DOWNLOADREPOS_AS_LIB" ]; then
# Script mode, not library mode.
downloadrepos_main "$@"
Expand Down
3 changes: 1 addition & 2 deletions runtest
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ BUILDOUT_DIR="buildout" # hardcode in Jenkinsfile, can not be override.

mkdir -p "$BUILDOUT_DIR/"
for nb in $NOTEBOOKS; do
repo_branch_name="$(extract_repo_name "$nb")"
filename="${repo_branch_name}--$(basename "$nb")"
filename="$(choose_artifact_filename "$nb")"
filename="$(echo "$filename" | sed "s/.ipynb$//")" # remove .ipynb ext
if [ -e "${BUILDOUT_DIR}/${filename}.ipynb" ]; then
# prevent name clash
Expand Down
5 changes: 5 additions & 0 deletions test-override/jenkins-params-external-repos.include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ ROOK_DIR="$(sanitize_extracted_folder_name "${ROOK_REPO_NAME}-${ROOK_BRANCH}")"
# Set new nbs as nb list to test.
NOTEBOOKS="$ROOK_DIR/notebooks/*.ipynb"
# Sample demo override choose_artifact_filename: keep the original file path hierarchy.
choose_artifact_filename() {
echo "$1"
}
' > "$CONFIG_OVERRIDE_SCRIPT_URL"

0 comments on commit c9c8d50

Please sign in to comment.