diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..cd61b0e --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,24 @@ +name: Audit + +on: [push, pull_request] + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - name: Use Node.js 20.x + uses: actions/setup-node@v4.0.1 + with: + node-version: 20.x + cache: "npm" + + - name: Upgrade npm + run: npm i -g npm + + - name: Install + run: npm ci + + - name: Audit signatures + run: npm audit signatures diff --git a/.github/workflows/set-rollout-manual.yml b/.github/workflows/set-rollout-manual.yml new file mode 100644 index 0000000..8fef364 --- /dev/null +++ b/.github/workflows/set-rollout-manual.yml @@ -0,0 +1,46 @@ +name: Set rollout by path - Manual + +on: + workflow_dispatch: + inputs: + packageVersion: + description: "NPM Version of the release (@dcl/catalyst-monitor)" + required: true + default: "" + deploymentEnvironment: + type: "choice" + description: "Deployment environment" + required: true + default: "zone" + options: + - zone + - today + - org + rolloutPercentage: + description: "The percentage for this rollout" + required: true + default: "100" + +jobs: + set-manual-by-path-rollout: + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + - name: Set Rollout + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.ref }} + sha: ${{ github.sha }} + + # CDN information + packageName: "@dcl/catalyst-monitor" + packageVersion: ${{ github.event.inputs.packageVersion }} + + # Rollout information + deploymentPath: "catalyst-monitor" + deploymentEnvironment: ${{ github.event.inputs.deploymentEnvironment }} + deploymentName: "_site" + percentage: ${{ github.event.inputs.rolloutPercentage }} diff --git a/.github/workflows/set-rollout.yml b/.github/workflows/set-rollout.yml new file mode 100644 index 0000000..1607dd5 --- /dev/null +++ b/.github/workflows/set-rollout.yml @@ -0,0 +1,50 @@ +name: Set rollout by path + +on: [deployment_status] + +jobs: + set-rollout: + if: ${{ github.event.deployment.task == 'upload-to-cdn' && github.event.deployment_status.state == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + + # Dev + - name: Set Rollout - Development + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.deployment.ref }} + sha: ${{ github.event.deployment.sha }} + + # CDN information + packageName: ${{ github.event.deployment.payload.packageName }} + packageVersion: ${{ github.event.deployment.payload.packageVersion }} + + # Rollout information + deploymentPath: 'catalyst-monitor-site' + deploymentEnvironment: 'zone' + deploymentName: '_site' + percentage: 100 + + # Stg + - name: Set Rollout - Staging + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.deployment.ref }} + sha: ${{ github.event.deployment.sha }} + + # CDN information + packageName: ${{ github.event.deployment.payload.packageName }} + packageVersion: ${{ github.event.deployment.payload.packageVersion }} + + # Rollout information + deploymentPath: 'catalyst-monitor' + deploymentEnvironment: 'today' + deploymentName: '_site' + percentage: 100 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e15fc0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Test + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Use Node.js 20.x + uses: actions/setup-node@v1 + with: + node-version: 20.x + - name: Install + run: npm ci + + - name: Test + run: npm run test:coverage + if: ${{ always() }} diff --git a/package-lock.json b/package-lock.json index ea9fa58..0f613a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.3", + "husky": "^9.1.7", "jest": "^29.7.0", "lint-staged": "^15.2.7", "prettier": "^3.3.2", @@ -42,7 +43,7 @@ }, "engines": { "node": "20.*", - "npm": "8.* || 9.*" + "npm": "8.* || 9.* || 10.*" } }, "node_modules/@ampproject/remapping": { @@ -6187,6 +6188,21 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", diff --git a/package.json b/package.json index 8f4abcd..f9ec308 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "preview": "vite preview", "test": "jest", "test:coverage": "npm run test -- --coverage", + "prepare": "husky", + "precommit": "lint-staged --config .husky/pre-commit.js", "format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md,mdx,css}'", "lint": "eslint ./src", "lint:fix": "npm run lint -- --fix" @@ -53,6 +55,7 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.3", + "husky": "^9.1.7", "jest": "^29.7.0", "lint-staged": "^15.2.7", "prettier": "^3.3.2",