Skip to content

Commit

Permalink
add test github action
Browse files Browse the repository at this point in the history
  • Loading branch information
dlinah committed Jul 11, 2022
1 parent 18ab677 commit a310195
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/nowcasting-app-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Nowcasting App Tests
on:
push:
paths:
- 'apps/nowcasting-app/**'
jobs:
test:
name: Lint, typecheck & test
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/nowcasting-app
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "14"

# Cache node_modules for faster CI runs if the yarn.lock doesn't change change
- name: Get yarn cache directory path
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Restore yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn1-${{ hashFiles('../../yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn1-
# Throw an error if the yarn.lock file doesn't match the installed dependencies (rather than updating it in-place, which it does by default locally)
- name: Install
run: yarn install --frozen-lockfile --silent

- name: End-to-end tests (Cypress)
id: cypress
uses: cypress-io/github-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DB_LOG: false
NEXT_PUBLIC_ENV_NAME: test
with:
working-directory: apps/nowcasting-app
build: yarn build
start: yarn start:test
wait-on: http://localhost:3002

- name: End-to-end tests Record (Cypress)
if: failure() && steps.cypress.outcome == 'failure'
uses: cypress-io/github-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DB_LOG: false
NEXT_PUBLIC_ENV_NAME: test
# CYPRESS_PROJECT_ID: ---
# CYPRESS_RECORD_KEY: ----
with:
working-directory: apps/nowcasting-app
record: true
start: yarn start:test
wait-on: http://localhost:3002
5 changes: 4 additions & 1 deletion apps/nowcasting-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"private": true,
"scripts": {
"dev": "next dev -p 3002",
"test-srv": "cross-env NEXT_PUBLIC_ENV_NAME=test next dev -p 3002",
"dev:test": "cross-env NEXT_PUBLIC_ENV_NAME=test next dev -p 3002",
"start:test": "cross-env NEXT_PUBLIC_ENV_NAME=test next start -p 3002",
"build": "next build",
"start": "next start",
"cypress:open": "cypress open",
"cypress:headless": "cypress run --headless",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"lint": "next lint"
Expand Down

0 comments on commit a310195

Please sign in to comment.