From 34e958c3a767820f582ae0f719b119bb271b302b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 8 May 2023 23:40:21 +0900 Subject: [PATCH 1/2] test: Storybook is broken --- packages/frontend/.storybook/preview.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/frontend/.storybook/preview.ts b/packages/frontend/.storybook/preview.ts index d91d76ff0f..e887acaa2e 100644 --- a/packages/frontend/.storybook/preview.ts +++ b/packages/frontend/.storybook/preview.ts @@ -46,7 +46,10 @@ function loadTheme(applyTheme: typeof import('../src/scripts/theme')['applyTheme function initLocalStorage() { localStorage.clear(); - localStorage.setItem('account', JSON.stringify(userDetailed())); + localStorage.setItem('account', JSON.stringify({ + ...userDetailed(), + policies: {}, + })); localStorage.setItem('locale', JSON.stringify(locale)); } From 3510768fd5507d72e89f6ae0939163cbda56aab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Tue, 9 May 2023 00:14:42 +0900 Subject: [PATCH 2/2] ci: check for PRs (#10804) * ci: check for PRs * ci: run all PRs * ci: fix syntax error * ci: comment on PRs only * ci: use pull_request_target --- .github/workflows/storybook.yml | 36 +++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index d5e6769bca..eb6ace27da 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -2,8 +2,10 @@ name: Storybook on: push: - branches-ignore: - - l10n_develop + branches: + - master + - develop + pull_request_target: jobs: build: @@ -17,6 +19,9 @@ jobs: with: fetch-depth: 0 submodules: true + - name: Checkout HEAD + if: github.event_name == 'pull_request' + run: git checkout ${{ github.head_ref }} - name: Install pnpm uses: pnpm/action-setup@v2 with: @@ -36,13 +41,13 @@ jobs: - name: Build storybook run: pnpm --filter frontend build-storybook - name: Publish to Chromatic - if: github.ref == 'refs/heads/master' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' run: pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static env: CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} - name: Publish to Chromatic - if: github.ref != 'refs/heads/master' - id: chromatic + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/master' + id: chromatic_push run: | DIFF="${{ github.event.before }} HEAD" if [ "$DIFF" = "0000000000000000000000000000000000000000 HEAD" ]; then @@ -55,16 +60,31 @@ jobs: pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static $(echo "$CHROMATIC_PARAMETER") env: CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + - name: Publish to Chromatic + if: github.event_name == 'pull_request' + id: chromatic_pull_request + run: | + DIFF="${{ github.base_ref }} HEAD" + if [ "$DIFF" = "0000000000000000000000000000000000000000 HEAD" ]; then + DIFF="HEAD" + fi + CHROMATIC_PARAMETER="$(node packages/frontend/.storybook/changes.js $(git diff-tree --no-commit-id --name-only -r $(echo "$DIFF") | xargs))" + if [ "$CHROMATIC_PARAMETER" = " --skip" ]; then + echo "skip=true" >> $GITHUB_OUTPUT + fi + pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static $(echo "$CHROMATIC_PARAMETER") + env: + CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} - name: Notify that Chromatic will skip testing uses: actions/github-script@v6.4.0 - if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop' && steps.chromatic.outputs.skip == 'true' + if: github.event_name == 'pull_request' && steps.chromatic_pull_request.outputs.skip == 'true' with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - github.rest.repos.createCommitComment({ + github.rest.issues.createComment({ + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - commit_sha: context.sha, body: 'Chromatic will skip testing but you may still have to [review the changes on Chromatic](https://www.chromatic.com/pullrequests?appId=6428f7d7b962f0b79f97d6e4).' }) - name: Upload Artifacts