Merge branch 'fix-test' of github.com:openwdl/wdl into fix-test #80
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: Sprocket Spec Conformance - WDL 1.2 | |
on: | |
push: | |
jobs: | |
sprocket-conformance: | |
runs-on: ubuntu-latest | |
name: Run Sprocket WDL 1.2 Spec Conformance Tests | |
steps: | |
- name: Checkout WDL spec repo (wdl-1.2) | |
uses: actions/checkout@v4 | |
with: | |
repository: openwdl/wdl | |
ref: wdl-1.2 | |
path: wdl-spec | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: | | |
pip install junit-xml subby | |
- name: Install Sprocket dependencies | |
run: | | |
curl -y --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |
. "$HOME/.cargo/env" | |
cargo install sprocket --locked | |
- 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 sprocket_test -v 1.2 | |
- name: Run tests and capture results | |
run: | | |
mkdir -p sprocket_tests/artifacts | |
echo "📊 Running tests..." | |
python wdl-tests/scripts/run_tests_sprocket.py \ | |
-T ${{ github.workspace }}/sprocket_test \ | |
-c ${{ github.workspace }}/sprocket_test/test_config.json \ | |
-D ${{ github.workspace }}/sprocket_test/data \ | |
-O sprocket_results | tee sprocket_tests/artifacts/result.log | |
echo "📊 Parsing test summary..." | |
total=$(grep "Total tests:" sprocket_tests/artifacts/result.log | awk '{print $3}') | |
passed=$(grep "Passed:" sprocket_tests/artifacts/result.log | awk '{print $2}') | |
warnings=$(grep "Warnings:" sprocket_tests/artifacts/result.log | awk '{print $2}') | |
failed=$(grep "Failures:" sprocket_tests/artifacts/result.log | awk '{print $2}') | |
invalid=$(grep "Invalid outputs:" sprocket_tests/artifacts/result.log | awk '{print $3}') | |
ignored=$(grep "Ignored:" sprocket_tests/artifacts/result.log | awk '{print $2}') | |
# Write summary JSON | |
cat <<EOF > sprocket_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 sprocket_test/failed_tests.txt sprocket_tests/artifacts/failed_tests.txt | |
# Generate shields.io badge JSON | |
color="green" | |
if [ "$passed" -lt "$total" ]; then color="yellow"; fi | |
if [ "$passed" -eq 0 ]; then color="red"; fi | |
cat <<EOF > sprocket_tests/artifacts/shields.json | |
{ | |
"schemaVersion": 1, | |
"label": "Sprocket WDL 1.2", | |
"message": "$passed/$total passed", | |
"color": "$color" | |
} | |
EOF | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sprocket-test-results | |
path: sprocket_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}" | |
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" | |
git fetch origin $BRANCH | |
git checkout $BRANCH | |
mkdir -p shields | |
cp sprocket_tests/artifacts/shields.json shields/sprocket_shields.json | |
git add shields/sprocket_shields.json | |
# Update README badge link only if needed | |
sed_pattern="https://raw.githubusercontent.com/openwdl/wdl/.*/shields/sprocket_shields.json" | |
new_url="https://raw.githubusercontent.com/openwdl/wdl/$BRANCH/shields/sprocket_shields.json" | |
if grep -qE "$sed_pattern" README.md; then | |
git pull | |
sed -E -i "/sprocket_shields\.json/s|$sed_pattern|$new_url|g" README.md | |
sed -E -i "/sprocket_shields\.json/s|$run_pattern|$new_run|g" README.md | |
git add README.md | |
fi | |
# Commit only if there are staged changes | |
if ! git diff --cached --quiet; then | |
git commit -m "chore: updates Sprocket shields badge for \`$BRANCH\`" | |
git push $REPO_URL $BRANCH | |
else | |
echo "🟢 No changes to commit" | |
fi |