From 4686b12cb2321b8decb81e083da24fd7d91afe85 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Fri, 18 Oct 2024 10:39:37 -0400 Subject: [PATCH] ci: refactor release workflow --- .github/workflows/cli.yaml | 28 ++++----------------- .github/workflows/devnet.yaml | 17 ------------- .github/workflows/paymaster.yaml | 17 ------------- .github/workflows/release.yaml | 42 +++++++++++--------------------- apps/cli/package.json | 3 +-- apps/cli/vitest.config.ts | 1 + package.json | 5 ++-- turbo.json | 4 +++ 8 files changed, 28 insertions(+), 89 deletions(-) diff --git a/.github/workflows/cli.yaml b/.github/workflows/cli.yaml index 30b7fc42..8a90eff0 100644 --- a/.github/workflows/cli.yaml +++ b/.github/workflows/cli.yaml @@ -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 @@ -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 }} diff --git a/.github/workflows/devnet.yaml b/.github/workflows/devnet.yaml index 010f538e..67a1e49b 100644 --- a/.github/workflows/devnet.yaml +++ b/.github/workflows/devnet.yaml @@ -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 @@ -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 }} diff --git a/.github/workflows/paymaster.yaml b/.github/workflows/paymaster.yaml index d100e854..1df1471b 100644 --- a/.github/workflows/paymaster.yaml +++ b/.github/workflows/paymaster.yaml @@ -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 @@ -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 }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cb024164..ec9d39c3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,7 +38,19 @@ jobs: - name: Install Dependencies run: pnpm install - - name: Create Release Pull Request + - 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 or Publish to npm id: changeset uses: changesets/action@v1 with: @@ -46,6 +58,7 @@ jobs: publish: pnpm run publish-packages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} packages_to_build: name: Get released packages @@ -66,30 +79,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 diff --git a/apps/cli/package.json b/apps/cli/package.json index 335f8e5a..cf889828 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -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" diff --git a/apps/cli/vitest.config.ts b/apps/cli/vitest.config.ts index f958e3a5..14e2d424 100644 --- a/apps/cli/vitest.config.ts +++ b/apps/cli/vitest.config.ts @@ -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, diff --git a/package.json b/package.json index 74ec4dc2..74c0b510 100644 --- a/package.json +++ b/package.json @@ -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:*", diff --git a/turbo.json b/turbo.json index f7e88e09..fc16336a 100644 --- a/turbo.json +++ b/turbo.json @@ -26,6 +26,10 @@ "lint": {}, "start": { "dependsOn": ["^build"] + }, + "test": { + "outputs": ["coverage/**"], + "dependsOn": [] } } }