From c7f74aa211b1cfeaaf7e1928259b237fdb37abc4 Mon Sep 17 00:00:00 2001 From: Hammad Jutt Date: Sun, 26 Jul 2020 10:50:06 -0600 Subject: [PATCH] Setup CI to run linting / typechecking / unit testing with Github Actions --- .github/workflows/PR-CI.yml | 38 +++++++++++++++++++++++++++++ package.json | 1 + packages/app-react/package.json | 1 - packages/app-react/src/App.test.tsx | 10 -------- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/PR-CI.yml delete mode 100644 packages/app-react/src/App.test.tsx diff --git a/.github/workflows/PR-CI.yml b/.github/workflows/PR-CI.yml new file mode 100644 index 00000000..3b242815 --- /dev/null +++ b/.github/workflows/PR-CI.yml @@ -0,0 +1,38 @@ +name: TheGame CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + test: + name: Run Tests + runs-on: ubuntu-latest + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.4.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - name: Install packages + run: yarn --frozen-lockfile + - name: Linting + run: yarn lint + - name: Typechecking + run: yarn typecheck + - name: Testing + run: yarn test + env: + CI: true diff --git a/package.json b/package.json index c5292e35..88301278 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "hasura:migrate:init": "npm run hasura migrate create \"init\" -- --from-server", "hasura:migrate:apply": "npm run hasura migrate apply", "test": "lerna run test --parallel", + "test:full": "yarn lint && yarn typecheck && yarn test", "clean": "lerna clean", "format": "prettier --ignore-path .gitignore --write \"{*,**/*}.{ts,tsx,js,jsx,json,yml,yaml,md}\"", "lint": "eslint --ignore-path .gitignore \"./packages/**/*.{ts,tsx,js,jsx}\"", diff --git a/packages/app-react/package.json b/packages/app-react/package.json index 5cceb99c..f5ae48dc 100644 --- a/packages/app-react/package.json +++ b/packages/app-react/package.json @@ -6,7 +6,6 @@ "start": "react-scripts start", "build": "react-scripts build", "dev": "yarn start", - "test": "react-scripts test", "eject": "react-scripts eject", "typecheck": "tsc --noEmit", "precommit": "yarn lint-staged" diff --git a/packages/app-react/src/App.test.tsx b/packages/app-react/src/App.test.tsx deleted file mode 100644 index b95b1bd4..00000000 --- a/packages/app-react/src/App.test.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { render } from '@testing-library/react'; -import React from 'react'; - -import { App } from './App'; - -test('renders learn react link', () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -});