conveyal/transitive.js

View on GitHub
.github/workflows/node-ci.yml

Summary

Maintainability
Test Coverage
name: Node.js CI

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  test-build-release:
    env:
      IS_PUSH_TO_MASTER: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Install npm packages using cache
        uses: bahmutov/npm-install@v1
        with:
          # the IBI Group TSDX fork has some dependency issues
          # that cause yarn install to fail on a ci runner. Disabling
          # concurrency allows installation to complete successfully
          install-command: yarn --frozen-lockfile --network-concurrency 1
      - name: Lint code
        run: yarn lint
      - name: Run tests with coverage
        run: yarn cover

      # at this point, the build is successful
      - name: Semantic Release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: yarn semantic-release

      # Steps below deal with uploading Storybook to S3,
      # which is only performed with a push to the main branch.
      # Note that AWS CLI v2 is already installed by default on GitHub's Ubuntu 20.04.
      # per https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#cli-tools.
      - name: Add AWS credentials
        if: ${{ env.IS_PUSH_TO_MASTER == 'true' }}
        run: mkdir ~/.aws && printf '%s\n' '[default]' "aws_access_key_id=$AWS_ACCESS_KEY_ID" "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" "region=$AWS_REGION" > ~/.aws/config
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_REGION: ${{ secrets.AWS_REGION }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      # Deploy storybook demo to S3 if handling a push (non-PR build) on the main branch
      # https://s3.amazonaws.com/transitive.js/index.html
      - name: Deploy storybook to S3
        if: ${{ env.IS_PUSH_TO_MASTER == 'true' }}
        run: yarn deploy-storybook