diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index 9d4171a..bd4e09a 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -4,13 +4,6 @@ on: pull_request: branches: - master - paths: - - .github/workflows/ci_pr.yml - - FastMoq/ - - FastMoq.Core/ - - FastMoq.Web/ - - FastMoq.Tests/ - - FastMoq.Tests.Web/ jobs: call-template: diff --git a/.github/workflows/publish_pages.yml b/.github/workflows/publish_pages.yml index 6d3732d..99d5c51 100644 --- a/.github/workflows/publish_pages.yml +++ b/.github/workflows/publish_pages.yml @@ -1,20 +1,57 @@ name: Publish Pages +# Required permissions for GitHub Pages OIDC deployment token +permissions: + contents: read # to fetch the repository + pages: write # to publish to Pages + id-token: write # to request the OIDC token (fixes ACTIONS_ID_TOKEN_REQUEST_URL error) + on: + push: + branches: [ master ] + paths: + - '.github/workflows/publish_pages.yml' + - 'Help/**' + - 'docs/**' + workflow_dispatch: workflow_run: workflows: ["CI (master)"] types: - completed +# Ensure only one Pages deployment runs at a time +concurrency: + group: pages + cancel-in-progress: false + jobs: deploy: - if: ${{ github.event.workflow_run.conclusion == 'success' }} + # Run this job for all events except 'workflow_run', and only for successful 'workflow_run' events. + if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest + timeout-minutes: 15 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: "Guard: Validate site content exists" + run: | + set -euo pipefail + if [ ! -d Help ]; then + echo "Help directory missing; aborting publish." >&2 + exit 1 + fi + if [ ! -f Help/index.html ] && [ ! -f Help/Index.html ]; then + echo "No index.html/Index.html in Help; aborting publish." >&2 + ls -al Help || true + exit 1 + fi + echo "Help directory and index file found. Proceeding." + - name: Setup Pages uses: actions/configure-pages@v5 diff --git a/.github/workflows/template_ci.yml b/.github/workflows/template_ci.yml index 276fefa..a76ba80 100644 --- a/.github/workflows/template_ci.yml +++ b/.github/workflows/template_ci.yml @@ -141,15 +141,53 @@ jobs: if: always() steps: - name: Aggregate matrix result + id: aggregate run: | echo "Aggregating test matrix results..." result='${{ needs.build-test.result }}' echo "Matrix overall result: $result" if [ "$result" != "success" ]; then - echo "One or more test legs failed. See individual build-test jobs." + echo "Matrix failed. See individual build-test jobs." >> $GITHUB_STEP_SUMMARY + echo "matrix-status=$result" >> $GITHUB_OUTPUT exit 1 fi - echo "All test legs passed." >> $GITHUB_STEP_SUMMARY + echo "matrix-status=$result" >> $GITHUB_OUTPUT echo "### Test Matrix Summary" >> $GITHUB_STEP_SUMMARY echo "All frameworks succeeded." >> $GITHUB_STEP_SUMMARY + - name: Download test artifacts + if: steps.aggregate.outputs.matrix-status == 'success' + uses: actions/download-artifact@v4 + with: + pattern: test-results-* + path: test-artifacts + merge-multiple: true + + - name: Coverage summary + if: steps.aggregate.outputs.matrix-status == 'success' + run: | + set -euo pipefail + shopt -s globstar nullglob + files=(test-artifacts/**/coverage.cobertura.xml) + if [ ${#files[@]} -eq 0 ]; then + echo "No coverage.cobertura.xml files found." >> $GITHUB_STEP_SUMMARY + exit 0 + fi + total_covered=0 + total_valid=0 + for f in "${files[@]}"; do + covered=$(sed -n 's/.*lines-covered="\([0-9]\+\)".*/\1/p' "$f" | head -n1 || echo 0) + valid=$(sed -n 's/.*lines-valid="\([0-9]\+\)".*/\1/p' "$f" | head -n1 || echo 0) + if [ -n "$covered" ] && [ -n "$valid" ]; then + total_covered=$(( total_covered + covered )) + total_valid=$(( total_valid + valid )) + fi + done + echo "### Coverage" >> $GITHUB_STEP_SUMMARY + if [ "$total_valid" -gt 0 ]; then + pct=$(awk -v c="$total_covered" -v v="$total_valid" 'BEGIN { if (v>0) printf "%.2f", (c/v)*100; }') + echo "Combined line coverage: ${pct}% (${total_covered}/${total_valid})" >> $GITHUB_STEP_SUMMARY + else + echo "Unable to compute coverage (no valid line counts)." >> $GITHUB_STEP_SUMMARY + fi +