-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (131 loc) · 4.24 KB
/
self-test.yml
File metadata and controls
155 lines (131 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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@v6
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
# Branch used to verify Windows-only branch-name filtering.
# '=' is Git-valid but rejected by our Windows compatibility regex.
git branch 'feat=compat'
git push origin 'feat=compat'
# 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: Run action with Windows-restricted branch charset
id: windows_branch
continue-on-error: true
uses: ./action-src
with:
coverage: "80%"
branch: "feat=compat"
- name: Verify Windows-only branch filter
shell: bash
run: |
set -euo pipefail
if [[ "${RUNNER_OS}" == "Windows" ]]; then
test "${{ steps.windows_branch.outcome }}" = "failure"
else
test "${{ steps.windows_branch.outcome }}" = "success"
fi
- 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"