web_bonsaiの日記

web開発の学習日記です。誰に見せるためでもないただの日記です。

frontendのテストをGitHubActionsで実行できるようにする | Mac + Docker + Rails + Next.js その0039

参考にさせていただいたページ

actions/cache公式

その他

.github/workflows/frontend_workflow.ymlの作成とその記述内容

% vim .github/workflows/frontend_workflow.yml

記述内容は以下の通りです。

name: Rails Test Workflow
on: push
jobs:
  frontend-spec:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v3
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install Dependencies
        run: yarn --cwd frontend install --prefer-offline
      - name: yarn test:ci
        run: yarn --cwd frontend test:ci