Skip to content

pre-release

pre-release #2082

name: Build & Test
on:
push:
branches: [main]
tags:
- release/*
- prerelease/*
pull_request:
types: [opened, synchronize]
env:
API_GATEWAY: "web-components.nylas.com/middleware"
CYPRESS_RECORD_KEY: ${{secrets.CYPRESS_RECORD_KEY}}
TZ: "America/Toronto"
jobs:
# single job that generates and outputs a common id
prepare:
runs-on: ubuntu-20.04
outputs:
uuid: ${{ steps.uuid.outputs.value }}
steps:
- name: Generate unique ID 💎
id: uuid
# take the current commit + timestamp together
# the typical value would be something like
# "sha-5d3fe...35d3-time-1620841214"
run: echo "::set-output name=value::sha-$GITHUB_SHA-time-$(date +"%s")"
- name: Print unique ID 🖨`
run: echo "generated id ${{ steps.uuid.outputs.value }}"
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: "https://registry.yarnpkg.com/"
- name: Install dependencies
run: npm install
- name: Build Components
run: yarn build
- name: Cache build
uses: actions/cache@v2
env:
cache-name: cache-build
id: cache-build
with:
path: ./*
key: ${{ github.sha }}
- name: Cache cypress
uses: actions/cache@v2
env:
cache-name: cache-cypress
id: cache-cypress
with:
path: /home/runner/.cache/Cypress/*
key: ${{ github.sha }}
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
needs: build
steps:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Run linter
run: npm run lint:ci
type-check:
runs-on: ubuntu-latest
strategy:
fail-fast: true
needs: build
steps:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "14"
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Run type-check
run: npm run tsc
test-unit:
runs-on: ubuntu-latest
strategy:
fail-fast: true
needs: build
steps:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "14"
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Run unit tests
run: npm run test
test-cypress:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7]
needs: ["build", "prepare"]
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- uses: actions/cache@v2
id: restore-cypress
with:
path: /home/runner/.cache/Cypress/*
key: ${{ github.sha }}
- name: Run cypress tests
uses: cypress-io/github-action@v2
with:
working-directory: .
record: true
parallel: true
install: false # disable npm install because we are already running it in previous step
start: npm run start:ci
wait-on: http://localhost:8000
wait-on-timeout: 30
ci-build-id: ${{ needs.prepare.outputs.uuid }}
publish:
needs: [build, lint, test-unit, type-check, test-cypress]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/prerelease') || startsWith(github.ref, 'refs/tags/release')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # This is how we have to set the NPM_TOKEN because the `actions/setup-node@v1` requires it.
steps:
- name: Check out source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set node version
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: "https://registry.yarnpkg.com/"
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Configure Git CI User
run: |
echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ${{ github.workspace }}/.npmrc
- name: Publish (canary)
if: contains(github.ref, 'prerelease') == true
run: |
npm run lerna -- publish from-git --no-verify-access --no-git-reset --dist-tag canary --canary --preid canary --yes
- name: Publish (stable)
if: contains(github.ref, 'prerelease') == false
run: |
npm run lerna -- publish from-git --no-verify-access --no-git-reset --yes