Skip to content

Commit

Permalink
Explore unified CI for packages using NX's affected command
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Feb 19, 2024
1 parent 93baabc commit 1a5d3e7
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 15 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/packages_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: 'Packages CI'

on:
push:
paths:
- packages/**
- .github/workflows/packages_ci.yml
- jest.config.ts
- jest.preset.js
- .eslintrc.json
- .prettierrc
- package.json
- package-lock.json

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '20.4.0'

- name: Install dependencies
run: |
make install/ci
- name: Code format
shell: bash
run: |
npx nx affected --target format:check
npx nx affected --target lint:check
test-type:
runs-on: ubuntu-latest
needs: [build]
steps:
- shell: bash
run: |
npx nx affected --target test:type
test-unit:
needs: [build]
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
npx nx affected --target test:unit
# test-integration:
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - shell: bash
# run: |
# npx nx affected --target test:integration

# test-e2e:
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - shell: bash
# run: |
# npx nx affected --target test:e2e

notify:
needs: [test-type, test-unit, test-integration, test-e2e]
runs-on: ubuntu-latest
steps:
- name: Send Slack notification on failure
if: failure() && github.ref == 'refs/heads/main'
uses: 8398a7/action-slack@v3
with:
username: GitHub
author_name: '@narval/transaction-request-intent CI failed'
status: ${{ job.status }}
fields: message,commit,author
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include ./apps/authz/Makefile
include ./apps/orchestration/Makefile
include ./packages/authz-shared/Makefile
include ./packages/signature-verifier/Makefile
include ./packages/transaction-request-intent/Makefile

# For more terminal color codes, head over to https://opensource.com/article/19/9/linux-terminal-colors
Expand Down
2 changes: 1 addition & 1 deletion apps/authz/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test:type": {
"executor": "nx:run-commands",
"options": {
"command": "npx tsc --noEmit --project apps/orchestration/tsconfig.app.json"
"command": "make authz/test/type"
}
},
"test:unit": {
Expand Down
2 changes: 1 addition & 1 deletion apps/orchestration/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"test:type": {
"executor": "nx:run-commands",
"options": {
"command": "npx tsc --noEmit --project apps/authz/tsconfig.app.json"
"command": "make orchestration/test/type"
}
},
"test:unit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import { UserRepository } from '../../persistence/repository/user.repository'

@Injectable()
export class OrganizationService {
constructor(
private orgRepository: OrganizationRepository,
private userRepository: UserRepository
) {}
constructor(private orgRepository: OrganizationRepository, private userRepository: UserRepository) {}

async create(input: CreateOrganizationRequest): Promise<{
organization: OrganizationEntity
Expand Down
6 changes: 6 additions & 0 deletions packages/authz-shared/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"lintFilePatterns": ["packages/authz-shared/**/*.ts"]
}
},
"test:type": {
"executor": "nx:run-commands",
"options": {
"command": "make authz-shared/test/type"
}
},
"test:unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
Expand Down
16 changes: 8 additions & 8 deletions packages/signature-verifier/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
TRI_PROJECT_NAME := signature-verifier
TRI_PROJECT_DIR := ./packages/signature-verifier
SIGNATURE_PROJECT_NAME := signature-verifier
SIGNATURE_PROJECT_DIR := ./packages/signature-verifier

# == Code format ==

signature-verifier/format:
npx nx format:write --projects ${TRI_PROJECT_NAME}
npx nx format:write --projects ${SIGNATURE_PROJECT_NAME}

signature-verifier/lint:
npx nx lint ${TRI_PROJECT_NAME} -- --fix
npx nx lint ${SIGNATURE_PROJECT_NAME} -- --fix

signature-verifier/format/check:
npx nx format:check --projects ${TRI_PROJECT_NAME}
npx nx format:check --projects ${SIGNATURE_PROJECT_NAME}

signature-verifier/lint/check:
npx nx lint ${TRI_PROJECT_NAME}
npx nx lint ${SIGNATURE_PROJECT_NAME}

# == Testing ==

signature-verifier/test/type:
npx tsc \
--project ${TRI_PROJECT_DIR}/tsconfig.lib.json \
--project ${SIGNATURE_PROJECT_DIR}/tsconfig.lib.json \
--noEmit

signature-verifier/test/unit:
npx nx test:unit ${TRI_PROJECT_NAME} -- ${ARGS}
npx nx test:unit ${SIGNATURE_PROJECT_NAME} -- ${ARGS}

signature-verifier/test/unit/watch:
make signature-verifier/test/unit ARGS=--watch
6 changes: 6 additions & 0 deletions packages/signature-verifier/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"lintFilePatterns": ["packages/signature-verifier/**/*.ts"]
}
},
"test:type": {
"executor": "nx:run-commands",
"options": {
"command": "make signature-verifier/test/type"
}
},
"test:unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
Expand Down
3 changes: 2 additions & 1 deletion packages/signature-verifier/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
"esModuleInterop": true,
"strictPropertyInitialization": false
}
}
6 changes: 6 additions & 0 deletions packages/transaction-request-intent/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"lintFilePatterns": ["packages/transaction-request-intent/**/*.ts"]
}
},
"test:type": {
"executor": "nx:run-commands",
"options": {
"command": "make transaction-request-intent/test/type"
}
},
"test:unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
Expand Down

0 comments on commit 1a5d3e7

Please sign in to comment.