Skip to content

specify files for all config #20

specify files for all config

specify files for all config #20

Workflow file for this run

name: Test Package
on:
pull_request:
branches:
- "**"
types:
- opened
- synchronize
- reopened
paths:
- "packages/**"
- "package.json"
- ".github/workflows/test.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
paths-filter:
name: Filter Changed Packages
runs-on: ubuntu-24.04
permissions:
pull-requests: read
timeout-minutes: 5
outputs:
eslint: ${{ steps.filter.outputs.eslint-config }}
prettier: ${{ steps.filter.outputs.prettier-config }}
stylelint: ${{ steps.filter.outputs.stylelint-config }}
directory: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
# package.json を含めているのはl、ビルド環境が変わった場合にすべてのパッケージをビルドするようにするため
filters: |
eslint-config:
- 'packages/eslint-config/**'
- 'package.json'
prettier-config:
- 'packages/prettier-config/**'
- 'package.json'
stylelint-config:
- 'packages/stylelint-config/**'
- 'package.json'
test:
needs: paths-filter
name: Vitest
if: ${{ needs.paths-filter.outputs.eslint == 'true' || needs.paths-filter.outputs.prettier == 'true' || needs.paths-filter.outputs.stylelint == 'true' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- run: corepack enable pnpm
- name: Setup Node.js 20.x
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version-file: "package.json"
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Test ESLint Config
id: eslint
if: ${{ needs.paths-filter.outputs.eslint == 'true' }}
continue-on-error: true
run: pnpm run build:eslint && pnpm run test --project eslint-config
- name: Test Prettier Config
id: prettier
if: ${{ needs.paths-filter.outputs.prettier == 'true' }}
continue-on-error: true
run: pnpm run build:prettier && pnpm run test --project prettier-config
- name: Test Stylelint Config
id: stylelint
if: ${{ needs.paths-filter.outputs.stylelint == 'true' }}
continue-on-error: true
run: pnpm run build:stylelint && test --project stylelint-config
- name: Comment if any Error
if: steps.eslint.outcome == 'failure' || steps.prettier.outcome == 'failure' || steps.stylelint.outcome == 'failure'
run: |
set -eu
# Create a comment body
cat << EOF > COMMENT.md
## 🚨 Snapshot test failed
See the details in the [workflow run details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
### Errors
EOF
if [ ${{ steps.eslint.outcome }} == 'failure' ]; then
echo "- ESLint" >> COMMENT.md
fi
if [ ${{ steps.prettier.outcome }} == 'failure' ]; then
echo "- Prettier" >> COMMENT.md
fi
if [ ${{ steps.stylelint.outcome }} == 'failure' ]; then
echo "- Stylelint" >> COMMENT.md
fi
echo -e "---\nIf these changes are expected, please update the snapshots by \`/update-snapshot\`." >> COMMENT.md
# Edit the last comment if it exists
gh pr comment ${{ github.event.pull_request.number }} --body-file COMMENT.md --edit-last \
|| gh pr comment ${{ github.event.pull_request.number }} --body-file COMMENT.md
env:
GH_TOKEN: ${{ github.token }}
- name: Mark as failure if any Error
if: steps.eslint.outcome == 'failure' || steps.prettier.outcome == 'failure' || steps.stylelint.outcome == 'failure'
run: |
echo "::error::Snapshot test failed."
exit 1