From b6580c830d31021754da8af79c53989ec0cbeef6 Mon Sep 17 00:00:00 2001 From: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> Date: Fri, 12 May 2023 17:54:03 +0100 Subject: [PATCH] Fix workflow fails if job is not submitted (#10) Changes: - 'export' was succeeding, so the workflow passed. Now separates to two steps which should fail properly. - Add failing test --- .github/workflows/ci.yml | 18 ++++++++++++++++++ entrypoint.sh | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b450dff..41a3b5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,24 @@ jobs: | 😎 Workflow URL | ${{ steps.runs.outputs.workflowUrl }} | comment_tag: towerrun if: github.event_name == 'pull_request' + + - uses: ./ + id: runfails + continue-on-error: true + with: + pipeline: no_pipeline_exists + revision: master + workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }} + access_token: ${{ secrets.TOWER_ACCESS_TOKEN }} + compute_env: ${{ secrets.TOWER_COMPUTE_ENV }} + run_name: ${{ github.job }}_${{ github.sha }} + workdir: ${{ secrets.AWS_S3_BUCKET }}/work/${{ github.sha }} + + - name: Check Failure + if: steps.runfails.outcome == 'success' + run: | + echo "Failed to catch invalid pipeline submission: ${{ steps.runfails.outcome }}" + exit 1 - uses: actions/upload-artifact@v3 with: diff --git a/entrypoint.sh b/entrypoint.sh index f7a83d4..ad6643c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,7 +33,7 @@ if [ "$WAIT" = false ]; then unset WAIT; fi # Launch the pipeline # We use capture the JSON as variable $OUT. We encode it as base64 to get around Github secrets filters but we still mask it anyway to make sure the details don't leak. -export OUT=$(tw -o json -v \ +OUT=$(tw -o json -v \ launch \ $PIPELINE \ --params-file=params.json \ @@ -45,7 +45,7 @@ export OUT=$(tw -o json -v \ ${PRE_RUN_SCRIPT:+"--pre-run=pre_run.sh"} \ ${NEXTFLOW_CONFIG:+"--config=nextflow.config"} \ ${WAIT:+"--wait=$WAIT"} \ - 2>> $LOG_FN | tee -a $LOG_FN | base64 -w 0) + 2>> $LOG_FN | base64 -w 0) # Base64 decode and extract specific value for output export workflowId=$(echo $OUT | base64 -d | jq -r '.workflowId')