|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + |
| 5 | + pull_request: |
| 6 | + branches: [ main ] |
| 7 | + |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + # Runs the workflow once per day at 3:15am |
| 12 | + schedule: |
| 13 | + - cron: '3 16 * * *' |
| 14 | + |
| 15 | +env: |
| 16 | + CACHE_NUMBER: 1 # increase to reset cache manually |
| 17 | + SNAKEMAKE_RESULT_FILE: metadata4ing_provenance |
| 18 | + PROVENANACE_FILE_NAME: element_size_vs_max_mises_stress.pdf |
| 19 | + |
| 20 | +jobs: |
| 21 | + run-simulation: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: checkout repo content |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Setup Mambaforge |
| 28 | + uses: conda-incubator/setup-miniconda@v3 |
| 29 | + with: |
| 30 | + miniforge-version: latest |
| 31 | + activate-environment: model-validation |
| 32 | + use-mamba: true |
| 33 | + |
| 34 | + - name: Set strict channel priority |
| 35 | + run: conda config --set channel_priority strict |
| 36 | + |
| 37 | + - name: Update environment |
| 38 | + run: mamba env update -n model-validation -f environment_benchmarks.yml |
| 39 | + |
| 40 | + - name: generate-config-files |
| 41 | + shell: bash -l {0} |
| 42 | + run: | |
| 43 | + cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/ |
| 44 | + python generate_config.py |
| 45 | +
|
| 46 | + - name: run_linear-elastic-plate-with-hole-benchmarks_snakemake |
| 47 | + shell: bash -l {0} |
| 48 | + run: | |
| 49 | + cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/ |
| 50 | + snakemake --use-conda --force --cores 'all' |
| 51 | + snakemake --use-conda --force --cores all \ |
| 52 | + --reporter metadata4ing \ |
| 53 | + --report-metadata4ing-paramscript ../common/parameter_extractor.py \ |
| 54 | + --report-metadata4ing-config metadata4ing.config \ |
| 55 | + --report-metadata4ing-filename $SNAKEMAKE_RESULT_FILE |
| 56 | +
|
| 57 | + - name: run_linear-elastic-plate-with-hole-benchmarks_nextflow |
| 58 | + shell: bash -l {0} |
| 59 | + run: | |
| 60 | + cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/ |
| 61 | + nextflow run main.nf -params-file workflow_config.json -c ../common/nextflow.config -plugins nf-prov@1.4.0 |
| 62 | +
|
| 63 | + - name: Archive Linear Elastic plate with a hole benchmark data for snakemake |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: snakemake_results_linear-elastic-plate-with-hole |
| 67 | + path: | |
| 68 | + benchmarks/linear-elastic-plate-with-hole/${{ env.SNAKEMAKE_RESULT_FILE }}.zip |
| 69 | +
|
| 70 | + - name: Archive Linear Elastic plate with a hole benchmark data for nextflow |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: nextflow_results_linear-elastic-plate-with-hole |
| 74 | + path: | |
| 75 | + benchmarks/linear-elastic-plate-with-hole/nextflow_results/ |
| 76 | +
|
| 77 | + process-artifacts: |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: run-simulation |
| 80 | + steps: |
| 81 | + - name: Checkout repo content |
| 82 | + uses: actions/checkout@v2 |
| 83 | + |
| 84 | + - name: Download artifact |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + name: snakemake_results_linear-elastic-plate-with-hole |
| 88 | + path: ./artifact_files |
| 89 | + |
| 90 | + - name: Unzip Snakemake Result File |
| 91 | + run: | |
| 92 | + mkdir -p ./$SNAKEMAKE_RESULT_FILE |
| 93 | + unzip -o ./artifact_files/$SNAKEMAKE_RESULT_FILE.zip -d ./$SNAKEMAKE_RESULT_FILE |
| 94 | +
|
| 95 | + - name: Setup Mambaforge with postprocessing env |
| 96 | + uses: conda-incubator/setup-miniconda@v3 |
| 97 | + with: |
| 98 | + miniforge-version: latest |
| 99 | + activate-environment: postprocessing |
| 100 | + use-mamba: true |
| 101 | + environment-file: benchmarks/linear-elastic-plate-with-hole/environment_postprocessing.yml |
| 102 | + |
| 103 | + - name: Validate Snakemake Result File |
| 104 | + shell: bash -l {0} |
| 105 | + run: | |
| 106 | + python benchmarks/common/validate_provenance.py \ |
| 107 | + --provenance_folderpath "./$SNAKEMAKE_RESULT_FILE" |
| 108 | +
|
| 109 | + - name: Run plotting script |
| 110 | + shell: bash -l {0} |
| 111 | + run: | |
| 112 | + python benchmarks/linear-elastic-plate-with-hole/plot_metrics.py \ |
| 113 | + --provenance_folderpath "./$SNAKEMAKE_RESULT_FILE" \ |
| 114 | + --output_file $PROVENANACE_FILE_NAME |
| 115 | +
|
| 116 | + - name: Upload snakemake results file as artifact |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: element-size-vs-stress-plot |
| 120 | + path: ${{ env.PROVENANACE_FILE_NAME }} |
| 121 | + |
| 122 | + - name: Re-zip snakemake result folder |
| 123 | + run: | |
| 124 | + cd "./${SNAKEMAKE_RESULT_FILE}" |
| 125 | + zip -r "../${SNAKEMAKE_RESULT_FILE}.zip" . |
| 126 | +
|
| 127 | + - name: Upload RoCrate Zip file onto RoHub |
| 128 | + id: rohub_upload |
| 129 | + shell: bash -l {0} |
| 130 | + continue-on-error: true |
| 131 | + run: | |
| 132 | + LOG_FILE=rohub_upload_error.log |
| 133 | +
|
| 134 | + # Run Python and capture all stdout+stderr |
| 135 | + python benchmarks/common/upload_provenance.py \ |
| 136 | + --provenance_folderpath "./${SNAKEMAKE_RESULT_FILE}.zip" \ |
| 137 | + --benchmark_name "linear-elastic-plate-with-hole" \ |
| 138 | + --username "${{ secrets.ROHUB_USERNAME }}" \ |
| 139 | + --password "${{ secrets.ROHUB_PASSWORD }}" \ |
| 140 | + 2>&1 | tee "$LOG_FILE" |
| 141 | +
|
| 142 | + PYTHON_EXIT_CODE=${PIPESTATUS[0]} |
| 143 | +
|
| 144 | + # Check exit code: 0 = failure, 1 = success (per your convention) |
| 145 | + if [ $PYTHON_EXIT_CODE -eq 0 ]; then |
| 146 | + echo "=== RoHub upload failed — see log below ===" |
| 147 | + cat "$LOG_FILE" |
| 148 | + else |
| 149 | + echo "✅ RoHub upload succeeded" |
| 150 | + rm -f "$LOG_FILE" |
| 151 | + fi |
| 152 | +
|
| 153 | + # Export exit code for subsequent steps if needed |
| 154 | + echo "python_exit_code=$PYTHON_EXIT_CODE" >> $GITHUB_ENV |
| 155 | + |
| 156 | + - name: Upload RoHub error log |
| 157 | + if: ${{ env.python_exit_code == '0' }} |
| 158 | + uses: actions/upload-artifact@v4 |
| 159 | + with: |
| 160 | + name: rohub-upload-error-log |
| 161 | + path: rohub_upload_error.log |
| 162 | + |
0 commit comments