Skip to content

Commit

Permalink
improvement: add test script to turbo.json + package.json
Browse files Browse the repository at this point in the history
add install turbo

fix: switch from uses to run script

use script to install pnpm

use pnpm run test in the root directory
  • Loading branch information
chinathaip committed Jan 7, 2024
1 parent 40456f3 commit 6e63bef
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 71 deletions.
93 changes: 46 additions & 47 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
name: Run test pull request

on:
push:
branches:
- bas
push:
branches:
- bas

jobs:
test:
name: Course compose CI/CD testing
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://postgres:CourseComposeBeta@db.svnqvwyareiofplfxslm.supabase.co:5432/postgres
PRISMA_PROVIDER: go run github.com/steebchen/prisma-client-go
PRISMA_OUTPUT: ../../apps/prisma/db

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install libaries
run: npm install -g pnpm

- name: Install jest and dependencies with pnpm
working-directory: ./apps/course-api
run: pnpm add --save-dev jest @types/jest ts-jest

- name: Run course-api integration
working-directory: ./apps/course-api
run: pnpm run integration

- name: Setup Go 1.21.5
uses: actions/setup-go@v4
with:
go-version: '1.21.5'

- name: Generate ORM
working-directory: ./apps/reviews-api
run: go run github.com/steebchen/prisma-client-go generate --schema=../../packages/prisma/schema.prisma

- name: Run reviews-api unit
working-directory: ./apps/reviews-api
run: pnpm run unit

- name: Run reviews-api integration
working-directory: ./apps/reviews-api
run: pnpm run integration

- name: Run api-gateway test
working-directory: ./apps/api-gateway
run: pnpm run test
test:
name: Course compose CI/CD testing
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://postgres:CourseComposeBeta@db.svnqvwyareiofplfxslm.supabase.co:5432/postgres
PRISMA_PROVIDER: go run github.com/steebchen/prisma-client-go
PRISMA_OUTPUT: ../../apps/prisma/db

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 8
run_install: false

- name: Install turbo
run: pnpm install --global turbo

- name: Install jest
working-directory: ./apps/course-api
run: pnpm add --save-dev jest @types/jest ts-jest

- name: Setup Go 1.21.5
uses: actions/setup-go@v4
with:
go-version: "1.21.5"

- name: Generate ORM
working-directory: ./apps/reviews-api
run: go run github.com/steebchen/prisma-client-go generate --schema=../../packages/prisma/schema.prisma

- name: Unit test
run: pnpm run unit

- name: Integration test
run: pnpm run integration

- name: Test
run: pnpm run test
2 changes: 1 addition & 1 deletion apps/regscraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"compile": "pnpm exec tsc",
"scrape": "pnpm compile && node ./dist/scraper.js --filename out.json",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 0"
},
"keywords": [],
"author": "",
Expand Down
43 changes: 23 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
{
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"bootstrap": "docker compose -f docker-compose.dev.yaml down -v && docker compose -f docker-compose.dev.yaml up -d --build --force-recreate",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md,go}\""
},
"devDependencies": {
"eslint": "^8.55.0",
"prettier": "^3.1.0",
"tsconfig": "workspace:*",
"turbo": "^1.11.0"
},
"packageManager": "pnpm@8.9.0",
"name": "course-compose",
"dependencies": {
"@prisma/client": "^5.7.1",
"prettier-plugin-go-template": "^0.0.15"
}
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"bootstrap": "docker compose -f docker-compose.dev.yaml down -v && docker compose -f docker-compose.dev.yaml up -d --build --force-recreate",
"test": "turbo run test",
"unit": "turbo run unit",
"integration": "turbo run integration",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md,go}\""
},
"devDependencies": {
"eslint": "^8.55.0",
"prettier": "^3.1.0",
"tsconfig": "workspace:*",
"turbo": "^1.11.0"
},
"packageManager": "pnpm@8.9.0",
"name": "course-compose",
"dependencies": {
"@prisma/client": "^5.7.1",
"prettier-plugin-go-template": "^0.0.15"
}
}
22 changes: 19 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"globalDependencies": [
"**/.env.*local"
],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": [".next/**", "!.next/cache/**"]
"dependsOn": [
"^build"
],
"outputs": [
".next/**",
"!.next/cache/**"
]
},
"lint": {},
"test": {
"cache": false
},
"unit": {
"cache": false
},
"integration": {
"cache": false
},
"dev": {
"cache": false,
"persistent": true
Expand Down

0 comments on commit 6e63bef

Please sign in to comment.