From 869925989369d791fb9ab699a3ed8ec67de4d23c Mon Sep 17 00:00:00 2001 From: unnoq Date: Sat, 23 Nov 2024 11:59:16 +0700 Subject: [PATCH] ci: delete release-pr workflow & move lint:fix to local with husky pre-commit --- .github/workflows/code-quality.yaml | 8 +- .github/workflows/release-next.yaml | 3 - .github/workflows/release-pr.yaml | 150 -------------------------- .github/workflows/release-stable.yaml | 4 - .gitignore | 1 + .husky/pre-commit | 3 + package.json | 2 + pnpm-lock.yaml | 10 ++ 8 files changed, 17 insertions(+), 164 deletions(-) delete mode 100644 .github/workflows/release-pr.yaml create mode 100644 .husky/pre-commit diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml index 17cbe0e8..2fafade2 100644 --- a/.github/workflows/code-quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -9,8 +9,6 @@ on: jobs: main: runs-on: ubuntu-latest - permissions: - contents: write steps: - uses: actions/checkout@v4 @@ -19,12 +17,8 @@ jobs: - run: pnpm i - - run: pnpm run lint:fix + - run: pnpm run lint - run: pnpm run type:check - run: pnpm run test - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: 'style: apply lint fixes' diff --git a/.github/workflows/release-next.yaml b/.github/workflows/release-next.yaml index 582252a9..84ffb99a 100644 --- a/.github/workflows/release-next.yaml +++ b/.github/workflows/release-next.yaml @@ -12,9 +12,6 @@ jobs: runs-on: ubuntu-latest - permissions: - contents: read - steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-pr.yaml b/.github/workflows/release-pr.yaml deleted file mode 100644 index 9c005632..00000000 --- a/.github/workflows/release-pr.yaml +++ /dev/null @@ -1,150 +0,0 @@ -name: Release PR - -on: - pull_request: - branches: [main] - -jobs: - release: - runs-on: ubuntu-latest - - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - - - name: NPM registry authentication - run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - run: pnpm i - - - name: Context vars - id: vars - run: | - echo "short_sha=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT - - - name: Find pr-release comment - uses: peter-evans/find-comment@v3 - id: pr-fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: - - - name: Create or update pr-release comment with in process status - uses: peter-evans/create-or-update-comment@v4 - id: pr-couc - with: - comment-id: ${{ steps.pr-fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ## PR-release for testing - - Latest commit: `${{ steps.vars.outputs.short_sha }}` - Status: 👷 In process... - - [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - edit-mode: replace - - - name: Publish packages - id: publish - continue-on-error: true - run: | - pnpm run changeset:version --snapshot unsafe-pr-${{ github.event.pull_request.number }} - pnpm run changeset:publish --tag unsafe-pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Update pr-release comment with failed status - if: steps.publish.outcome != 'success' - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.pr-couc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ## PR-release for testing - - Latest commit: `${{ steps.vars.outputs.short_sha }}` - Status: ❌ Failed - - [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - edit-mode: replace - - - name: Get @orpc/server version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-server-version - with: - path: packages/server - - - name: Get @orpc/contract version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-contract-version - with: - path: packages/contract - - - name: Get @orpc/client version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-client-version - with: - path: packages/client - - - name: Get @orpc/react version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-react-version - with: - path: packages/react - - - name: Get @orpc/openapi version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-openapi-version - with: - path: packages/openapi - - - name: Get @orpc/zod version - if: steps.publish.outcome == 'success' - uses: martinbeentjes/npm-get-version-action@v1.3.1 - id: orpc-zod-version - with: - path: packages/zod - - - name: Update pr-release comment with published status - if: steps.publish.outcome == 'success' - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.pr-couc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ## PR-release for testing - - Latest commit: `${{ steps.vars.outputs.short_sha }}` - Status: ✅ Published - - ```bash - npm install @orpc/server@${{ steps.orpc-server-version.outputs.current-version}} - npm install @orpc/contract@${{ steps.orpc-contract-version.outputs.current-version}} - npm install @orpc/client@${{ steps.orpc-client-version.outputs.current-version}} - npm install @orpc/react@${{ steps.orpc-react-version.outputs.current-version}} - npm install @orpc/openapi@${{ steps.orpc-openapi-version.outputs.current-version}} - npm install @orpc/zod@${{ steps.orpc-zod-version.outputs.current-version}} - ``` - - [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}) - edit-mode: replace - - - name: Exit with failed status - if: steps.publish.outcome != 'success' - run: exit 1 diff --git a/.github/workflows/release-stable.yaml b/.github/workflows/release-stable.yaml index 485a55ca..9cfcaf08 100644 --- a/.github/workflows/release-stable.yaml +++ b/.github/workflows/release-stable.yaml @@ -12,10 +12,6 @@ jobs: runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 04e41972..2d5a00aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ !.vscode/ !.changeset/ !.github/ +!.husky/ # Common generated folders logs/ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..2ab11464 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,3 @@ +pnpm run lint:fix +pnpm run type:check +pnpm run test \ No newline at end of file diff --git a/package.json b/package.json index 28bcfee1..4fc0c530 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "url": "https://unnoq.com" }, "scripts": { + "prepare": "husky", "build": "pnpm run -r build", "build:packages": "pnpm --filter=\"./packages/*\" run -r build", "preview": "pnpm run --parallel preview", @@ -38,6 +39,7 @@ "eslint-plugin-format": "^0.1.2", "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.14", + "husky": "^9.1.7", "jsdom": "^25.0.1", "tsup": "^8.3.0", "typescript": "5.7.1-rc", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67dc1c1b..d3171b79 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: eslint-plugin-react-refresh: specifier: ^0.4.14 version: 0.4.14(eslint@9.15.0(jiti@2.1.0)) + husky: + specifier: ^9.1.7 + version: 9.1.7 jsdom: specifier: ^25.0.1 version: 25.0.1 @@ -3356,6 +3359,11 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} + husky@9.1.7: + resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} + engines: {node: '>=18'} + hasBin: true + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -8731,6 +8739,8 @@ snapshots: human-signals@2.1.0: {} + husky@9.1.7: {} + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2