Skip to content

Commit 7bde9f6

Browse files
committed
github: add ability to "unskip" skipped tests
1 parent bd68346 commit 7bde9f6

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/workflows/spread-results-reporter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ jobs:
162162
163163
if find . -name skipped_tests_list.txt | grep -q .; then
164164
echo "## Skipped tests from [snapd-testing-skip](https://github.com/canonical/snapd-testing-skip)" >> report
165+
echo "*If you wish to have any of the below tests run in your PR, in your PR description, add 'unskip:' followed by a copy-and-pasted list of the below tests you wish to run*" >> report
165166
find . -name skipped_tests_list.txt -exec cat {} \; | tr ' ' '\n' | grep . | sort -u | awk '{print "- "$1}' >> report
166167
fi
167168

.github/workflows/spread-tests.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ jobs:
240240
printf "" > "$RUN_TESTS_FILE"
241241
fi
242242
243+
- name: Check un-skip tests in PR description
244+
if: ${{ github.event.pull_request.number != "" }}
245+
run: |
246+
body="$(gh pr view ${{ github.event.pull_request.number }} --json body --jq .body)"
247+
248+
# Grab "unskip:" and the following lines that start with "-".
249+
unskip_yaml="$(
250+
grep -ozP '(?ms)^[[:space:]]*unskip:[[:space:]]*\n(?:[[:space:]]*-[^\n]*\n?)*' <<<"$body" |
251+
tr '\0' '\n' || true
252+
)"
253+
if [ -z "$unskip_yaml" ]; then
254+
exit 0
255+
fi
256+
257+
mapfile -t unskip_tests < <(printf '%s\n' "$unskip_yaml" | yq -r '.unskip[]')
258+
UNSKIP_TESTS="${unskip_tests[*]}"
259+
260+
if [ -z "$UNSKIP_TESTS" ]; then
261+
exit 0
262+
fi
263+
264+
echo "UNSKIP_TESTS=$UNSKIP_TESTS" >> "$GITHUB_ENV"
265+
266+
243267
- name: Checkout snapd-testing-skip
244268
if: ${{ env.SKIP_SPREAD_LABEL != 'true' && env.RUN_TESTS == 'true' }}
245269
uses: actions/checkout@v6
@@ -273,6 +297,13 @@ jobs:
273297
backend=$(yq -r '."spread-backend" // ".*"' "$file")
274298
if [[ "$expire" > "$today" ]] && grep -Eq "$system" <<<"${{ inputs.systems }}" && grep -Eq "^$backend$" <<<"$SPREAD_BACKEND"; then
275299
task=$(yq -r '."spread-task"' "$file")
300+
for unskip_test in ${UNSKIP_TESTS:-}; do
301+
if [[ "$unskip_test" == "$backend:$system:$task" ]]; then
302+
echo "Ignoring skip rule for $backend:$system:$task due to unskip entry"
303+
continue 2
304+
fi
305+
done
306+
276307
SNAPD_TESTS_SKIP="${SNAPD_TESTS_SKIP} $(echo "$spread_list" | tr ' ' '\n' | grep "$task$" | tr '\n' ' ')"
277308
spread_list=$(echo "$spread_list" | tr ' ' '\n' | grep -vE "$task$" | tr '\n' ' ')
278309
echo "$spread_list" > "$RUN_TESTS_FILE"

0 commit comments

Comments
 (0)