Fixed pattern. #76
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Toil WDL Spec Conformance - WDL 1.1 | |
| on: | |
| push: | |
| jobs: | |
| conformance: | |
| runs-on: ubuntu-latest | |
| name: Run WDL 1.1 Spec Conformance Tests | |
| steps: | |
| - name: Checkout WDL spec repo | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Toil WDL and dependencies | |
| run: | | |
| pip install toil[wdl] subby | |
| - name: Clone WDL tests | |
| run: | | |
| git clone https://github.com/openwdl/wdl-tests.git | |
| - name: Extract tests | |
| run: | | |
| python wdl-tests/scripts/extract_tests.py -i ${{ github.workspace }}/SPEC.md -d ${{ github.workspace }}/tests/data/ -O toil_test -v 1.1 | |
| - name: Run tests and capture results | |
| run: | | |
| mkdir -p toil_tests/artifacts | |
| echo "📊 Running tests..." | |
| python wdl-tests/scripts/run_tests_toil.py -T ${{ github.workspace }}/toil_test -c ${{ github.workspace }}/toil_test/test_config.json -D ${{ github.workspace }}/toil_test/data -O toil_results | tee toil_tests/artifacts/result.log | |
| echo "📊 Parsing test summary..." | |
| total=$(grep "Total tests:" toil_tests/artifacts/result.log | awk '{print $3}') | |
| passed=$(grep "Passed:" toil_tests/artifacts/result.log | awk '{print $2}') | |
| warnings=$(grep "Warnings:" toil_tests/artifacts/result.log | awk '{print $2}') | |
| failed=$(grep "Failures:" toil_tests/artifacts/result.log | awk '{print $2}') | |
| invalid=$(grep "Invalid outputs:" toil_tests/artifacts/result.log | awk '{print $3}') | |
| ignored=$(grep "Ignored:" toil_tests/artifacts/result.log | awk '{print $2}') | |
| # Write summary JSON | |
| cat <<EOF > toil_tests/artifacts/results.json | |
| { | |
| "total": $total, | |
| "passed": $passed, | |
| "warnings": $warnings, | |
| "failures": $failed, | |
| "invalid_outputs": $invalid, | |
| "ignored": $ignored | |
| } | |
| EOF | |
| # Copy list of failures to artifacts | |
| cp toil_test/failed_tests.txt toil_tests/artifacts/failed_tests.txt || touch toil_tests/artifacts/failed_tests.txt | |
| # Generate shields.io badge JSON | |
| color="green" | |
| total_run=$((total - ignored)) | |
| if [ "$passed" -lt "$total_run" ]; then color="yellow"; fi | |
| if [ "$passed" -eq 0 ]; then color="red"; fi | |
| cat <<EOF > toil_tests/artifacts/shields.json | |
| { | |
| "schemaVersion": 1, | |
| "label": "Toil WDL 1.1", | |
| "message": "$passed/$total_run passed", | |
| "color": "$color" | |
| } | |
| EOF | |
| - name: Upload test artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: toil-test-results | |
| path: toil_tests/artifacts/ | |
| - name: Publish badge JSON to current branch | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| BRANCH="${GITHUB_REF_NAME}" | |
| RUN_ID="${{ github.run_id }}" | |
| REPO="${{ github.repository }}" | |
| RUN_URL="https://github.com/$REPO/actions/runs/$RUN_ID" | |
| REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" | |
| git fetch origin $BRANCH | |
| git checkout $BRANCH | |
| mkdir -p shields | |
| cp toil_tests/artifacts/shields.json shields/toil_shields.json | |
| git add shields/toil_shields.json | |
| # Update README only if needed | |
| sed_pattern="https://raw.githubusercontent.com/openwdl/wdl/.*/shields/toil_shields.json" | |
| new_url="https://raw.githubusercontent.com/openwdl/wdl/$BRANCH/shields/toil_shields.json" | |
| run_pattern="https://github.com/$REPO/actions/runs/[0-9]+" | |
| new_run="https://github.com/$REPO/actions/runs/$RUN_ID" | |
| if grep -qE "$sed_pattern" README.md; then | |
| git pull | |
| sed -E -i "/toil_shields\.json/s|$sed_pattern|$new_url|g" README.md | |
| sed -E -i "/toil_shields\.json/s|$run_pattern|$new_run|g" README.md | |
| git add README.md | |
| fi | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: updates Toil WDL shields badge for \`$BRANCH\`" | |
| git push $REPO_URL $BRANCH | |
| else | |
| echo "🟢 No changes to commit" | |
| fi |