forked from kdlbs/kandev
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (132 loc) · 5.02 KB
/
Copy pathfrontend-tests.yml
File metadata and controls
153 lines (132 loc) · 5.02 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
name: Frontend Tests
on:
push:
branches: [main]
paths:
- "apps/cli/**"
- "apps/package.json"
- "apps/prettier.config.mjs"
- "apps/.prettierignore"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- "apps/backend/go.mod"
- "apps/backend/go.sum"
- ".github/workflows/frontend-tests.yml"
- "!**/*.md"
- "!**/*.mdx"
- "!**/*.markdown"
pull_request:
branches: [main]
paths:
- "apps/cli/**"
- "apps/package.json"
- "apps/prettier.config.mjs"
- "apps/.prettierignore"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- "apps/backend/go.mod"
- "apps/backend/go.sum"
- ".github/workflows/frontend-tests.yml"
- "!**/*.md"
- "!**/*.mdx"
- "!**/*.markdown"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Least-privilege: the `frontend` job only reads source and runs tests.
# `packages: read` lets the container job pull the kandev-ci image from GHCR.
permissions:
contents: read
packages: read
jobs:
frontend:
name: Run Frontend Lint, Tests, and Build
runs-on: ubuntu-latest
# Pre-baked image bundles Node 24, pnpm 9.15.9, Go, and go-licenses —
# see .github/docker/ci-base/Dockerfile.
container: ghcr.io/kdlbs/kandev-ci:build-latest
defaults:
run:
# Container jobs default to `sh` (dash); pin to bash for `set -euo
# pipefail` and other bash-isms used by the formatting / licenses steps.
shell: bash
working-directory: apps
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Mark workspace safe for git
shell: bash
working-directory: ${{ github.workspace }}
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('apps/pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Regenerate OSS licenses manifest
run: pnpm --filter @kandev/web licenses:gen
- name: Verify licenses manifest is fresh
shell: bash
continue-on-error: true
run: |
set -euo pipefail
# `defaults.run.working-directory` is `apps`, so the path is relative.
# The diff is reported as a warning, not a hard failure: `go-licenses`
# resolves slightly different license metadata across platforms (macOS
# dev vs. ubuntu CI) for the same Go modules, and we have not yet
# eliminated that drift. The committed file is still the source of
# truth for what the page renders.
if ! git diff --quiet --exit-code web/generated/licenses.json; then
echo "::warning::apps/web/generated/licenses.json differs from a fresh re-run."
echo "::warning::Run 'pnpm --filter @kandev/web licenses:gen' and commit if the drift is real."
git --no-pager diff --stat web/generated/licenses.json || true
fi
- name: Check formatting
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
if [[ -z "${BASE_SHA}" || "${BASE_SHA}" == "0000000000000000000000000000000000000000" ]]; then
BASE_SHA="$(git rev-list --max-parents=0 HEAD)"
fi
CHANGED_FILES="$(
git diff --name-only --diff-filter=ACMRT "${BASE_SHA}"..."${{ github.sha }}" \
| grep -E '^apps/(web|cli|packages)/.*\.(ts|tsx|js|jsx|mjs|cjs|json|md|mdx|yml|yaml|css|scss)$' \
|| true
)"
if [[ -z "${CHANGED_FILES}" ]]; then
echo "No Prettier-scoped files changed."
exit 0
fi
# Skip symlinks — prettier errors with exit 123 when an explicit
# pattern is a symbolic link. CLAUDE.md files in the tree are symlinks
# to sibling AGENTS.md files (Codex / Claude Code convention).
FILES_TO_CHECK="$(
echo "${CHANGED_FILES}" \
| sed 's#^apps/##' \
| while IFS= read -r f; do [ -L "$f" ] || echo "$f"; done
)"
if [[ -z "${FILES_TO_CHECK}" ]]; then
echo "No non-symlink Prettier-scoped files changed."
exit 0
fi
echo "Checking Prettier on changed files:"
echo "${FILES_TO_CHECK}"
echo "${FILES_TO_CHECK}" | xargs pnpm exec prettier --check --ignore-unknown
- name: Run lint
run: pnpm --filter @kandev/web lint
- name: Run tests
run: pnpm --filter @kandev/web test
- name: Build
run: pnpm --filter @kandev/web build