Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Turborepo for tests and add turbo cache for CI eslint and unit-tests #3458

Merged
merged 5 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ jobs:
# Make sure eslint passes
eslint:
uses: Seneca-CDOT/telescope/.github/workflows/eslint-ci.yml@master
secrets:
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

# Run unit tests on all platforms/versions of node
unit:
uses: Seneca-CDOT/telescope/.github/workflows/unit-tests-ci.yml@master
secrets:
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

# Run end-to-end tests along with the microservices in docker-compose on Linux
e2e:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/eslint-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: ESLint Workflow

on:
workflow_call:
secrets:
server-token:
description: 'The Turborepo local server token'
required: true

jobs:
# Make sure eslint passes
Expand All @@ -14,7 +18,14 @@ jobs:
- uses: actions/[email protected]
with:
cache: 'pnpm'

- name: Turborepo local server
uses: felixmosh/turborepo-gh-artifacts@v1
with:
repo-token: ${{ github.token }}
server-token: ${{ secrets.server-token }}

- name: Install dependencies and run eslint
run: |
pnpm install
pnpm lint
pnpm turbo run lint --api="http://127.0.0.1:9080" --token="${{ secrets.server-token }}"
16 changes: 12 additions & 4 deletions .github/workflows/unit-tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Unit Tests Workflow

on:
workflow_call:
secrets:
server-token:
description: 'The Turborepo local server token'
required: true

jobs:
unit:
Expand All @@ -18,10 +22,14 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1

- name: Turborepo local server
uses: felixmosh/turborepo-gh-artifacts@v1
with:
repo-token: ${{ github.token }}
server-token: ${{ secrets.server-token }}

- name: Install dependencies and run tests with default env
run: |
pnpm install
# pnpm can't handle passing args through to run scripts: https://github.com/pnpm/pnpm/issues/2764
npm run jest --max-workers ${{ steps.cpu-cores.outputs.count }}
pnpm turbo run test --api="http://127.0.0.1:9080" --token="${{ secrets.server-token }}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"prettier": "prettier --write \"./**/*.{md,jsx,json,html,css,js,yml,ts,tsx}\"",
"prettier-check": "prettier --check \"./**/*.{md,jsx,json,html,css,js,yml,ts,tsx}\"",
"migrate": "pnpm migrate --prefix src/db",
"test": "pnpm jest",
"test": "pnpm turbo run test",
"jest": "jest -c jest.config.js --",
"jest:e2e": "jest -c jest.config.e2e.js --forceExit --",
"coverage": "jest -c jest.config.js --collectCoverage --",
Expand Down
3 changes: 2 additions & 1 deletion src/api/dependency-discovery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dev": "env-cmd -f env.local nodemon src/server.js",
"lint": "pnpm eslint",
"eslint": "TIMING=1 eslint --config .eslintrc.js \"**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js \"**/*.js\" --fix"
"eslint-fix": "eslint --config .eslintrc.js \"**/*.js\" --fix",
"test": "jest -c jest.config.js"
},
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion src/api/feed-discovery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"eslint": "eslint --config .eslintrc.js \"./**/*.js\" ",
"eslint-time": "TIMING=1 eslint --config .eslintrc.js \"./**/*.js\" ",
"eslint-fix": "eslint --config .eslintrc.js \"./**/*.js\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/api/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"clean": "find ./photos -type f -not -name 'default.jpg' -delete",
"lint": "pnpm eslint",
"eslint": "TIMING=1 eslint --config .eslintrc.js --ignore-path .gitignore \"./**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js --ignore-path .gitignore \"./**/*.js\" --fix"
"eslint-fix": "eslint --config .eslintrc.js --ignore-path .gitignore \"./**/*.js\" --fix",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/api/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "node src/index.js",
"eslint": "TIMING=1 eslint --config .eslintrc.js \"./**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js \"./**/*.js\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/api/posts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "node src/server.js",
"eslint": "TIMING=1 eslint --config .eslintrc.js \"./**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js \"./**/*.js\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/api/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "node src/server.js",
"eslint": "TIMING=1 eslint --config .eslintrc.js \"./**/**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js \"./**/**/*.js\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/api/sso/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"eslint": "eslint --config .eslintrc.js \"./**/*.js\"",
"eslint-time": "TIMING=1 eslint --config .eslintrc.js \"./**/*.js\"",
"eslint-fix": "eslint --config .eslintrc.js \"./**/*.js\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"repository": "Seneca-CDOT/telescope",
"license": "BSD-2-Clause",
Expand Down
3 changes: 2 additions & 1 deletion src/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"eject": "expo eject",
"eslint": "TIMING=1 eslint --config .eslintrc.js \"**/*.{js,jsx}\"",
"eslint-fix": "eslint --config .eslintrc.js \"**/*.{js,jsx}\" --fix",
"lint": "pnpm eslint"
"lint": "pnpm eslint",
"test": "jest -c jest.config.js"
},
"dependencies": {
"@react-native-async-storage/async-storage": "1.15.0",
Expand Down
1 change: 1 addition & 0 deletions src/web/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"eslint": "TIMING=1 eslint --config .eslintrc.js --ignore-path .gitignore \"./**/*.{js,jsx,ts,tsx}\"",
"eslint-fix": "eslint --config .eslintrc.js --ignore-path .gitignore \"./**/*.{js,jsx,ts,tsx}\" --fix",
"lint": "pnpm eslint",
"test": "jest -c jest.config.js",
"clean": "rm -rf .next .turbo out"
},
"version": "3.0.0",
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"build": {
"dependsOn": ["^build"]
},
"test": {
"outputs": []
},
"lint": {
"outputs": []
},
Expand Down