Skip to content

Commit

Permalink
Merge pull request #78 from nextstrain/fix-ci-aws-batch
Browse files Browse the repository at this point in the history
pathogen-repo-build: Move `build.log` to ignored directory
  • Loading branch information
joverlee521 authored Apr 4, 2024
2 parents 5cd0ba1 + b9a9ae9 commit d15f4f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/pathogen-repo-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ on:
required: true
env:
NEXTSTRAIN_GITHUB_DIR: .git/nextstrain/.github
NEXTSTRAIN_BUILD_LOG: build.log
permissions:
id-token: write
jobs:
Expand Down Expand Up @@ -274,14 +275,20 @@ jobs:
# shellcheck disable=SC2154
set -x
eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee build.log
# tee build output to .git/ to avoid
# https://github.com/nextstrain/.github/issues/77#issuecomment-1998652064
# After build is complete, move .git/build.log to the working directory
# so this is kept as an implementation detail
eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee .git/"$NEXTSTRAIN_BUILD_LOG"
mv .git/"$NEXTSTRAIN_BUILD_LOG" "$NEXTSTRAIN_BUILD_LOG"
# Attempt to get the AWS Batch ID even if the run build command failed
# as long as the runtime is `aws-batch` and the `build.log` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles('build.log') != '' }}
# as long as the runtime is `aws-batch` and the `NEXTSTRAIN_BUILD_LOG` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles(env.NEXTSTRAIN_BUILD_LOG) != '' }}
name: Get AWS Batch job id
id: aws-batch
run: |
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < build.log)" | tee -a "$GITHUB_ENV"
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < "$NEXTSTRAIN_BUILD_LOG")" | tee -a "$GITHUB_ENV"
- if: ${{ always() && env.AWS_BATCH_JOB_ID }}
name: Generate AWS Batch summary
run: |
Expand All @@ -293,7 +300,7 @@ jobs:
if-no-files-found: warn
name: ${{ inputs.artifact-name }}
path: |
build.log
${{ env.NEXTSTRAIN_BUILD_LOG }}
auspice/
results/
benchmarks/
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/pathogen-repo-build.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ on:
logs/
.snakemake/log/

The "build.log" contains log messages from the `nextstrain build` command.
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).
Expand All @@ -160,6 +161,7 @@ on:

env:
NEXTSTRAIN_GITHUB_DIR: .git/nextstrain/.github
NEXTSTRAIN_BUILD_LOG: build.log

permissions:
id-token: write
Expand Down Expand Up @@ -240,15 +242,21 @@ jobs:
# shellcheck disable=SC2154
set -x

eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee build.log
# tee build output to .git/ to avoid
# https://github.com/nextstrain/.github/issues/77#issuecomment-1998652064
# After build is complete, move .git/build.log to the working directory
# so this is kept as an implementation detail
eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee .git/"$NEXTSTRAIN_BUILD_LOG"

mv .git/"$NEXTSTRAIN_BUILD_LOG" "$NEXTSTRAIN_BUILD_LOG"

# Attempt to get the AWS Batch ID even if the run build command failed
# as long as the runtime is `aws-batch` and the `build.log` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles('build.log') != '' }}
# as long as the runtime is `aws-batch` and the `NEXTSTRAIN_BUILD_LOG` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles(env.NEXTSTRAIN_BUILD_LOG) != '' }}
name: Get AWS Batch job id
id: aws-batch
run: |
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < build.log)" | tee -a "$GITHUB_ENV"
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < "$NEXTSTRAIN_BUILD_LOG")" | tee -a "$GITHUB_ENV"

- if: ${{ always() && env.AWS_BATCH_JOB_ID }}
name: Generate AWS Batch summary
Expand All @@ -262,7 +270,7 @@ jobs:
if-no-files-found: warn
name: ${{ inputs.artifact-name }}
path: |
build.log
${{ env.NEXTSTRAIN_BUILD_LOG }}
auspice/
results/
benchmarks/
Expand Down

0 comments on commit d15f4f9

Please sign in to comment.