Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Setup Node and Yarn Dependencies
description: Configures Node.js, prepares Yarn config, restores cache, and installs dependencies.

inputs:
node-version:
description: Node.js version to use.
required: true

runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Yarn configuration
shell: bash
run: make .yarnrc.yml

- name: Cache dependencies
uses: actions/cache@v4
with:
path: .yarn
key: ${{ runner.OS }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-${{ inputs.node-version }}-yarn-

- name: Install dependencies
shell: bash
run: yarn install
173 changes: 138 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,156 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- '**'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pr-check:
runs-on: ubuntu-latest

outputs:
has_open_pr: ${{ steps.detect.outputs.has_open_pr }}

steps:
- name: Detect open pull request for current branch
id: detect
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail

if [[ "${{ github.event_name }}" != "push" || "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
exit 0
fi

branch="${GITHUB_REF#refs/heads/}"
head="${GITHUB_REPOSITORY_OWNER}:${branch}"
api_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"

count="$(
curl -fsSL \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
--get "${api_url}" \
--data-urlencode "state=open" \
--data-urlencode "head=${head}" \
--data-urlencode "per_page=1" \
| python3 -c 'import json,sys; print(len(json.load(sys.stdin)))'
)"

if [[ "${count}" -gt 0 ]]; then
echo "has_open_pr=true" >> "$GITHUB_OUTPUT"
else
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
fi

eslint:
needs: pr-check
if: github.event_name != 'push' || github.ref == 'refs/heads/main' || needs.pr-check.outputs.has_open_pr != 'true'
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 22.x ]
node-version: [ 22.x, 24.x ]

steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}

- name: Yarn configuration
run: make .yarnrc.yml
- name: Run eslint
run: yarn eslint

tests:
needs: eslint

timeout-minutes: 90

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 22.x, 24.x ]

steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4

- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
- name: Run tests
if: matrix.node-version != '24.x'
run: yarn test

- name: Install Playwright Chromium
if: matrix.node-version == '24.x'
run: yarn playwright install --with-deps chromium

- name: Run merged coverage
if: matrix.node-version == '24.x'
run: |
rm -rf coverage .nyc_output
mkdir -p coverage/.parts .nyc_output
yarn test --coverage --coverage.provider=istanbul --coverage.reporter=json --coverage.reportsDirectory=coverage/unit
yarn test:e2e:coverage
cp coverage/unit/coverage-final.json coverage/.parts/unit.json
cp coverage/e2e-react/coverage-final.json coverage/.parts/e2e-react.json
cp coverage/e2e-vue/coverage-final.json coverage/.parts/e2e-vue.json
yarn nyc merge coverage/.parts .nyc_output/coverage-final.json >/dev/null
yarn nyc report
yarn nyc report --reporter=json-summary >/dev/null
yarn node --experimental-strip-types scripts/show-total-coverage.ts

- name: Upload merged coverage artifacts
if: matrix.node-version == '24.x' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
path: .yarn
key: ${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-
name: coverage-node-24
path: |
coverage/lcov.info
coverage/coverage-summary.json
if-no-files-found: error

- name: Install dependencies
run: yarn install
codecov:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: tests

- name: Run eslint
run: yarn eslint
runs-on: ubuntu-latest

tests:
steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4

- name: Download merged coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-node-24
path: coverage

- name: Upload merged coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage/lcov.info
flags: combined
name: combined-coverage
fail_ci_if_error: true
verbose: true

storybook-tests:
needs: eslint

timeout-minutes: 60
Expand All @@ -50,31 +159,25 @@ jobs:

strategy:
matrix:
node-version: [ 22.x ]
node-version: [ 22.x, 24.x ]

steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}

- name: Yarn configuration
run: make .yarnrc.yml
- name: Build React Storybook
run: yarn workspace @modulify/m3-react storybook:build --test --quiet

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: .yarn
key: ${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-
- name: Build Vue Storybook
run: yarn workspace @modulify/m3-vue storybook:build --test --quiet

- name: Install dependencies
run: yarn install
- name: Run React Storybook smoke tests
run: yarn workspace @modulify/m3-react test:smoke

- name: Run tests
run: yarn test
- name: Run Vue Storybook smoke tests
run: yarn workspace @modulify/m3-vue test:smoke
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
!.yarnrc.yml.dist

coverage/
.nyc_output/
dist/
dist-storybook/
node_modules/
Expand Down
13 changes: 13 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"all": false,
"cache": false,
"check-coverage": false,
"temp-dir": ".nyc_output",
"report-dir": "coverage",
"reporter": [
"text",
"text-summary",
"html",
"lcovonly"
]
}
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ Global examples: eslint rule updates, shared dependency updates, repository-leve
`skills/yarn-lock-conflict-resolution/SKILL.md`.
- For coverage deficit analysis and recovery strategy, use the local skill:
`skills/coverage-recovery/SKILL.md`.
- For documentation creation or edits under `docs/` with locale parity, use the local skill:
`skills/docs-parity/SKILL.md`.
Loading