File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : quality-gate
2+
3+ on :
4+ pull_request :
5+
6+ permissions :
7+ contents : read
8+
9+ jobs :
10+ changed-file-quality-gate :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+ with :
15+ fetch-depth : 0
16+
17+ - name : detect changed source/test files
18+ id : diff
19+ shell : bash
20+ run : |
21+ set -euo pipefail
22+
23+ BASE_SHA="${{ github.event.pull_request.base.sha }}"
24+ HEAD_SHA="${{ github.event.pull_request.head.sha }}"
25+ CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
26+
27+ SOURCE="$(printf '%s\n' "$CHANGED" | grep -E '\.ts$' | grep -Ev '\.test\.ts$|^\.github/' || true)"
28+ TESTS="$(printf '%s\n' "$CHANGED" | grep -E '\.test\.ts$' || true)"
29+
30+ if [ -n "$SOURCE" ]; then
31+ echo "source_changed=true" >> "$GITHUB_OUTPUT"
32+ else
33+ echo "source_changed=false" >> "$GITHUB_OUTPUT"
34+ fi
35+
36+ if [ -n "$SOURCE" ] && [ -z "$TESTS" ]; then
37+ echo "::error::Source files changed without test updates. Add or update *.test.ts files."
38+ exit 1
39+ fi
40+
41+ - uses : denoland/setup-deno@v1
42+ if : steps.diff.outputs.source_changed == 'true'
43+ with :
44+ deno-version : v2.x
45+
46+ - run : deno check ./entrypoint.ts
47+ if : steps.diff.outputs.source_changed == 'true'
48+
49+ - run : deno test ./lib
50+ if : steps.diff.outputs.source_changed == 'true'
You can’t perform that action at this time.
0 commit comments