Feature#79: MSW 설정 #38
Workflow file for this run
This file contains hidden or 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: Run Tests | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: ["main", "develop"] | |
| types: [opened, reopened, synchronize] | |
| jobs: | |
| lint: | |
| name: Compile & Lint | |
| runs-on: roomfit | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Cache node_modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install Yarn Package Manager | |
| run: npm install -g yarn | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Compile Typescript | |
| run: npx tsc --noEmit | |
| - name: Run lint | |
| run: yarn lint | |
| unit-test: | |
| name: Unit Test | |
| runs-on: roomfit | |
| needs: lint | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Cache node_modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install Yarn Package Manager | |
| run: npm install -g yarn | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Run tests | |
| run: yarn test | |
| ui-test: | |
| name: Storybook UI Test | |
| runs-on: roomfit | |
| needs: unit-test | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Cache node_modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install Yarn Package Manager | |
| run: npm install -g yarn | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build Storybook | |
| run: yarn build-storybook | |
| - name: Create Preview | |
| id: chromatic | |
| uses: chromaui/action@latest | |
| with: | |
| projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
| onlyChanged: true | |
| autoAcceptChanges: false | |
| exitOnceUploaded: true | |
| - name: Comment Storybook and Chromatic URLs on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const storybookUrl = '${{ steps.chromatic.outputs.url }}'; | |
| const chromaticBuildUrl = '${{ steps.chromatic.outputs.buildUrl }}'; | |
| const prNumber = context.payload.pull_request.number; | |
| let commentBody = ''; | |
| if (!storybookUrl) console.warn('Storybook URL not found.'); | |
| else commentBody += `📖 **Storybook Preview:** ${storybookUrl}\n`; | |
| if (!chromaticBuildUrl) console.warn('Chromatic Build URL not found.'); | |
| else commentBody += `🔍 **Chromatic Review:** ${chromaticBuildUrl}\n`; | |
| if (!commentBody) console.warn('No URLs available to comment.'); | |
| else { | |
| await github.rest.issues.createComment({ | |
| ...context.repo, | |
| issue_number: prNumber, | |
| body: commentBody, | |
| }); | |
| console.log('Storybook and Chromatic URLs commented on PR.'); | |
| } |