From 217645ab3afc8af38d4b90fd1c002cb7d40e5008 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 10:46:09 +0700 Subject: [PATCH 01/10] feat(docs): add workflow to generate documentation on PR merge --- .github/workflows/docsgen-cli.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/docsgen-cli.yml diff --git a/.github/workflows/docsgen-cli.yml b/.github/workflows/docsgen-cli.yml new file mode 100644 index 00000000000..e55c1f68f97 --- /dev/null +++ b/.github/workflows/docsgen-cli.yml @@ -0,0 +1,31 @@ +name: Generate Documentation + +on: + pull_request: + types: [closed] + branches: + - master + +jobs: + generate-docs: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Generate documentation + run: make docsgen-cli + + - name: Commit and push generated docs + run: | + if [ -n "$(git status --porcelain)" ]; then + git config user.name "GitHub Actions" + git config user.email noreply@github.com + git add . + git commit --amend --no-edit + git push --force + else + echo "No changes to commit" + fi From 84e5487823cfcfd015015b152ad90b99a26c3bd5 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 09:22:37 +0530 Subject: [PATCH 02/10] Update .github/workflows/docsgen-cli.yml Co-authored-by: Rod Vagg --- .github/workflows/docsgen-cli.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docsgen-cli.yml b/.github/workflows/docsgen-cli.yml index e55c1f68f97..5c5ca0a37e2 100644 --- a/.github/workflows/docsgen-cli.yml +++ b/.github/workflows/docsgen-cli.yml @@ -1,5 +1,8 @@ name: Generate Documentation +permissions: + contents: write + on: pull_request: types: [closed] From 145b3b45621e87e370985d57d7ecb071b2d8b431 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 11:01:18 +0700 Subject: [PATCH 03/10] remove docsgen-cli check in github actions --- .github/workflows/check.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6b9046a46de..0c43d8fced2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,21 +26,19 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go - uses: ./.github/actions/make-deps - run: make gen - run: git diff --exit-code - - run: make docsgen-cli - - run: git diff --exit-code check-lint: name: Check (lint-all) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go - uses: ./.github/actions/make-deps @@ -52,7 +50,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" - uses: ./.github/actions/install-go - run: go fmt ./... - run: git diff --exit-code @@ -62,7 +60,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" - uses: ./.github/actions/install-go - run: go mod tidy -v - run: git diff --exit-code From 6f3602ad4230d375e92fbf1e4ae959223c4c1845 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 14:55:41 +0700 Subject: [PATCH 04/10] run on push --- .github/workflows/docsgen-cli.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docsgen-cli.yml b/.github/workflows/docsgen-cli.yml index 5c5ca0a37e2..ef281958928 100644 --- a/.github/workflows/docsgen-cli.yml +++ b/.github/workflows/docsgen-cli.yml @@ -5,13 +5,12 @@ permissions: on: pull_request: - types: [closed] branches: - master + types: [opened, synchronize, reopened] jobs: generate-docs: - if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: From 5a6d6eb65f465ece1afbd64daeb2eeecdf41d23e Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 20:09:51 +0530 Subject: [PATCH 05/10] address changes --- .../{check.yml => check-and-gen.yml} | 42 +++++++++++++++++-- .github/workflows/docsgen-cli.yml | 33 --------------- 2 files changed, 38 insertions(+), 37 deletions(-) rename .github/workflows/{check.yml => check-and-gen.yml} (55%) delete mode 100644 .github/workflows/docsgen-cli.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check-and-gen.yml similarity index 55% rename from .github/workflows/check.yml rename to .github/workflows/check-and-gen.yml index 64fef79e6a3..dce77010dfc 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check-and-gen.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -52,7 +52,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" fetch-depth: 0 - uses: ./.github/actions/install-go - run: go fmt ./... @@ -63,8 +63,42 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: 'recursive' + submodules: "recursive" fetch-depth: 0 - uses: ./.github/actions/install-go - run: go mod tidy -v - run: git diff --exit-code + generate-docs: + name: Generate API Documentation + runs-on: ubuntu-latest + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + + - uses: ./.github/actions/install-system-dependencies + - uses: ./.github/actions/install-go + - uses: ./.github/actions/make-deps + + - name: Generate API documentation using docsgen-cli + run: | + make docsgen-cli || { + echo "Error: Documentation generation failed" + exit 1 + } + + - name: Commit and push if documentation changed + run: | + if [ -n "$(git status --porcelain)" ]; then + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "docs: update API documentation via docsgen-cli" + git push + else + echo "No documentation changes to commit" + fi diff --git a/.github/workflows/docsgen-cli.yml b/.github/workflows/docsgen-cli.yml deleted file mode 100644 index ef281958928..00000000000 --- a/.github/workflows/docsgen-cli.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Generate Documentation - -permissions: - contents: write - -on: - pull_request: - branches: - - master - types: [opened, synchronize, reopened] - -jobs: - generate-docs: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Generate documentation - run: make docsgen-cli - - - name: Commit and push generated docs - run: | - if [ -n "$(git status --porcelain)" ]; then - git config user.name "GitHub Actions" - git config user.email noreply@github.com - git add . - git commit --amend --no-edit - git push --force - else - echo "No changes to commit" - fi From 2cceea82558238a182ff88bf5af58aa5e2d001dd Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 20:13:43 +0530 Subject: [PATCH 06/10] Refactor workflow to check and generate documentation --- .github/workflows/check-and-gen.yml | 4 +- .github/workflows/check.yml | 97 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check-and-gen.yml b/.github/workflows/check-and-gen.yml index dce77010dfc..8e7cb889edc 100644 --- a/.github/workflows/check-and-gen.yml +++ b/.github/workflows/check-and-gen.yml @@ -1,4 +1,4 @@ -name: Check +name: Check and Generate on: pull_request: @@ -69,7 +69,7 @@ jobs: - run: go mod tidy -v - run: git diff --exit-code generate-docs: - name: Generate API Documentation + name: Generate Documentation runs-on: ubuntu-latest if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) permissions: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000000..228100a96f4 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,97 @@ +name: Check + +on: + pull_request: + push: + branches: + - master + - release/* + workflow_dispatch: + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + check-gen: + name: Check (gen-check) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - uses: ./.github/actions/install-system-dependencies + - uses: ./.github/actions/install-go + - uses: ./.github/actions/make-deps + - run: make gen + - run: git diff --exit-code + check-lint: + name: Check (lint-all) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - uses: ./.github/actions/install-system-dependencies + - uses: ./.github/actions/install-go + - uses: ./.github/actions/make-deps + - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 + - run: golangci-lint run -v --timeout 10m --concurrency 4 + check-fmt: + name: Check (gofmt) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - uses: ./.github/actions/install-go + - run: go fmt ./... + - run: git diff --exit-code + check-mod-tidy: + name: Check (mod-tidy-check) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - uses: ./.github/actions/install-go + - run: go mod tidy -v + - run: git diff --exit-code + generate-docs: + name: Generate Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + + - uses: ./.github/actions/install-system-dependencies + - uses: ./.github/actions/install-go + - uses: ./.github/actions/make-deps + + - name: Generate documentation + run: make docsgen-cli + + - name: Commit and push if changed + run: | + if [ -n "$(git status --porcelain)" ]; then + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "docs: update generated documentation" + git push + else + echo "No changes to commit" + fi From 046880f21b17795f868a97dd1936feb8319f302b Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 21:55:25 +0530 Subject: [PATCH 07/10] update --- .github/workflows/check-and-gen.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-and-gen.yml b/.github/workflows/check-and-gen.yml index 8e7cb889edc..334ea5a54c4 100644 --- a/.github/workflows/check-and-gen.yml +++ b/.github/workflows/check-and-gen.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -52,7 +52,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-go - run: go fmt ./... @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-go - run: go mod tidy -v @@ -77,7 +77,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies From 190f7cb4cbad941d124f092eb48991f908818865 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 21:57:54 +0530 Subject: [PATCH 08/10] update --- .github/workflows/check.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 228100a96f4..846be7694da 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go @@ -52,7 +52,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-go - run: go fmt ./... @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-go - run: go mod tidy -v @@ -74,7 +74,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: "recursive" + submodules: 'recursive' fetch-depth: 0 - uses: ./.github/actions/install-system-dependencies From 938f8b5737d6ebb5a88fe306aef4f129f22f45d4 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 21:59:30 +0530 Subject: [PATCH 09/10] update --- .github/workflows/check.yml | 97 ------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 846be7694da..00000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Check - -on: - pull_request: - push: - branches: - - master - - release/* - workflow_dispatch: - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -permissions: - contents: read - -jobs: - check-gen: - name: Check (gen-check) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 - - uses: ./.github/actions/install-system-dependencies - - uses: ./.github/actions/install-go - - uses: ./.github/actions/make-deps - - run: make gen - - run: git diff --exit-code - check-lint: - name: Check (lint-all) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 - - uses: ./.github/actions/install-system-dependencies - - uses: ./.github/actions/install-go - - uses: ./.github/actions/make-deps - - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 - - run: golangci-lint run -v --timeout 10m --concurrency 4 - check-fmt: - name: Check (gofmt) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 - - uses: ./.github/actions/install-go - - run: go fmt ./... - - run: git diff --exit-code - check-mod-tidy: - name: Check (mod-tidy-check) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 - - uses: ./.github/actions/install-go - - run: go mod tidy -v - - run: git diff --exit-code - generate-docs: - name: Generate Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 - - - uses: ./.github/actions/install-system-dependencies - - uses: ./.github/actions/install-go - - uses: ./.github/actions/make-deps - - - name: Generate documentation - run: make docsgen-cli - - - name: Commit and push if changed - run: | - if [ -n "$(git status --porcelain)" ]; then - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "docs: update generated documentation" - git push - else - echo "No changes to commit" - fi From 4e5a8c61729eaf0c6eecc4f59b5e668fea3fe769 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 18 Nov 2024 22:39:34 +0530 Subject: [PATCH 10/10] add link for bot configuration discussion --- .github/workflows/check-and-gen.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-and-gen.yml b/.github/workflows/check-and-gen.yml index 334ea5a54c4..c567a47e7ab 100644 --- a/.github/workflows/check-and-gen.yml +++ b/.github/workflows/check-and-gen.yml @@ -94,6 +94,7 @@ jobs: - name: Commit and push if documentation changed run: | if [ -n "$(git status --porcelain)" ]; then + # Bot email is configured from: https://github.com/orgs/community/discussions/26560 git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add .