104 lines
2.6 KiB
YAML
104 lines
2.6 KiB
YAML
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"
|
|
- ".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"
|
|
- ".github/workflows/frontend-tests.yml"
|
|
- "!**/*.md"
|
|
- "!**/*.mdx"
|
|
- "!**/*.markdown"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
frontend:
|
|
name: Run Frontend Lint, Tests, and Build
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: apps
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v5
|
|
with:
|
|
version: "9.15.9"
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "24"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- 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
|
|
|
|
echo "Checking Prettier on changed files:"
|
|
echo "${CHANGED_FILES}"
|
|
echo "${CHANGED_FILES}" \
|
|
| sed 's#^apps/##' \
|
|
| 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
|