-
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (169 loc) · 6.01 KB
/
Copy pathci.yml
File metadata and controls
191 lines (169 loc) · 6.01 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: CI
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "25"
- uses: gradle/actions/setup-gradle@v6
- name: Check
run: ./gradlew check
action-integration:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "25"
- uses: gradle/actions/setup-gradle@v6
- name: Set Up Fixture Files
shell: bash
run: |
set -euo pipefail
fixture_dir=".ci-action-fixture"
mkdir -p "${fixture_dir}"
cat > "${fixture_dir}/schema.rng" <<'EOF'
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="root">
<empty/>
</element>
</start>
</grammar>
EOF
cat > "${fixture_dir}/valid.xml" <<'EOF'
<?xml version="1.0"?>
<?xml-model href="schema.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<root/>
EOF
cat > "${fixture_dir}/manifest.txt" <<'EOF'
.ci-action-fixture/valid.xml
EOF
- name: Run Local Action With Directory Input
id: action-directory
uses: ./
with:
directory: .ci-action-fixture
json_report_path: .ci-action-fixture/report.json
jobs: 0
- name: Run Local Action With files_from Input
uses: ./
with:
files_from: .ci-action-fixture/manifest.txt
jobs: 0
- name: Assert Action Outputs
shell: bash
run: |
set -euo pipefail
test "${{ steps.action-directory.outputs.skipped }}" = "false"
test "${{ steps.action-directory.outputs.files_checked }}" = "1"
test "${{ steps.action-directory.outputs.failed_files }}" = "0"
test "${{ steps.action-directory.outputs.warning_count }}" = "0"
test "${{ steps.action-directory.outputs.json_report_path }}" = "${GITHUB_WORKSPACE}/.ci-action-fixture/report.json"
test -f .ci-action-fixture/report.json
jq -e '.summary.skipped == false' .ci-action-fixture/report.json >/dev/null
jq -e '.summary.filesChecked == 1' .ci-action-fixture/report.json >/dev/null
- name: Smoke Test changed_files_only for Push and Pull Request
shell: bash
run: |
set -euo pipefail
tmpdir="$(mktemp -d)"
repo="${tmpdir}/repo"
mkdir -p "${repo}"
cd "${repo}"
git init -q
git config user.name "CI"
git config user.email "ci@example.com"
cat > schema.rng <<'EOF'
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="root">
<empty/>
</element>
</start>
</grammar>
EOF
cat > valid.xml <<'EOF'
<?xml version="1.0"?>
<?xml-model href="schema.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<root/>
EOF
git add schema.rng valid.xml
git commit -qm "Base XML"
cat > "${repo}/changed.xml" <<'EOF'
<?xml version="1.0"?>
<?xml-model href="schema.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<root/>
EOF
before_sha="$(git rev-parse HEAD)"
git add changed.xml
git commit -qm "Changed XML"
cat > "${tmpdir}/push-event.json" <<EOF
{"before":"${before_sha}"}
EOF
XML_MODEL_VALIDATOR_WORKSPACE="${repo}" \
XML_MODEL_VALIDATOR_CACHE_HOME="${tmpdir}/cache" \
XML_MODEL_VALIDATOR_INPUT_CHANGED_FILES_ONLY="true" \
XML_MODEL_VALIDATOR_INPUT_CHANGED_SOURCE="git" \
GITHUB_EVENT_NAME="push" \
GITHUB_SHA="$(git rev-parse HEAD)" \
GITHUB_EVENT_PATH="${tmpdir}/push-event.json" \
XML_MODEL_VALIDATOR_INPUT_JOBS="0" \
bash "${GITHUB_WORKSPACE}/entrypoint.sh"
origin_repo="${tmpdir}/origin.git"
pr_repo="${tmpdir}/pr-repo"
git init -q --bare "${origin_repo}"
git clone -q "${origin_repo}" "${pr_repo}" 2>/dev/null
cd "${pr_repo}"
git config user.name "CI"
git config user.email "ci@example.com"
git checkout -qb main
cat > schema.rng <<'EOF'
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="root">
<empty/>
</element>
</start>
</grammar>
EOF
cat > base.xml <<'EOF'
<?xml version="1.0"?>
<?xml-model href="schema.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<wrong/>
EOF
git add schema.rng base.xml
git commit -qm "Base branch"
git push -q -u origin main
git checkout -qb feature
cat > pr-changed.xml <<'EOF'
<?xml version="1.0"?>
<?xml-model href="schema.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<root/>
EOF
echo note > note.txt
git add pr-changed.xml note.txt
git commit -qm "Feature branch"
XML_MODEL_VALIDATOR_WORKSPACE="${pr_repo}" \
XML_MODEL_VALIDATOR_CACHE_HOME="${tmpdir}/cache" \
XML_MODEL_VALIDATOR_INPUT_CHANGED_FILES_ONLY="true" \
XML_MODEL_VALIDATOR_INPUT_CHANGED_SOURCE="git" \
GITHUB_EVENT_NAME="pull_request" \
GITHUB_BASE_REF="main" \
GITHUB_SHA="$(git rev-parse HEAD)" \
XML_MODEL_VALIDATOR_INPUT_JOBS="0" \
bash "${GITHUB_WORKSPACE}/entrypoint.sh"