From 090a35eed9c09636f0eed601a9c0fd3848d439f2 Mon Sep 17 00:00:00 2001 From: John SJ Anderson Date: Fri, 31 May 2024 11:33:29 -0700 Subject: [PATCH] Refactor `pathogen-repo-ci` to be smarter [#89] --- .github/workflows/pathogen-repo-ci.yaml | 74 +++++++++++++++++++++--- actions/run-nextstrain-build/action.yaml | 38 ++++++++++++ 2 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 actions/run-nextstrain-build/action.yaml diff --git a/.github/workflows/pathogen-repo-ci.yaml b/.github/workflows/pathogen-repo-ci.yaml index a8ce20e..45a7471 100644 --- a/.github/workflows/pathogen-repo-ci.yaml +++ b/.github/workflows/pathogen-repo-ci.yaml @@ -232,16 +232,74 @@ jobs: with: runtime: ${{ matrix.runtime }} + - name: Run ingest + uses: nextstrain/.github/actions/run-nextstrain-build@update-ci-89 + with: + step: ingest + + # run: | + # if [[ -f nextstrain-pathogen.yaml && -f ingest/Snakefile && -f ingest/build-configs/ci/config.yaml ]]; then + # nextstrain build ingest --configfile build-configs/ci/config.yaml ${{ inputs.build-args }} + # else + # echo "Skipping ingest build due to one or more missing files." + # for i in nextstrain-pathogen.yaml ingest/Snakefile ingest/build-configs/ci/config.yaml; do + # ! test -f $i && echo missing $i + # done + # fi + + # - name: Upload ingest artifact + # if: always() + # uses: actions/upload-artifact@v4 + # with: + # name: ingest-${{ inputs.artifact-name }}-${{ matrix.runtime }} + # path: | + # ingest/results/ + # ingest/benchmarks/ + # ingest/logs/ + # ingest/.snakemake/log/ + + - name: Run phylogenetic + run: | + if [[ -f nextstrain-pathogen.yaml && -f phylogenetic/Snakefile && -f phylogenetic/build-configs/ci/config.yaml ]]; then + nextstrain build phylogenetic --configfile build-configs/ci/config.yaml ${{ inputs.build-args }} + else + echo "Skipping phylogenetic build due to one or more missing files." + for i in nextstrain-pathogen.yaml phylogenetic/Snakefile phylogenetic/build-configs/ci/config.yaml; do + ! test -f $i && echo missing $i + done + fi - - run: nextstrain build . ${{ inputs.build-args }} + - name: Upload phylogenetic artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: phylogenetic-${{ inputs.artifact-name }}-${{ matrix.runtime }} + path: | + phylogenetic/auspice/ + phylogenetic/results/ + phylogenetic/benchmarks/ + phylogenetic/logs/ + phylogenetic/.snakemake/log/ + + - name: Run nextclade + run: | + if [[ -f nextstrain-pathogen.yaml && -f nextclade/Snakefile && -f nextclade/build-configs/ci/config.yaml ]]; then + nextstrain build nextclade --configfile build-configs/ci/config.yaml ${{ inputs.build-args }} + else + echo "Skipping nextclade build due to one or more missing files." + for i in nextstrain-pathogen.yaml nextclade/Snakefile nextclade/build-configs/ci/config.yaml; do + ! test -f $i && echo missing $i + done + fi - - if: always() + - name: Upload nextclade artifact + if: always() uses: actions/upload-artifact@v4 with: - name: ${{ inputs.artifact-name }}-${{ matrix.runtime }} + name: nextclade-${{ inputs.artifact-name }}-${{ matrix.runtime }} path: | - auspice/ - results/ - benchmarks/ - logs/ - .snakemake/log/ + nextclade/auspice/ + nextclade/results/ + nextclade/benchmarks/ + nextclade/logs/ + nextclade/.snakemake/log/ diff --git a/actions/run-nextstrain-build/action.yaml b/actions/run-nextstrain-build/action.yaml new file mode 100644 index 0000000..14d54a8 --- /dev/null +++ b/actions/run-nextstrain-build/action.yaml @@ -0,0 +1,38 @@ +name: run-nextstrain-build +description: >- + Runs a single `nextstrain build` command in a given sub-directory of + a pathogen repo. Must be provided with the name of the + sub-directory. + +inputs: + step: + description: The name of the sub-directory to run the build from + type: string + required: true + +runs: + steps: + - name: Run ${{ inputs.step }} + env: + STEP: ${{ inputs.step }} + run: | + if [[ -f nextstrain-pathogen.yaml && -f $STEP/Snakefile && -f $STEP/build-configs/ci/config.yaml ]]; then + nextstrain build $STEP --configfile build-configs/ci/config.yaml + else + echo "Skipping $STEP build due to one or more missing files." + for i in nextstrain-pathogen.yaml $STEP/Snakefile $STEP/build-configs/ci/config.yaml; do + ! test -f $i && echo missing $i + done + fi + shell: bash + + - name: Upload ${{ inputs.step }} artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: ${{inputs.step }}-outputs-${{ matrix.runtime }} + path: | + ${{ inputs.step }}/results/ + ${{ inputs.step }}/benchmarks/ + ${{ inputs.step }}/logs/ + ${{ inputs.step }}/.snakemake/log/