support relative origin paths #14
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: Self Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - action.yml | |
| - README.md | |
| - .github/workflows/self-test.yml | |
| pull_request: | |
| paths: | |
| - action.yml | |
| - README.md | |
| - .github/workflows/self-test.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| integration: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Check out action source | |
| uses: actions/checkout@v4 | |
| with: | |
| path: action-src | |
| - name: Prepare local fixture repository | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git init --bare remote.git | |
| git init . | |
| git config user.email "ci@example.com" | |
| git config user.name "CI" | |
| git checkout -b main | |
| mkdir -p reports | |
| echo "initial" > reports/report.html | |
| git add reports/report.html | |
| git commit -m "init fixture" | |
| git remote add origin "remote.git" | |
| git push -u origin main | |
| git tag v-test | |
| git push origin v-test | |
| # Detached/tag-only commit (not contained by any remote branch) | |
| git checkout --detach | |
| echo "detached-only" > detached-only.txt | |
| git add detached-only.txt | |
| git commit -m "detached tag fixture" | |
| git tag v-detached | |
| git push origin v-detached | |
| git checkout main | |
| # Simulate a dirty tracked file before the action runs | |
| echo "dirty workspace" > reports/report.html | |
| # Ensure explicit branch validation does not depend on local origin/* refs | |
| git update-ref -d refs/remotes/origin/main || true | |
| - name: Run action with explicit branch on dirty workspace | |
| uses: ./action-src | |
| with: | |
| coverage: "81.2%" | |
| branch: main | |
| report: reports/report.html | |
| - name: Verify explicit branch run | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| test "$(cat reports/report.html)" = "dirty workspace" | |
| git --git-dir=remote.git rev-parse --verify refs/heads/coverage >/dev/null | |
| files="$(git --git-dir=remote.git ls-tree --name-only -r coverage)" | |
| echo "$files" | grep -Fx "main/badge.svg" | |
| echo "$files" | grep -Fx "main/report.html" | |
| - name: Run action in tag-triggered mode | |
| uses: ./action-src | |
| env: | |
| GITCOVERAGE_REF_TYPE: tag | |
| GITCOVERAGE_REF_NAME: v-test | |
| GITCOVERAGE_REF: refs/tags/v-test | |
| GITCOVERAGE_HEAD_REF: "" | |
| with: | |
| coverage: "82%" | |
| - name: Verify tag-triggered run | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git clone remote.git verify >/dev/null 2>&1 | |
| pushd verify >/dev/null | |
| git checkout coverage | |
| test -f main/badge.svg | |
| test ! -f main/report.html | |
| popd >/dev/null | |
| - name: Run action for detached tag (should fail) | |
| id: detached_tag | |
| continue-on-error: true | |
| uses: ./action-src | |
| env: | |
| GITCOVERAGE_REF_TYPE: tag | |
| GITCOVERAGE_REF_NAME: v-detached | |
| GITCOVERAGE_REF: refs/tags/v-detached | |
| GITCOVERAGE_HEAD_REF: "" | |
| with: | |
| coverage: "77%" | |
| - name: Verify detached tag run failed | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| test "${{ steps.detached_tag.outcome }}" = "failure" |