Skip to content

Commit

Permalink
run validation jobs in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 25, 2023
1 parent ebc2bfb commit 63345d7
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 111 deletions.
192 changes: 192 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: CI

on:
push:
pull_request:
branches: [main]
paths-ignore:
- README.md
- docs/**

jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
nestjs: ${{ steps.filter.outputs.nestjs }}
remix: ${{ steps.filter.outputs.remix }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Check for file changes
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
nestjs:
- 'apps/nestjs/**'
- 'libs/types/**'
remix:
- 'apps/remix/**'
- 'apps/types/**'
lint:
name: ⬣ ESLint
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: 🔬 Lint
run: npm run lint

typecheck:
name: ʦ TypeScript
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: 📥 Install Dependencies
run: pnpm install

- name: 🔎 Type check
run: pnpm typecheck

test:
name: 🧪 Tests
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: 📥 Install Dependencies
run: pnpm install

- name: 🧪 Run tests
run: pnpm test

e2e:
name: 🔬 E2E Tests
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: 📥 Install Dependencies
run: pnpm install

- name: 🧪 Run tests
run: pnpm test:e2e

build:
name: 🏗️ Build
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: 📥 Install Dependencies
run: pnpm install

- name: 🏗️ Build
run: pnpm build

deploy-nestjs:
name: Deploy NestJS App
needs: [changes, lint, typecheck, test, e2e, build]
if: needs.changes.outputs.nestjs == 'true' && github.ref == 'refs/heads/main'

runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy
run: flyctl deploy --config ./apps/nestjs/fly.toml --dockerfile ./apps/nestjs/Dockerfile --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

deploy-remix:
name: Deploy Remix App
needs: [changes, lint, typecheck, test, e2e, build]
if: needs.changes.outputs.remix == 'true' && github.ref == 'refs/heads/main'

runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy
run: flyctl deploy --config ./apps/remix/fly.toml --dockerfile ./apps/remix/Dockerfile --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
98 changes: 0 additions & 98 deletions .github/workflows/validate.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [x] manually deploy to fly.io
- [x] create CI deployment workflow to fly.io
- [x] improve CI deployment workflow to trigger only for changed apps
- [ ] run typecheck, lint, test and build in parallel
- [x] run typecheck, lint, test and build in parallel
- [ ] setup tailwindcss in remix
- [ ] create shared ui lib
- [ ] setup Storybook in shared ui lib
Expand Down
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
"name": "pnpm-monorepo",
"private": true,
"scripts": {
"build:nestjs": "pnpm --F nestjs build",
"build:remix": "pnpm --F remix build",
"build": "pnpm --F './apps/**' build",
"build:nestjs": "pnpm -F nestjs build",
"build:remix": "pnpm -F remix build",
"build": "pnpm run -r build",
"deploy:nestjs": "fly deploy --config ./apps/nestjs/fly.toml --dockerfile ./apps/nestjs/Dockerfile",
"deploy:remix": "fly deploy --config ./apps/remix/fly.toml --dockerfile ./apps/remix/Dockerfile",
"develop:nestjs": "pnpm --F nestjs develop",
"develop:remix": "pnpm --F remix develop",
"develop": "pnpm --F './apps/**' develop",
"develop:nestjs": "pnpm -F nestjs develop",
"develop:remix": "pnpm -F remix develop",
"develop": "pnpm -r develop",
"format": "prettier --write .",
"lint:fix": "pnpm lint --fix",
"lint:fix": "pnpm lint -fix",
"lint": "eslint --ext .ts,.tsx ./apps ./libs",
"start:nestjs": "pnpm --F nestjs start",
"start:remix": "pnpm --F remix start",
"start": "pnpm --F './apps/**' start",
"test": "pnpm --F './apps/**' test",
"test:nestjs": "pnpm --F nestjs test"
"start:nestjs": "pnpm -F nestjs start",
"start:remix": "pnpm -F remix start",
"start": "pnpm -r start",
"test": "pnpm -r test",
"test:e2e": "pnpm -r test:e2e",
"test:nestjs": "pnpm -F nestjs test",
"typecheck": "tsc -b ."
},
"devDependencies": {
"@flydotio/dockerfile": "^0.4.11",
Expand Down

0 comments on commit 63345d7

Please sign in to comment.