From 523386a720dd0ae09fbd1683e9f54c290f03711e Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Thu, 13 Oct 2022 07:01:42 +0530 Subject: [PATCH] Merge CLI docs genertion and lint (#1130) ## Description If any of the dependents were skipped, the CI would skip a job. This resulted in `Docs-Linting` getting skipped because of `Generate-CLI-Docs` job being skipped for doc only change. Now they are both merged into a single job. The internal steps for cli docs generation will still be skipped, but that should not affect the steps below. *I have not been able to fully test it out as the "file change checker" logic can only be checked after merging it, but it should be working* Ref: https://github.com/orgs/community/discussions/25224 ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [x] :computer: CI/Deployment - [ ] :hamster: Trivial/Minor ## Issue(s) * # ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .github/workflows/ci.yml | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38c00e9c5..5f0bce726 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,54 +46,45 @@ jobs: go-version-file: src/go.mod # ---------------------------------------------------------------------------------------------------- - # --- Generate CLI docs ------------------------------------------------------------------------------ + # --- Docs Linting ----------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------- - Generate-CLI-Docs: + Docs-Linting: needs: [Precheck, Checkout] environment: Testing - if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.srcfileschanged == 'true' runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.docfileschanged == 'true' # docsfileschanged also includes srcfileschanged + steps: - uses: actions/checkout@v3 - name: Setup Golang with cache + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.srcfileschanged == 'true' uses: magnetikonline/action-golang-cache@v3 with: go-version-file: src/go.mod - # run the markdown generator - - name: Generate Markdown + - name: Generate CLI Docs + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.srcfileschanged == 'true' working-directory: ./src run: | go run ./cmd/mdgen/mdgen.go generate # migrate generated md files into /docs/docs/cli - name: Move CLI .md to Docs + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.srcfileschanged == 'true' run: | mkdir -p ./docs/docs/cli mv ./src/cmd/mdgen/cli_markdown/* ./docs/docs/cli/ rm -R ./src/cmd/mdgen/cli_markdown/ - uses: actions/upload-artifact@master + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.srcfileschanged == 'true' name: Upload cli docs as artifacts with: name: cli-docs path: docs/docs/cli - # ---------------------------------------------------------------------------------------------------- - # --- Docs Linting ----------------------------------------------------------------------------------- - # ---------------------------------------------------------------------------------------------------- - - Docs-Linting: - needs: [Generate-CLI-Docs] - environment: Testing - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || needs.precheck.outputs.docfileschanged == 'true' - - steps: - - uses: actions/checkout@v3 - - name: Install dependencies for docs lint run: | wget https://github.com/errata-ai/vale/releases/download/v2.20.2/vale_2.20.2_Linux_64-bit.tar.gz # NOTE: update in Dockerfile when updating @@ -101,12 +92,6 @@ jobs: echo "$PWD/bin" >> $GITHUB_PATH npm i -g markdownlint-cli@0.32.2 # NOTE: update in Dockerfile when updating - - uses: actions/download-artifact@master - name: Download cli docs from build step - with: - name: cli-docs - path: docs/docs/cli - - name: Run docs lint run: | cd docs && make -o genclidocs check