Skip to content

Commit

Permalink
ci: refactor release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuler committed Oct 18, 2024
1 parent 273af81 commit c2858d2
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 88 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: cli
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/cli.yaml
Expand Down Expand Up @@ -48,22 +38,14 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Test / Coverage
working-directory: ./apps/cli
run: pnpm run test:coverage
- name: Build
run: pnpm build --filter @cartesi/cli

- name: Test
run: pnpm test --filter @cartesi/cli

- name: "Report Coverage"
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./apps/cli

- name: Build
run: pnpm build --filter @cartesi/cli

- name: Publish
if: ${{ inputs.release }}
working-directory: ./apps/cli
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/devnet.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: devnet
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/devnet.yaml
Expand Down Expand Up @@ -46,10 +36,3 @@ jobs:

- name: Build
run: pnpm build --filter @cartesi/devnet

- name: Publish
if: ${{ inputs.release }}
run: pnpm publish --access public
working-directory: packages/devnet
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/paymaster.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: paymaster
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/paymaster.yaml
Expand Down Expand Up @@ -48,10 +38,3 @@ jobs:

- name: Build
run: pnpm build --filter @cartesi/mock-verifying-paymaster

- name: Publish
if: ${{ inputs.release }}
working-directory: ./packages/mock-verifying-paymaster
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 12 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ jobs:
- name: Install Dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Test
run: pnpm test

- name: "Report Coverage"
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./apps/cli

- name: Create Release Pull Request
id: changeset
uses: changesets/action@v1
Expand Down Expand Up @@ -66,30 +78,3 @@ jobs:
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/sdk') }}
uses: ./.github/workflows/sdk.yaml
secrets: inherit

build_devnet:
name: Build devnet
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/devnet') }}
uses: ./.github/workflows/devnet.yaml
secrets: inherit
with:
release: true

build_cli:
name: Build cli
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/cli') }}
uses: ./.github/workflows/cli.yaml
secrets: inherit
with:
release: true

build_paymaster:
name: Build paymaster
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/mock-verifying-paymaster') }}
uses: ./.github/workflows/paymaster.yaml
secrets: inherit
with:
release: true
3 changes: 1 addition & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"postpack": "rimraf oclif.manifest.json",
"posttest": "pnpm lint",
"prepack": "pnpm build && oclif manifest",
"test": "vitest",
"test:coverage": "vitest --coverage.enabled true"
"test": "vitest"
},
"engines": {
"node": ">=18.0.0"
Expand Down
1 change: 1 addition & 0 deletions apps/cli/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
enabled: true,
provider: "istanbul",
reporter: ["text", "json-summary", "json"],
reportOnFailure: true,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{cjs,css,json,md,mjs,ts,tsx}\"",
"publish-packages": "pnpm changeset tag && git push --follow-tags",
"preinstall": "npx only-allow pnpm"
"publish-packages": "pnpm changeset publish && git push --follow-tags",
"preinstall": "npx only-allow pnpm",
"test": "turbo test"
},
"devDependencies": {
"@cartesi/eslint-config": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"lint": {},
"start": {
"dependsOn": ["^build"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": []
}
}
}

0 comments on commit c2858d2

Please sign in to comment.