chore: change CI workflow to avoid caching issues (#159) #658
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Build | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the main branch on Push and any branches on PR | |
push: | |
branches: [main,next] | |
pull_request_target: | |
jobs: | |
run: | |
name: Node ${{ matrix.node }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18, 20] | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 3 | |
- name: Set NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: 'pnpm' | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Run pnpm install dependencies | |
run: pnpm install | |
- run: pnpm --version | |
- name: Prettier Check | |
run: pnpm prettier:check | |
- name: Build Library | |
run: pnpm build:lib | |
- name: Build Website (GitHub demo site) | |
run: pnpm build:demo | |
- name: Install Playwright Browsers (chromium) | |
run: pnpm exec playwright install chromium | |
- name: Start HTTP Server | |
run: pnpm serve:demo & | |
- name: Find Playwright Summary Comment (when exist) | |
if: ${{ github.event.pull_request.number }} | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Playwright Summary | |
- name: Run Playwright E2E Tests | |
uses: mathiasvr/[email protected] | |
id: playwrightsummary | |
with: | |
run: pnpm test:e2e | |
- name: Define Playwright Outcome Text | |
id: pw_outcome | |
if: always() | |
run: | | |
if [ ${{ steps.playwrightsummary.outcome }} == 'failure' ]; then | |
printf "pw_outcome=Failure :rotating_light:" >> $GITHUB_OUTPUT | |
else | |
echo "pw_outcome=Success :tada:" >> $GITHUB_OUTPUT | |
fi | |
shell: bash | |
- name: Upsert Playwright Summary | |
if: | | |
github.event.pull_request.number && | |
always() | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## :performing_arts: Playwright Summary - ${{ steps.pw_outcome.outputs.pw_outcome }} | |
### [Playwright Report](https://ghiscoding.github.io/multiple-select-vanilla/playwright-report) | |
${{ steps.playwrightsummary.outputs.stdout }} ${{ steps.playwrightsummary.outputs.stderr }} | |
edit-mode: replace | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 15 | |
- name: Deploy Demo to gh-pages | |
if: | | |
github.ref == 'refs/heads/main' && | |
(contains(github.event.head_commit.message, 'chore(release)') || contains(github.event.head_commit.message, '[refresh gh-pages]')) | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./demo/dist | |
- name: Deploy Playwright Report | |
if: always() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
destination_dir: playwright-report | |
publish_dir: ./playwright-report |