Skip to content

Commit

Permalink
pathogen-repo-ci: Add build-dir input option
Browse files Browse the repository at this point in the history
With the development of the pathogen-repo-template¹, we are reorganizing
pathogen repositories to move workflows into their own directories.
This change in monkeypox² revealed that the pathogen-repo-ci workflow no
longer works with this new file organization because it expects
`nextstrain build` to run with the root of the pathogen repository.

This commit adds support for this change by allowing users to define
the directory to use for the `nextstrain build` command.

Changes are backwards compatible as the default is set to `.` to point
to the root of the pathogen repository.

¹ https://github.com/nextstrain/pathogen-repo-template
² nextstrain/mpox#198

Co-authored-by: Cornelius Roemer <[email protected]>
  • Loading branch information
joverlee521 and corneliusroemer committed Nov 6, 2023
1 parent 05a227b commit d340a70
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ jobs:
with:
repo: nextstrain/zika-tutorial

test-pathogen-repo-ci-with-build-dir:
uses: ./.github/workflows/pathogen-repo-ci.yaml
with:
repo: nextstrain/monkeypox
build-dir: phylogenetic
artifact-name: mpox-phylogenetic

test-pathogen-repo-ci-failure:
uses: ./.github/workflows/pathogen-repo-ci.yaml
with:
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/pathogen-repo-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ on:
- conda
required: false

build-dir:
description: >-
The directory used for `nextstrain build`.
If provided, example data should be in an `example_data` directory
relative to this directory.
Defaults to the root of the repository.
type: string
default: "."
required: false

artifact-name:
description: >-
Name to use for build results artifact uploaded at the end of the
Expand Down Expand Up @@ -94,12 +104,20 @@ jobs:
- id: inputs
env:
runtimes: ${{ inputs.runtimes }}
build_dir: ${{ inputs.build-dir }}
shell: bash
run: |
runtimes="$(yq --output-format=json --indent=0 . <<<"$runtimes")"
echo runtimes="$runtimes" | tee -a "$GITHUB_OUTPUT"
# Remove potential trailing slash and set default to current directory
build_dir="${build_dir%/}"
build_dir="${build_dir:-'.'}"
echo build_dir="$build_dir" | tee -a "$GITHUB_OUTPUT"
outputs:
runtimes: ${{ steps.inputs.outputs.runtimes }}
build_dir: ${{ steps.inputs.outputs.build_dir }}

build:
needs: configuration
Expand Down Expand Up @@ -228,6 +246,7 @@ jobs:
python-version: "3.7"

- name: Copy example data
working-directory: ${{ needs.configuration.outputs.build_dir }}
run: |
if [[ -d example_data ]]; then
mkdir -p data/
Expand All @@ -237,14 +256,15 @@ jobs:
fi
- run: nextstrain build . ${{ inputs.build-args }}
working-directory: ${{ needs.configuration.outputs.build_dir }}

- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}-${{ matrix.runtime }}
path: |
auspice/
results/
benchmarks/
logs/
.snakemake/log/
${{ needs.configuration.outputs.build_dir }}/auspice/
${{ needs.configuration.outputs.build_dir }}/results/
${{ needs.configuration.outputs.build_dir }}/benchmarks/
${{ needs.configuration.outputs.build_dir }}/logs/
${{ needs.configuration.outputs.build_dir }}/.snakemake/log/

0 comments on commit d340a70

Please sign in to comment.