From 0c92d41d8f792bb1926470d185b64d9cc8f7d616 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 11 May 2023 16:56:17 +0200 Subject: [PATCH] :construction_worker: [#31] -- add running storybook tests to CI pipeline --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7077b58..4058aa1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,12 +101,46 @@ jobs: - name: Run ESLint run: yarn test:lint + tests: + name: Run Storybook tests + runs-on: ubuntu-latest + needs: + - storybook + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: yarn + + - name: Install dependencies + run: yarn install + + # Reference: https://storybook.js.org/docs/6.5/react/writing-tests/test-runner#run-against-non-deployed-storybooks + - name: Set up test environment + run: | + npx playwright install --with-deps + + - name: Download storybook artifact + uses: actions/download-artifact@v3 + with: + name: github-pages + path: storybook-static + + - name: Serve storybook and run tests + run: | + npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ + "npx http-server storybook-static --port 6006 --quiet" \ + "npx wait-on -l http://127.0.0.1:6006 && yarn test:storybook" + deploy: runs-on: ubuntu-latest needs: - storybook - prettier - eslint + - tests # do not run in forks & only publish main branch if: github.ref_name == 'main' && github.repository_owner == 'open-formulieren' @@ -135,6 +169,7 @@ jobs: - build-package - prettier - eslint + - tests # do not publish in forks or non-tag pushes if: startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'open-formulieren'