LoginSignup
7
5

More than 3 years have passed since last update.

JavaScriptのテストをCircleCIからGitHubActionsに移行する

Posted at

GitHubActionsを試してみましたがめちゃ便利ですね。早速今までCircleCIで動かしてたJavaScriptのテストをGitHubActionsで書き直してみました。

GitHubActionsのほうが並列実行に優れていて、値段も安いっぽいです。

CircleCI

.circleci/config.yml

version: 2
jobs:
  jstest:
    docker:
      - image: circleci/node:10

    environment:
      - NODE_ENV: test

    steps:
      - checkout
      - restore_cache:
          keys:
            - dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install-npm
          command: npm install
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: # run tests
          name: test
          command: npm test

workflows:
  version: 2
  workflow:
    jobs:
      - jstest

GitHub Actions

test.yml
name: JavaScript Test

on: [push]

jobs:
  build:
    name: JavaScript Test
    runs-on: ubuntu-latest

    steps:
      # assetsのビルド
      - uses: actions/checkout@v1
      - name: Set up Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 10.x
      - name: Build assets
        run: |
          npm install
          npm run prod

      # testの実行
      - name: Exec test
        run: npm run test

node_modulesキャッシュする部分だけ再現できていませんがほぼ同じ動きがすぐ再現出来たので楽ちんで良かったです。

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5