From 2a0c1a87c0fe748b36138fe00ee43f2907553344 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 22 Nov 2024 02:42:15 +0000 Subject: [PATCH 1/3] feat - add pre-commit hook for branch name validation --- .githooks/pre-commit | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..0d7fead --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +LC_ALL=C + +local_branch="$(git rev-parse --abbrev-ref HEAD)" + +valid_branch_regex="^(penify|gitauto|dependabot|feature|fix|docs|style|refactor|perf|hotfix|test|chore|create)(\/[a-zA-Z0-9#._-]+)+$" + +message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again." + +if [[ ! $local_branch =~ $valid_branch_regex ]] +then + echo "$message" + exit 1 +fi + +npm run lint \ No newline at end of file From 49646793ff16700c4dca90b40324c2ad2e0b4f19 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 22 Nov 2024 02:45:57 +0000 Subject: [PATCH 2/3] feat - add GitHub workflows and dependabot configuration files --- .github/dependabot.yml | 28 +++++++ .github/workflows/deploy.yml | 77 +++++++++++++++++++ .github/workflows/infisical-secrets-check.yml | 24 ++++++ .github/workflows/size-label.yml | 27 +++++++ .../workflows/snorkell-auto-documentation.yml | 12 +-- .github/workflows/sonar-cloud.yml | 44 +++++++++++ GitVersion.yml | 2 + 7 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/infisical-secrets-check.yml create mode 100644 .github/workflows/size-label.yml create mode 100644 .github/workflows/sonar-cloud.yml create mode 100644 GitVersion.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9d10b13 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,28 @@ +version: 2 + +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 50 + assignees: + - "guibranco" + reviewers: + - "guibranco" + labels: + - "npm" + - "dependencies" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 50 + assignees: + - "guibranco" + reviewers: + - "guibranco" + labels: + - "github-actions" + - "dependencies" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..6ba14f1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,77 @@ +name: Build & Deploy via ftp + +on: + push: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + outputs: + fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v3.0.1 + with: + versionSpec: "6.x" + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v3.0.1 + with: + useConfigFile: true + + - name: Set up Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Test + run: npm test + + # - name: Upload build + # uses: sebastianpopp/ftp-action@releases/v2 + # with: + # host: ${{ secrets.FTP_SERVER }} + # user: ${{ secrets.FTP_USERNAME }} + # password: ${{ secrets.FTP_PASSWORD }} + # localDir: "build/" + # remoteDir: "/" + + create_release: + name: Create release + needs: build + runs-on: ubuntu-latest + env: + fullSemVer: ${{ needs.deploy_service.outputs.fullSemVer }} + + steps: + - name: Create Release + uses: ncipollo/release-action@v1.14.0 + with: + skipIfReleaseExists: true + allowUpdates: false + draft: false + makeLatest: true + tag: v${{ env.fullSemVer }} + name: Release v${{ env.fullSemVer }} + generateReleaseNotes: true + body: Release ${{ env.fullSemVer }} of ${{ github.repository }} diff --git a/.github/workflows/infisical-secrets-check.yml b/.github/workflows/infisical-secrets-check.yml new file mode 100644 index 0000000..edaf002 --- /dev/null +++ b/.github/workflows/infisical-secrets-check.yml @@ -0,0 +1,24 @@ +name: Infisical secrets check + +on: + workflow_dispatch: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + secrets-scan: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Infisical secrets check + uses: guibranco/github-infisical-secrets-check-action@v1.1.16 diff --git a/.github/workflows/size-label.yml b/.github/workflows/size-label.yml new file mode 100644 index 0000000..9d97549 --- /dev/null +++ b/.github/workflows/size-label.yml @@ -0,0 +1,27 @@ +name: Label based on PR size + +on: + pull_request: + pull_request_target: + workflow_dispatch: + +jobs: + size-label: + permissions: write-all + runs-on: ubuntu-latest + + steps: + - name: size-label + if: >- + ( + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + ) || ( + github.event_name == 'pull_request_target' && + github.event.pull_request.head.repo.full_name != github.repository + ) || ( + github.event_name == 'workflow_dispatch' + ) + uses: "pascalgn/size-label-action@v0.5.5" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/snorkell-auto-documentation.yml b/.github/workflows/snorkell-auto-documentation.yml index 926c7e5..ccd08e3 100644 --- a/.github/workflows/snorkell-auto-documentation.yml +++ b/.github/workflows/snorkell-auto-documentation.yml @@ -11,9 +11,9 @@ jobs: Documentation: runs-on: ubuntu-latest steps: - - name: Penify DocGen Client - uses: SingularityX-ai/snorkell-documentation-client@v1.0.0 - with: - client_id: ${{ secrets.SNORKELL_CLIENT_ID }} - api_key: ${{ secrets.SNORKELL_API_KEY }} - branch_name: "main" \ No newline at end of file + - name: Penify DocGen Client + uses: SingularityX-ai/snorkell-documentation-client@v1.0.0 + with: + client_id: ${{ secrets.SNORKELL_CLIENT_ID }} + api_key: ${{ secrets.SNORKELL_API_KEY }} + branch_name: "main" diff --git a/.github/workflows/sonar-cloud.yml b/.github/workflows/sonar-cloud.yml new file mode 100644 index 0000000..b38e861 --- /dev/null +++ b/.github/workflows/sonar-cloud.yml @@ -0,0 +1,44 @@ +name: Sonar Cloud Analysis +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + pull_request_target: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: npm install + + - name: Test and coverage + run: npm run test -- --coverage --watchAll=false + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + if: >- + ( + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + ) || ( + github.event_name == 'pull_request_target' && + github.event.pull_request.head.repo.full_name != github.repository + ) || ( + github.event_name == 'workflow_dispatch' + ) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..3e4fb36 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,2 @@ +workflow: GitHubFlow/v1 +mode: ContinuousDelivery \ No newline at end of file From bf06dd766511f54549980ff9005064bd247f2185 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 22 Nov 2024 02:46:21 +0000 Subject: [PATCH 3/3] feat - add GitHub workflows for build process --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 668fead..740f50b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Node.js 20 uses: actions/setup-node@v4