Skip to content

Commit

Permalink
Introduce upgrades to CI/CD (#18)
Browse files Browse the repository at this point in the history
* Introduce typechecking scripts

* Introduce coverage testing

* Introduce upgraded CI/CD

* Apply suggestions from code review

Co-authored-by: Luc <[email protected]>

---------

Co-authored-by: Luc <[email protected]>
  • Loading branch information
svemat01 and lucemans authored Sep 26, 2023
1 parent 9b9546d commit d1bc3ca
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 27 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Setup dependencies"
description: "Prepare repository and all dependencies"

runs:
using: "composite"
steps:
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: pnpm install
14 changes: 14 additions & 0 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pull request
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ on:
concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
verify:
name: Verify
uses: ./.github/workflows/verify.yml
secrets: inherit
changesets:
name: Changesets
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'pnpm'

- name: Install Dependencies
run: pnpm install
uses: ./.github/actions/setup

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Verify
on:
workflow_call:
workflow_dispatch:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/setup

- name: Lint code
run: pnpm lint

build:
name: Build
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/setup

- name: Build
run: pnpm build

types:
name: Types
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/setup

- name: Check types
run: pnpm typecheck

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

steps:
- uses: actions/checkout@v3

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

- name: Run tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 3
command: pnpm test:coverage
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"main": "index.js",
"scripts": {
"sync:deps": "syncpack",
"release": "pnpm -r build && changeset publish"
"release": "pnpm -r build && changeset publish",
"build": "pnpm -r build",
"lint": "pnpm -r lint",
"test": "pnpm -r test",
"test:coverage": "pnpm -r test -- --coverage",
"typecheck": "pnpm -r typecheck"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/base/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"moduleResolution": "node",
"target": "es2022",
"module": "es2022",
"lib": ["es2015", "es2016", "es2017", "es2020"],
"lib": ["es2015", "es2016", "es2017", "es2020", "DOM"],
"strict": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
Expand Down
4 changes: 3 additions & 1 deletion packages/chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"lint": "eslint --ext .ts,.tsx src",
"pub": "pnpm publish --no-git-checks",
"build": "tsup",
"test": "vitest run"
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"exports": {
".": {
Expand All @@ -22,6 +23,7 @@
"license": "lgpl-3.0",
"devDependencies": {
"@ens-tools/base": "workspace:*",
"@vitest/coverage-v8": "^0.34.5",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vitest": "^0.34.5"
Expand Down
4 changes: 3 additions & 1 deletion packages/chains/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"extends": ["@ens-tools/base/tsconfig.base.json"],
"extends": [
"@ens-tools/base/tsconfig.base.json"
],
}
5 changes: 4 additions & 1 deletion packages/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"test": "vitest run",
"lint": "eslint --ext .ts,.tsx src",
"pub": "pnpm publish --no-git-checks",
"build": "tsup"
"build": "tsup",
"typecheck": "tsc --noEmit"
},
"exports": {
".": {
Expand Down Expand Up @@ -48,6 +49,8 @@
"license": "lgpl-3.0",
"devDependencies": {
"@ens-tools/base": "workspace:*",
"@types/node": "^20.7.0",
"@vitest/coverage-v8": "^0.34.5",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vitest": "^0.34.5"
Expand Down
4 changes: 3 additions & 1 deletion packages/format/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"extends": ["@ens-tools/base/tsconfig.base.json"],
"extends": [
"@ens-tools/base/tsconfig.base.json"
],
}
5 changes: 4 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"lint": "eslint --ext .ts,.tsx src",
"pub": "pnpm publish --no-git-checks",
"build": "tsup",
"test": "vitest run"
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"exports": {
".": {
Expand All @@ -23,7 +24,9 @@
"devDependencies": {
"@ens-tools/base": "workspace:*",
"@testing-library/react": "^14.0.0",
"@types/node": "^20.7.0",
"@types/react": "^18.2.21",
"@vitest/coverage-v8": "^0.34.5",
"eslint": "^8.49.0",
"happy-dom": "^12.1.6",
"react-dom": "^18.2.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"extends": ["@ens-tools/base/tsconfig.base.json"],
"extends": [
"@ens-tools/base/tsconfig.base.json"
],
}
Loading

0 comments on commit d1bc3ca

Please sign in to comment.