Skip to content

Commit

Permalink
feat(monorepo): initial github actions workflow for code quality chec…
Browse files Browse the repository at this point in the history
…ks (#18)
  • Loading branch information
mpellegrini authored Mar 11, 2024
1 parent 7bc2935 commit 94129da
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/composite-actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Install'
description: 'Sets up Node, and installs dependencies'

inputs:
fetch-depth:
default: '1'
required: false
persist-credentials:
default: true
required: false

runs:
using: composite
steps:
- name: Install pnpm package manager
uses: pnpm/action-setup@v3

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: pnpm

- name: Install dependencies
shell: bash
run: pnpm install --ignore-scripts
49 changes: 49 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: code-quality
on:
push:
branches:
- 'main'
pull_request:

jobs:
lint:
name: 'ESLint'
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run ESLint check
run: pnpm run lint

type-check:
name: 'Type Check'
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run type checks
run: pnpm run type-check

test:
name: 'Unit Test'
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run unit test
run: pnpm run test
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
engine-strict=true

save-workspace-protocol=rolling
save-prefix=''

Expand Down
8 changes: 5 additions & 3 deletions apps/sveltekit-example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"type": "module",
"scripts": {
"build": "vite build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"clean": "del .turbo .svelte-kit",
"check": "pnpm run code-gen && pnpm run type-check",
"clean": "del .turbo coverage .svelte-kit .vercel",
"code-gen": "svelte-kit sync",
"dev": "vite dev",
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest run"
"test": "vitest run",
"type-check": "svelte-check --tsconfig ./tsconfig.json"
},
"dependencies": {
"@packages/example-pkg": "workspace:*"
Expand Down
3 changes: 3 additions & 0 deletions apps/sveltekit-example-app/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"extends": ["//"],
"pipeline": {
"build": {
"outputs": [".svelte-kit/**", ".vercel/**"]
},
"code-gen": {
"outputs": [".svelte-kit/**"]
}
}
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"format": "prettier --write .",
"lint": "turbo run lint",
"prepare": "husky",
"test": "turbo run test"
"test": "turbo run test",
"type-check": "turbo run type-check"
},
"devDependencies": {
"@commitlint/cli": "19.0.1",
Expand All @@ -21,5 +22,8 @@
"prettier-plugin-tailwindcss": "0.5.11",
"turbo": "1.12.4"
},
"packageManager": "pnpm@8.15.3"
"packageManager": "pnpm@8.15.3",
"engines": {
"node": "20.11.x"
}
}
6 changes: 4 additions & 2 deletions packages/example-pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
".": "./src/index.ts"
},
"scripts": {
"clean": "del .turbo dist coverage",
"check-types": "tsc --no-emit",
"clean": "del .turbo coverage",
"lint": "eslint .",
"test": "vitest run"
"test": "vitest run",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"@toolchain/eslint-config": "workspace:*",
Expand Down
11 changes: 10 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"clean": {
"cache": false
},
"lint": {},
"code-gen": {},
"lint": {
"dependsOn": ["code-gen"]
},
"test": {
"outputs": ["./coverage/**"]
},
"type-check": {
"dependsOn": ["code-gen"]
}
}
}

0 comments on commit 94129da

Please sign in to comment.