From 92c041421ca3cef9d3a4db1b3e338303f69b1f4b Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Wed, 18 Dec 2024 23:58:01 -0500 Subject: [PATCH 1/4] chore: remove deprecated label-pr workflow --- .github/workflows/checks.yml | 12 +++++++ .github/workflows/deploy-net.yml | 34 ------------------- .github/workflows/label-pr.yml | 19 ----------- .../{version-bump.yml => on-merge.yml} | 0 .github/workflows/publish-assets.yml | 25 -------------- .../workflows/{make-docs.yml => publish.yml} | 24 ++++++++++--- .../{scheduled-release.yml => release.yml} | 8 ++--- 7 files changed, 36 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/deploy-net.yml delete mode 100644 .github/workflows/label-pr.yml rename .github/workflows/{version-bump.yml => on-merge.yml} (100%) delete mode 100644 .github/workflows/publish-assets.yml rename .github/workflows/{make-docs.yml => publish.yml} (59%) rename .github/workflows/{scheduled-release.yml => release.yml} (96%) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 76ec4cc61..a83f4cc55 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -2,9 +2,21 @@ name: Run All Checks on: pull_request: + types: [opened, edited] merge_group: jobs: + pr-labeler: + permissions: + contents: read # for TimonVS/pr-labeler-action to read config file + pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR + runs-on: ubuntu-latest + steps: + - uses: TimonVS/pr-labeler-action@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value + test-builds: if: github.event_name == 'pull_request' runs-on: ubuntu-latest diff --git a/.github/workflows/deploy-net.yml b/.github/workflows/deploy-net.yml deleted file mode 100644 index 765b590c2..000000000 --- a/.github/workflows/deploy-net.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Deploy Networks -on: - workflow_dispatch: - push: - tags: - - "v*" - branches: - - develop - -permissions: - contents: write - issues: write - -jobs: - reboot-devnet: - name: Devnet Deploy - runs-on: goliath - environment: "Devnet" - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - branch: develop - - - name: Stop Existing Network - continue-on-error: true - run: | - make stop-uds - make clean - - - name: Start Updated Network - run: | - make start-uds diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml deleted file mode 100644 index 45788f43f..000000000 --- a/.github/workflows/label-pr.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: PR Labeler -on: - pull_request: - types: [opened, edited] - -permissions: - contents: read - -jobs: - pr-labeler: - permissions: - contents: read # for TimonVS/pr-labeler-action to read config file - pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR - runs-on: ubuntu-latest - steps: - - uses: TimonVS/pr-labeler-action@v5 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value diff --git a/.github/workflows/version-bump.yml b/.github/workflows/on-merge.yml similarity index 100% rename from .github/workflows/version-bump.yml rename to .github/workflows/on-merge.yml diff --git a/.github/workflows/publish-assets.yml b/.github/workflows/publish-assets.yml deleted file mode 100644 index 8d8f2e562..000000000 --- a/.github/workflows/publish-assets.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Publish Versioned Assets -on: - push: - branches: - - develop - -permissions: - contents: write - issues: write - -jobs: - buf_push_core: - name: Publish to buf.build/onsonr/sonr - runs-on: ubuntu-latest - steps: - # Run `git checkout` - - uses: actions/checkout@v3 - # Install the `buf` CLI - - uses: bufbuild/buf-setup-action@v1 - # Push only the Input in `proto` to the BSR - - uses: bufbuild/buf-push-action@v1 - continue-on-error: true - with: - input: proto - buf_token: ${{ secrets.BUF_TOKEN }} diff --git a/.github/workflows/make-docs.yml b/.github/workflows/publish.yml similarity index 59% rename from .github/workflows/make-docs.yml rename to .github/workflows/publish.yml index 2b5869e23..472aad248 100644 --- a/.github/workflows/make-docs.yml +++ b/.github/workflows/publish.yml @@ -1,17 +1,33 @@ -name: Publish Docs via GitHub Pages +name: Publish Versioned Assets on: push: branches: - - main - - master - develop paths: - "docs/**" + - "proto/**" permissions: contents: write + issues: write + jobs: - deploy: + buf_push_core: + name: Publish to buf.build/onsonr/sonr + runs-on: ubuntu-latest + steps: + # Run `git checkout` + - uses: actions/checkout@v3 + # Install the `buf` CLI + - uses: bufbuild/buf-setup-action@v1 + # Push only the Input in `proto` to the BSR + - uses: bufbuild/buf-push-action@v1 + continue-on-error: true + with: + input: proto + buf_token: ${{ secrets.BUF_TOKEN }} + + publish-docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/scheduled-release.yml b/.github/workflows/release.yml similarity index 96% rename from .github/workflows/scheduled-release.yml rename to .github/workflows/release.yml index 833a75b55..fd787957c 100644 --- a/.github/workflows/scheduled-release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,10 @@ name: Versioned Release on: push: tags: - - "v[0-9]+.[0-9]+.[0-9]+" - workflow_dispatch: - repository_dispatch: - types: [trigger-release] + - v* + branches: + - develop + - main permissions: contents: write From b2cd3f6fba81cc6f72debe33f8889b2b5a09ad70 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Wed, 18 Dec 2024 23:58:24 -0500 Subject: [PATCH 2/4] chore: reduce Dependabot update frequency to monthly --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cd885540d..04d02677d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: - package-ecosystem: "gomod" # See documentation for possible values directory: "/" # Location of package manifests schedule: - interval: "weekly" + interval: "monthly" From bef13e1b4c6d00c1e53995bdb80bb380f5ddaba4 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Thu, 19 Dec 2024 00:29:07 -0500 Subject: [PATCH 3/4] ci: adjust CI to account for removed db reset --- deploy/sink/db_reset.sql | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 deploy/sink/db_reset.sql diff --git a/deploy/sink/db_reset.sql b/deploy/sink/db_reset.sql deleted file mode 100644 index e59217b04..000000000 --- a/deploy/sink/db_reset.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Connect to a different database first (postgres) since we can't drop a database while connected to it -\c postgres; - --- Terminate all connections to the databases -SELECT pg_terminate_backend(pid) -FROM pg_stat_activity -WHERE datname IN ('chainindex', 'highway', 'matrixhs') -AND pid <> pg_backend_pid(); - --- Drop the databases if they exist -DROP DATABASE IF EXISTS chainindex; -DROP DATABASE IF EXISTS highway; -DROP DATABASE IF EXISTS matrixhs; - --- Drop the users if they exist -DROP USER IF EXISTS chainindex_user; -DROP USER IF EXISTS highway_user; -DROP USER IF EXISTS matrixhs_user; - From 15e09036d877a849540afd186b412bdf04babec6 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Thu, 19 Dec 2024 06:42:43 -0500 Subject: [PATCH 4/4] refactor: improve CI/CD workflows for release and checks --- .github/workflows/checks.yml | 35 +++++++++++++++----- .github/workflows/on-merge.yml | 42 ------------------------ .github/workflows/publish.yml | 6 ++-- .github/workflows/release.yml | 58 +++------------------------------- 4 files changed, 36 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/on-merge.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a83f4cc55..2183f20b0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -2,11 +2,13 @@ name: Run All Checks on: pull_request: - types: [opened, edited] + types: [opened, edited, closed] merge_group: jobs: - pr-labeler: + tidy-pr: + name: Tidy PR + if: github.event_name == 'pull_request' permissions: contents: read # for TimonVS/pr-labeler-action to read config file pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR @@ -95,10 +97,10 @@ jobs: check-latest: true - run: make test-cover - goreleaser-check: + validate-release: if: github.event_name == 'merge_group' runs-on: ubuntu-latest - name: Check GoReleaser Config + name: Verify Release Config steps: - name: Checkout repository uses: actions/checkout@v4 @@ -115,19 +117,36 @@ jobs: - name: Check GoReleaser Config uses: goreleaser/goreleaser-action@v6 with: - distribution: goreleaser-pro + distribution: goreleaser version: latest args: check env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - name: GoReleaser Dry Run uses: goreleaser/goreleaser-action@v6 with: - distribution: goreleaser-pro + distribution: goreleaser version: latest args: release --snapshot --clean --skip=publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + bump-version: + if: github.event_name == 'merge_group' + runs-on: ubuntu-latest + name: Bump Current Version + needs: [validate-release, test-cover, test-race] + outputs: + new_tag: ${{ steps.bump.outputs.new_tag }} + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - name: Create bump and changelog + id: bump + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + increment: "PATCH" diff --git a/.github/workflows/on-merge.yml b/.github/workflows/on-merge.yml deleted file mode 100644 index a2e8111f1..000000000 --- a/.github/workflows/on-merge.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Update Version and Release - -on: - push: - branches: - - master - -permissions: - contents: write - pull-requests: write - -jobs: - bump-version: - runs-on: ubuntu-latest - name: "Bump Version" - if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }} - outputs: - new_tag: ${{ steps.bump.outputs.new_tag }} - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - name: Create bump and changelog - id: bump - uses: commitizen-tools/commitizen-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - increment: "PATCH" - - trigger-release: - needs: [bump-version] - if: needs.bump-version.outputs.new_tag != '' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Trigger release workflow - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - event-type: trigger-release - client-payload: '{"tag": "${{ needs.bump-version.outputs.new_tag }}"}' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 472aad248..e2773b63f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,7 @@ on: push: branches: - develop + - main paths: - "docs/**" - "proto/**" @@ -12,12 +13,12 @@ permissions: issues: write jobs: - buf_push_core: + buf_push: name: Publish to buf.build/onsonr/sonr runs-on: ubuntu-latest steps: # Run `git checkout` - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Install the `buf` CLI - uses: bufbuild/buf-setup-action@v1 # Push only the Input in `proto` to the BSR @@ -29,6 +30,7 @@ jobs: publish-docs: runs-on: ubuntu-latest + name: Publish Docs steps: - uses: actions/checkout@v4 - name: Configure Git Credentials diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd787957c..af8ff1126 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,48 +4,14 @@ on: push: tags: - v* - branches: - - develop - - main permissions: contents: write jobs: - check-release: - name: Check Existing Release - runs-on: ubuntu-latest - outputs: - release_exists: ${{ steps.check.outputs.release_exists }} - is_tag: ${{ steps.check-ref.outputs.is_tag }} - ref_name: ${{ steps.check-ref.outputs.ref_name }} - steps: - - name: Determine ref type and name - id: check-ref - run: | - if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "is_tag=true" >> "$GITHUB_OUTPUT" - echo "ref_name=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" - else - echo "is_tag=false" >> "$GITHUB_OUTPUT" - echo "ref_name=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT" - fi - - - name: Check if release exists - id: check - if: steps.check-ref.outputs.is_tag == 'true' - run: | - RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/onsonr/sonr/releases/tags/${GITHUB_REF#refs/tags/}" \ - | jq -r 'if .message == "Not Found" then "false" else "true" end') - echo "release_exists=$RELEASE_EXISTS" >> "$GITHUB_OUTPUT" - - goreleaser: - name: Run GoReleaser - needs: check-release - if: | - (needs.check-release.outputs.is_tag == 'true' && needs.check-release.outputs.release_exists == 'false') || - (needs.check-release.outputs.is_tag == 'false') + new-release: + name: Run GoReleaser on New Tag + if: startsWith(github.ref, 'refs/tags/') permissions: write-all runs-on: ubuntu-latest steps: @@ -56,18 +22,6 @@ jobs: fetch-depth: 0 fetch-tags: true - - name: Set up release configuration - id: setup - run: | - if [[ "${{ needs.check-release.outputs.is_tag }}" == "true" ]]; then - echo "Using tag configuration" - git checkout ${{ needs.check-release.outputs.ref_name }} - echo "args=release --clean" >> "$GITHUB_OUTPUT" - else - echo "Using snapshot configuration" - echo "args=release --snapshot --clean" >> "$GITHUB_OUTPUT" - fi - - uses: actions/setup-go@v5 with: go-version: "1.23" @@ -82,14 +36,12 @@ jobs: - name: Release uses: goreleaser/goreleaser-action@v6 with: - distribution: goreleaser-pro + distribution: goreleaser version: latest - args: ${{ steps.setup.outputs.args }} + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} - CLOUDSMITH_TOKEN: ${{ secrets.CLOUDSMITH_TOKEN }}