Fix Storybook tests on CI aborts early #5
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
# SPDX-FileCopyrightText: 2024 Shota FUJI <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
name: Build and deploy web application | ||
on: | ||
push: | ||
# Runs on every push | ||
branches: | ||
- "*" | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Gleam | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: "27" | ||
gleam-version: "1.4" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Build the app | ||
run: "bun run build --base '/${{ github.event.repository.name }}/'" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: main | ||
path: dist | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Gleam | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: "27" | ||
gleam-version: "1.4" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Check TypeScript types | ||
run: "bunx tsc" | ||
- name: Check Gleam types | ||
run: "gleam check" | ||
build-player-storybook: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Gleam | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: "27" | ||
gleam-version: "1.4" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Build Storybook | ||
run: "bun run build:storybook/player" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: player-storybook | ||
path: storybook-static/player | ||
build-builder-storybook: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Gleam | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: "27" | ||
gleam-version: "1.4" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Build Storybook | ||
run: "bun run build:storybook/builder" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: builder-storybook | ||
path: storybook-static/builder | ||
prep-artifact-for-pages: | ||
# Deploy only on master branch | ||
if: github.ref == 'refs/heads/master' | ||
needs: | ||
- build | ||
- build-player-storybook | ||
- build-builder-storybook | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download main artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
name: main | ||
- name: Download sub artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
pattern: "!main" | ||
- name: Upload artifact for Pages | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: artifacts | ||
deploy: | ||
# Deploy only on master branch | ||
if: github.ref == 'refs/heads/master' | ||
concurrency: | ||
group: deploy-ghpages | ||
needs: | ||
- check | ||
- prep-artifact-for-pages | ||
- test-storybook | ||
Check failure on line 139 in .github/workflows/build.yml GitHub Actions / Build and deploy web applicationInvalid workflow file
|
||
permissions: | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
test-player-storybook: | ||
needs: | ||
- build-player-storybook | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download built Storybook | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: "storybook-static" | ||
name: "player-storybook" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
# Needs Node.js since bunx is not compatible with npx | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22.x" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Setup Playwright | ||
run: "npx playwright install --with-deps" | ||
- name: Run tests | ||
run: | | ||
npx concurrently -k -s first -n "SB,TEST" \ | ||
"npx http-server storybook-static --port 6006 --silent" \ | ||
"npx wait-on tcp:6006 && bun run test:storybook/player --browsers chromium,firefox,webkit" | ||
test-builder-storybook: | ||
needs: | ||
- build-builder-storybook | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download built Storybook | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: "storybook-static" | ||
name: "builder-storybook" | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: "1.1" | ||
# Needs Node.js since bunx is not compatible with npx | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22.x" | ||
- name: Install dependencies | ||
run: "bun i" | ||
- name: Setup Playwright | ||
run: "npx playwright install --with-deps" | ||
- name: Run tests | ||
run: | | ||
npx concurrently -k -s first -n "SB,TEST" \ | ||
"npx http-server storybook-static --port 6007 --silent" \ | ||
"npx wait-on tcp:6007 && bun run test:storybook/builder --browsers chromium,firefox,webkit" | ||
cleanup: | ||
needs: | ||
- deploy | ||
- test-storybook | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete artifacts | ||
uses: geekyeggo/delete-artifact@v5 | ||
with: | ||
name: "*" |