Skip to content

Commit

Permalink
Merge pull request #1 from mangrovedao/feat/maxence/addci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
maxencerb authored May 2, 2024
2 parents eeb5d1c + 7d9509d commit d6fec62
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-wasps-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mangrovedao/mgv": patch
---

Adding CI pipeline
69 changes: 69 additions & 0 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Changesets
on:
push:
branches: main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml
secrets: inherit

changesets:
name: Create version pull request
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
submodules: 'recursive'

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

- name: Create Version Pull Request
uses: changesets/action@v1
with:
commit: 'chore: version package'
title: 'chore: version package'
version: bun run changeset:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
id-token: write

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Publish to NPM
uses: changesets/action@v1
with:
createGithubReleases: ${{ github.ref == 'refs/heads/main' }}
publish: bun run changeset:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# https://docs.npmjs.com/generating-provenance-statements
NPM_CONFIG_PROVENANCE: true
File renamed without changes.
67 changes: 67 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Verify
on:
workflow_call:
workflow_dispatch:

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

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Lint code
run: bun format && bun lint:fix

- uses: stefanzweifel/git-auto-commit-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: 'chore: format'
commit_user_name: 'github-actions[bot]'
commit_user_email: 'github-actions[bot]@users.noreply.github.com'

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

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Build
run: bun run build

tests:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Run tests
run: bun run test:ci


4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./src/_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./src/_cjs/package.json",
"build:esm": "tsc --project ./tsconfig.build.json --module es2015 --outDir ./src/_esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./src/_esm/package.json",
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./src/_types --emitDeclarationOnly --declaration --declarationMap",
"changeset": "changeset",
"changeset:publish": "bun run prepublishOnly && bun run build && changeset publish",
"changeset:version": "changeset version",
"clean": "rimraf src/_esm src/_cjs src/_types",
"format": "biome format . --write",
"lint": "biome check .",
"lint:fix": "bun run lint --apply",
"prepublishOnly": "bun scripts/prepublishOnly.ts",
"test": "vitest -c ./test/vitest.config.ts dev",
"test:ci": "CI=true vitest -c ./test/vitest.config.ts --coverage --retry=3 --bail=1 --pool=forks"
},
Expand Down
10 changes: 10 additions & 0 deletions scripts/prepublishOnly.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { join } from 'node:path'

const packageJsonPath = join(import.meta.dir, '../src/package.json')
const packageJson = await Bun.file(packageJsonPath).json()

// NOTE: We explicitly don't want to publish the type field.
// We create a separate package.json for `dist/cjs` and `dist/esm` that has the type field.
delete packageJson.type

Bun.write(packageJsonPath, JSON.stringify(packageJson, null, 2))

0 comments on commit d6fec62

Please sign in to comment.