Skip to content

Commit bfa71f3

Browse files
committed
Support artifact-paths with AWS Batch
This is now possible with the wait-N jobs.
1 parent 8c8e3d9 commit bfa71f3

2 files changed

Lines changed: 117 additions & 25 deletions

File tree

.github/workflows/pathogen-repo-build.yaml

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ on:
111111
.snakemake/log/
112112
113113
The "build.log" contains log messages from the `nextstrain build` command. The other paths are common output paths for Nextstrain builds. If a path does not exist in your build, then the action will still succeed and will print out a warning for the non-existent file(s). Use an exclude pattern for any of the default paths that you would like to exclude from the artifact (e.g. !build.log).
114-
115-
This is not supported for builds on AWS Batch because the workflow detaches from the build. Please use the `nextstrain build` command locally to reattach to AWS Batch builds to download outputs.
116114
type: string
117115
required: false
118116
outputs:
@@ -217,8 +215,6 @@ on:
217215
.snakemake/log/
218216
219217
The "build.log" contains log messages from the `nextstrain build` command. The other paths are common output paths for Nextstrain builds. If a path does not exist in your build, then the action will still succeed and will print out a warning for the non-existent file(s). Use an exclude pattern for any of the default paths that you would like to exclude from the artifact (e.g. !build.log).
220-
221-
This is not supported for builds on AWS Batch because the workflow detaches from the build. Please use the `nextstrain build` command locally to reattach to AWS Batch builds to download outputs.
222218
type: string
223219
required: false
224220
repo:
@@ -231,6 +227,12 @@ env:
231227
NEXTSTRAIN_GITHUB_DIR: .git/nextstrain/.github
232228
NEXTSTRAIN_BUILD_LOG: build.log
233229
NEXTSTRAIN_RUNTIME_ENVDIR: .git/nextstrain/env.d
230+
NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS: |
231+
auspice/
232+
results/
233+
benchmarks/
234+
logs/
235+
.snakemake/log/
234236
permissions:
235237
id-token: write
236238
jobs:
@@ -348,18 +350,14 @@ jobs:
348350
run: |
349351
"$NEXTSTRAIN_GITHUB_DIR"/bin/interpolate-env < "$NEXTSTRAIN_GITHUB_DIR"/text-templates/attach-aws-batch.md \
350352
> "$GITHUB_STEP_SUMMARY"
351-
- if: always()
353+
- if: ${{ always() && !env.AWS_BATCH_JOB_ID }}
352354
uses: actions/upload-artifact@v7
353355
with:
354356
if-no-files-found: warn
355357
name: ${{ inputs.artifact-name }}
356358
path: |
357359
${{ env.NEXTSTRAIN_BUILD_LOG }}
358-
auspice/
359-
results/
360-
benchmarks/
361-
logs/
362-
.snakemake/log/
360+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
363361
${{ inputs.artifact-paths }}
364362
outputs:
365363
AWS_BATCH_JOB_ID: ${{ env.AWS_BATCH_JOB_ID }}
@@ -402,20 +400,31 @@ jobs:
402400
name: Attach to AWS Batch job
403401
env:
404402
AWS_BATCH_JOB_ID: ${{ needs.run-build.outputs.AWS_BATCH_JOB_ID }}
403+
ARTIFACT_PATHS: ${{ inputs.artifact-paths }}
405404
run: |
406405
# Using timeout to detach from build before we hit the job.timeout-minutes
407406
# to avoid cancelling the job in order to avoid a "Cancelled" status
408407
# for the whole workflow.¹ Using SIGINT to ensure that the GH Action
409408
# cleanly detaches from the build without cancelling it.²
410409
# ¹ <https://github.com/nextstrain/.github/issues/129#issuecomment-2956350306>
411410
# ² <https://github.com/nextstrain/.github/pull/134#discussion_r2325804695>
411+
412+
# Set download args for default and custom artifact paths, skipping
413+
# blank lines. Append directories with ** to match files within.
414+
download_args=()
415+
while IFS= read -r line; do
416+
[[ -z "$line" ]] && continue
417+
[[ "$line" == */ ]] && line+='**'
418+
download_args+=(--download "$line")
419+
done <<< "${NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS}${ARTIFACT_PATHS}"
420+
412421
exit_status=0
413422
timeout --signal INT 359m \
414423
nextstrain build \
415424
--aws-batch \
416425
--attach "$AWS_BATCH_JOB_ID" \
417426
--detach-on-interrupt \
418-
--no-download || exit_status=$?
427+
"${download_args[@]}" . || exit_status=$?
419428
420429
if [[ $exit_status == 0 ]]; then
421430
conclusion="success"
@@ -431,6 +440,14 @@ jobs:
431440
432441
echo "conclusion=$conclusion" | tee -a "$GITHUB_OUTPUT"
433442
exit $exit_status
443+
- if: ${{ always() && steps.attach.outputs.conclusion != 'timeout' }}
444+
uses: actions/upload-artifact@v7
445+
with:
446+
if-no-files-found: warn
447+
name: ${{ inputs.artifact-name }}
448+
path: |
449+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
450+
${{ inputs.artifact-paths }}
434451
# Emit a "conclusion" output for the job that's based on the conclusion
435452
# (success, timeout, failure) of the "attach" step above.
436453
# This is the conclusion we care about for the job.
@@ -470,20 +487,31 @@ jobs:
470487
name: Attach to AWS Batch job
471488
env:
472489
AWS_BATCH_JOB_ID: ${{ needs.run-build.outputs.AWS_BATCH_JOB_ID }}
490+
ARTIFACT_PATHS: ${{ inputs.artifact-paths }}
473491
run: |
474492
# Using timeout to detach from build before we hit the job.timeout-minutes
475493
# to avoid cancelling the job in order to avoid a "Cancelled" status
476494
# for the whole workflow.¹ Using SIGINT to ensure that the GH Action
477495
# cleanly detaches from the build without cancelling it.²
478496
# ¹ <https://github.com/nextstrain/.github/issues/129#issuecomment-2956350306>
479497
# ² <https://github.com/nextstrain/.github/pull/134#discussion_r2325804695>
498+
499+
# Set download args for default and custom artifact paths, skipping
500+
# blank lines. Append directories with ** to match files within.
501+
download_args=()
502+
while IFS= read -r line; do
503+
[[ -z "$line" ]] && continue
504+
[[ "$line" == */ ]] && line+='**'
505+
download_args+=(--download "$line")
506+
done <<< "${NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS}${ARTIFACT_PATHS}"
507+
480508
exit_status=0
481509
timeout --signal INT 359m \
482510
nextstrain build \
483511
--aws-batch \
484512
--attach "$AWS_BATCH_JOB_ID" \
485513
--detach-on-interrupt \
486-
--no-download || exit_status=$?
514+
"${download_args[@]}" . || exit_status=$?
487515
488516
if [[ $exit_status == 0 ]]; then
489517
conclusion="success"
@@ -499,6 +527,14 @@ jobs:
499527
500528
echo "conclusion=$conclusion" | tee -a "$GITHUB_OUTPUT"
501529
exit $exit_status
530+
- if: ${{ always() && steps.attach.outputs.conclusion != 'timeout' }}
531+
uses: actions/upload-artifact@v7
532+
with:
533+
if-no-files-found: warn
534+
name: ${{ inputs.artifact-name }}
535+
path: |
536+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
537+
${{ inputs.artifact-paths }}
502538
# Emit a "conclusion" output for the job that's based on the conclusion
503539
# (success, timeout, failure) of the "attach" step above.
504540
# This is the conclusion we care about for the job.
@@ -539,20 +575,31 @@ jobs:
539575
name: Attach to AWS Batch job
540576
env:
541577
AWS_BATCH_JOB_ID: ${{ needs.run-build.outputs.AWS_BATCH_JOB_ID }}
578+
ARTIFACT_PATHS: ${{ inputs.artifact-paths }}
542579
run: |
543580
# Using timeout to detach from build before we hit the job.timeout-minutes
544581
# to avoid cancelling the job in order to avoid a "Cancelled" status
545582
# for the whole workflow.¹ Using SIGINT to ensure that the GH Action
546583
# cleanly detaches from the build without cancelling it.²
547584
# ¹ <https://github.com/nextstrain/.github/issues/129#issuecomment-2956350306>
548585
# ² <https://github.com/nextstrain/.github/pull/134#discussion_r2325804695>
586+
587+
# Set download args for default and custom artifact paths, skipping
588+
# blank lines. Append directories with ** to match files within.
589+
download_args=()
590+
while IFS= read -r line; do
591+
[[ -z "$line" ]] && continue
592+
[[ "$line" == */ ]] && line+='**'
593+
download_args+=(--download "$line")
594+
done <<< "${NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS}${ARTIFACT_PATHS}"
595+
549596
exit_status=0
550597
timeout --signal INT 359m \
551598
nextstrain build \
552599
--aws-batch \
553600
--attach "$AWS_BATCH_JOB_ID" \
554601
--detach-on-interrupt \
555-
--no-download || exit_status=$?
602+
"${download_args[@]}" . || exit_status=$?
556603
557604
if [[ $exit_status == 0 ]]; then
558605
conclusion="success"
@@ -568,6 +615,14 @@ jobs:
568615
569616
echo "conclusion=$conclusion" | tee -a "$GITHUB_OUTPUT"
570617
exit $exit_status
618+
- if: ${{ always() && steps.attach.outputs.conclusion != 'timeout' }}
619+
uses: actions/upload-artifact@v7
620+
with:
621+
if-no-files-found: warn
622+
name: ${{ inputs.artifact-name }}
623+
path: |
624+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
625+
${{ inputs.artifact-paths }}
571626
# Emit a "conclusion" output for the job that's based on the conclusion
572627
# (success, timeout, failure) of the "attach" step above.
573628
# This is the conclusion we care about for the job.
@@ -608,20 +663,31 @@ jobs:
608663
name: Attach to AWS Batch job
609664
env:
610665
AWS_BATCH_JOB_ID: ${{ needs.run-build.outputs.AWS_BATCH_JOB_ID }}
666+
ARTIFACT_PATHS: ${{ inputs.artifact-paths }}
611667
run: |
612668
# Using timeout to detach from build before we hit the job.timeout-minutes
613669
# to avoid cancelling the job in order to avoid a "Cancelled" status
614670
# for the whole workflow.¹ Using SIGINT to ensure that the GH Action
615671
# cleanly detaches from the build without cancelling it.²
616672
# ¹ <https://github.com/nextstrain/.github/issues/129#issuecomment-2956350306>
617673
# ² <https://github.com/nextstrain/.github/pull/134#discussion_r2325804695>
674+
675+
# Set download args for default and custom artifact paths, skipping
676+
# blank lines. Append directories with ** to match files within.
677+
download_args=()
678+
while IFS= read -r line; do
679+
[[ -z "$line" ]] && continue
680+
[[ "$line" == */ ]] && line+='**'
681+
download_args+=(--download "$line")
682+
done <<< "${NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS}${ARTIFACT_PATHS}"
683+
618684
exit_status=0
619685
timeout --signal INT 359m \
620686
nextstrain build \
621687
--aws-batch \
622688
--attach "$AWS_BATCH_JOB_ID" \
623689
--detach-on-interrupt \
624-
--no-download || exit_status=$?
690+
"${download_args[@]}" . || exit_status=$?
625691
626692
if [[ $exit_status == 0 ]]; then
627693
conclusion="success"
@@ -637,6 +703,14 @@ jobs:
637703
638704
echo "conclusion=$conclusion" | tee -a "$GITHUB_OUTPUT"
639705
exit $exit_status
706+
- if: ${{ always() && steps.attach.outputs.conclusion != 'timeout' }}
707+
uses: actions/upload-artifact@v7
708+
with:
709+
if-no-files-found: warn
710+
name: ${{ inputs.artifact-name }}
711+
path: |
712+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
713+
${{ inputs.artifact-paths }}
640714
# Emit a "conclusion" output for the job that's based on the conclusion
641715
# (success, timeout, failure) of the "attach" step above.
642716
# This is the conclusion we care about for the job.

.github/workflows/pathogen-repo-build.yaml.in

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ on:
155155
succeed and will print out a warning for the non-existent file(s).
156156
Use an exclude pattern for any of the default paths that you would like to
157157
exclude from the artifact (e.g. !build.log).
158-
159-
This is not supported for builds on AWS Batch because the workflow
160-
detaches from the build. Please use the `nextstrain build` command
161-
locally to reattach to AWS Batch builds to download outputs.
162158
type: string
163159
required: false
164160

@@ -189,6 +185,12 @@ env:
189185
NEXTSTRAIN_GITHUB_DIR: .git/nextstrain/.github
190186
NEXTSTRAIN_BUILD_LOG: build.log
191187
NEXTSTRAIN_RUNTIME_ENVDIR: .git/nextstrain/env.d
188+
NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS: |
189+
auspice/
190+
results/
191+
benchmarks/
192+
logs/
193+
.snakemake/log/
192194

193195
permissions:
194196
id-token: write
@@ -329,18 +331,14 @@ jobs:
329331
"$NEXTSTRAIN_GITHUB_DIR"/bin/interpolate-env < "$NEXTSTRAIN_GITHUB_DIR"/text-templates/attach-aws-batch.md \
330332
> "$GITHUB_STEP_SUMMARY"
331333

332-
- if: always()
334+
- if: ${{ always() && !env.AWS_BATCH_JOB_ID }}
333335
uses: actions/upload-artifact@v7
334336
with:
335337
if-no-files-found: warn
336338
name: ${{ inputs.artifact-name }}
337339
path: |
338340
${{ env.NEXTSTRAIN_BUILD_LOG }}
339-
auspice/
340-
results/
341-
benchmarks/
342-
logs/
343-
.snakemake/log/
341+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
344342
${{ inputs.artifact-paths }}
345343

346344
outputs:
@@ -366,20 +364,31 @@ jobs:
366364
name: Attach to AWS Batch job
367365
env:
368366
AWS_BATCH_JOB_ID: ${{ needs.run-build.outputs.AWS_BATCH_JOB_ID }}
367+
ARTIFACT_PATHS: ${{ inputs.artifact-paths }}
369368
run: |
370369
# Using timeout to detach from build before we hit the job.timeout-minutes
371370
# to avoid cancelling the job in order to avoid a "Cancelled" status
372371
# for the whole workflow.¹ Using SIGINT to ensure that the GH Action
373372
# cleanly detaches from the build without cancelling it.²
374373
# ¹ <https://github.com/nextstrain/.github/issues/129#issuecomment-2956350306>
375374
# ² <https://github.com/nextstrain/.github/pull/134#discussion_r2325804695>
375+
376+
# Set download args for default and custom artifact paths, skipping
377+
# blank lines. Append directories with ** to match files within.
378+
download_args=()
379+
while IFS= read -r line; do
380+
[[ -z "$line" ]] && continue
381+
[[ "$line" == */ ]] && line+='**'
382+
download_args+=(--download "$line")
383+
done <<< "${NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS}${ARTIFACT_PATHS}"
384+
376385
exit_status=0
377386
timeout --signal INT 359m \
378387
nextstrain build \
379388
--aws-batch \
380389
--attach "$AWS_BATCH_JOB_ID" \
381390
--detach-on-interrupt \
382-
--no-download || exit_status=$?
391+
"${download_args[@]}" . || exit_status=$?
383392

384393
if [[ $exit_status == 0 ]]; then
385394
conclusion="success"
@@ -396,6 +405,15 @@ jobs:
396405
echo "conclusion=$conclusion" | tee -a "$GITHUB_OUTPUT"
397406
exit $exit_status
398407

408+
- if: ${{ always() && steps.attach.outputs.conclusion != 'timeout' }}
409+
uses: actions/upload-artifact@v7
410+
with:
411+
if-no-files-found: warn
412+
name: ${{ inputs.artifact-name }}
413+
path: |
414+
${{ env.NEXTSTRAIN_DEFAULT_ARTIFACT_PATHS }}
415+
${{ inputs.artifact-paths }}
416+
399417
# Emit a "conclusion" output for the job that's based on the conclusion
400418
# (success, timeout, failure) of the "attach" step above.
401419
# This is the conclusion we care about for the job.

0 commit comments

Comments
 (0)