From 4c7fe0d5b578c08d4b75d9784b752b00974ceb9c Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Tue, 5 Nov 2024 12:22:00 +0700 Subject: [PATCH 01/14] add workflow --- .github/workflows/readme-check.yml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/readme-check.yml diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml new file mode 100644 index 000000000000..c288adbc8ec9 --- /dev/null +++ b/.github/workflows/readme-check.yml @@ -0,0 +1,44 @@ +name: Check README Updates + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + check-readme: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Find README.docify.md files and check generated READMEs + run: | + # Find all README.docify.md files + DOCIFY_FILES=$(find . -name "README.docify.md") + + for file in $DOCIFY_FILES; do + echo "Processing $file" + + # Get the directory containing the docify file + DIR=$(dirname "$file") + + # Go to the directory and run cargo build + cd "$DIR" + cargo build --features generate-readme + + # Check if README.md has any uncommitted changes + git diff --exit-code README.md + + if [ $? -ne 0 ]; then + echo "Error: Found uncommitted changes in $DIR/README.md" + echo "Please regenerate the README.md file and commit the changes" + exit 1 + fi + + # Return to the original directory + cd - > /dev/null + done From f76e551376ef075c666c10701952f03e4f6832e8 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 22:24:34 +0700 Subject: [PATCH 02/14] Refactor README generation script --- .../check-missing-readme-generation.sh | 36 +++++++++++++++++++ .github/workflows/readme-check.yml | 27 +------------- 2 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 .github/scripts/check-missing-readme-generation.sh diff --git a/.github/scripts/check-missing-readme-generation.sh b/.github/scripts/check-missing-readme-generation.sh new file mode 100644 index 000000000000..4da6e32b0ed7 --- /dev/null +++ b/.github/scripts/check-missing-readme-generation.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Find all README.docify.md files +DOCIFY_FILES=$(find . -name "README.docify.md") + +# Initialize a variable to track directories needing README regeneration +NEED_REGENERATION="" + +for file in $DOCIFY_FILES; do + echo "Processing $file" + + # Get the directory containing the docify file + DIR=$(dirname "$file") + + # Go to the directory and run cargo build + cd "$DIR" + cargo check --features generate-readme || echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." + + # Check if README.md has any uncommitted changes + git diff --exit-code README.md + + if [ $? -ne 0 ]; then + echo "Error: Found uncommitted changes in $DIR/README.md" + NEED_REGENERATION="$NEED_REGENERATION $DIR" + fi + + # Return to the original directory + cd - > /dev/null +done + +# Check if any directories need README regeneration +if [ -n "$NEED_REGENERATION" ]; then + echo "The following directories need README regeneration:" + echo "$NEED_REGENERATION" + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index c288adbc8ec9..a268e64293a6 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -16,29 +16,4 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Find README.docify.md files and check generated READMEs - run: | - # Find all README.docify.md files - DOCIFY_FILES=$(find . -name "README.docify.md") - - for file in $DOCIFY_FILES; do - echo "Processing $file" - - # Get the directory containing the docify file - DIR=$(dirname "$file") - - # Go to the directory and run cargo build - cd "$DIR" - cargo build --features generate-readme - - # Check if README.md has any uncommitted changes - git diff --exit-code README.md - - if [ $? -ne 0 ]; then - echo "Error: Found uncommitted changes in $DIR/README.md" - echo "Please regenerate the README.md file and commit the changes" - exit 1 - fi - - # Return to the original directory - cd - > /dev/null - done + run: .github/scripts/check-missing-readme-generation.sh From 536794509ebc275cceabc0434d9907e14e4711ec Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 22:25:14 +0700 Subject: [PATCH 03/14] Refactor README generation script and make check-missing-readme-generation.sh executable --- .github/workflows/readme-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index a268e64293a6..39d6772aeba9 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -15,5 +15,8 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable + - name: Make check-missing-readme-generation.sh executable + run: chmod +x .github/scripts/check-missing-readme-generation.sh + - name: Find README.docify.md files and check generated READMEs run: .github/scripts/check-missing-readme-generation.sh From 5959247bf0c3a0b3f8b21f8d255c1c184d69659c Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 22:42:36 +0700 Subject: [PATCH 04/14] Refactor README check workflow to include additional pull request events --- .github/scripts/check-missing-readme-generation.sh | 0 .github/workflows/readme-check.yml | 5 +---- 2 files changed, 1 insertion(+), 4 deletions(-) mode change 100644 => 100755 .github/scripts/check-missing-readme-generation.sh diff --git a/.github/scripts/check-missing-readme-generation.sh b/.github/scripts/check-missing-readme-generation.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index 39d6772aeba9..ba223455089f 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -2,7 +2,7 @@ name: Check README Updates on: pull_request: - branches: [main] + types: [opened, synchronize, reopened, ready_for_review] push: branches: [main] @@ -15,8 +15,5 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Make check-missing-readme-generation.sh executable - run: chmod +x .github/scripts/check-missing-readme-generation.sh - - name: Find README.docify.md files and check generated READMEs run: .github/scripts/check-missing-readme-generation.sh From d4aefeb46405c67bf4f4572ea55db8229579b843 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 22:44:08 +0700 Subject: [PATCH 05/14] Refactor README check workflow to include additional pull request events --- .github/workflows/readme-check.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index ba223455089f..6f73bc6130f2 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -1,10 +1,17 @@ name: Check README Updates on: + push: + branches: + - master pull_request: types: [opened, synchronize, reopened, ready_for_review] - push: - branches: [main] + workflow_dispatch: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: check-readme: From 041d1436f91e2bb75ff1ca9d6d5017baf3703415 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 21:24:38 +0530 Subject: [PATCH 06/14] Update .github/workflows/readme-check.yml Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> --- .github/workflows/readme-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index 6f73bc6130f2..b82c0d2db1c2 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -17,7 +17,7 @@ jobs: check-readme: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable From 12dcb4ee37068f52b852b7e3849bfb16cd65b304 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 22:57:42 +0700 Subject: [PATCH 07/14] Refactor README check workflow to include additional pull request events and update Rust toolchain setup --- .github/workflows/readme-check.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index b82c0d2db1c2..6466c1c90fdc 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -16,11 +16,16 @@ concurrency: jobs: check-readme: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 + with: + cache: false + toolchain: stable + components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std - name: Find README.docify.md files and check generated READMEs run: .github/scripts/check-missing-readme-generation.sh From 071d2181a684575cfea9d195899ece32e4bdc8f3 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 23:31:13 +0700 Subject: [PATCH 08/14] exit on failing of cargo check --- .github/scripts/check-missing-readme-generation.sh | 2 +- .github/workflows/readme-check.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/check-missing-readme-generation.sh b/.github/scripts/check-missing-readme-generation.sh index 4da6e32b0ed7..c3abf85adf84 100755 --- a/.github/scripts/check-missing-readme-generation.sh +++ b/.github/scripts/check-missing-readme-generation.sh @@ -14,7 +14,7 @@ for file in $DOCIFY_FILES; do # Go to the directory and run cargo build cd "$DIR" - cargo check --features generate-readme || echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." + cargo check --features generate-readme || echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." && exit 1 # Check if README.md has any uncommitted changes git diff --exit-code README.md diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index 6466c1c90fdc..28ab18026ba7 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -6,7 +6,6 @@ on: - master pull_request: types: [opened, synchronize, reopened, ready_for_review] - workflow_dispatch: merge_group: concurrency: From e17dc3d1436299bce2ecca72dea928103e7e6688 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 7 Nov 2024 23:43:11 +0700 Subject: [PATCH 09/14] Refactor README check script to exit on failing cargo check --- .github/scripts/check-missing-readme-generation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check-missing-readme-generation.sh b/.github/scripts/check-missing-readme-generation.sh index c3abf85adf84..7d35382ad320 100755 --- a/.github/scripts/check-missing-readme-generation.sh +++ b/.github/scripts/check-missing-readme-generation.sh @@ -14,7 +14,7 @@ for file in $DOCIFY_FILES; do # Go to the directory and run cargo build cd "$DIR" - cargo check --features generate-readme || echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." && exit 1 + cargo check --features generate-readme || { echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." && exit 1; } # Check if README.md has any uncommitted changes git diff --exit-code README.md From 367a695e4279f61e3ea2d361c03e8ffa7751e6a3 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 11 Nov 2024 15:30:17 +0530 Subject: [PATCH 10/14] Update .github/workflows/readme-check.yml Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> --- .github/workflows/readme-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index 28ab18026ba7..e82e2ed00452 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -23,7 +23,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 with: cache: false - toolchain: stable + toolchain: ${{ env.RUST_VERSION }} components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std - name: Find README.docify.md files and check generated READMEs From 778709d8543a4eb76e345752d9779b0ed2bff3dc Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 11 Nov 2024 15:30:26 +0530 Subject: [PATCH 11/14] Update .github/workflows/readme-check.yml Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> --- .github/workflows/readme-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml index e82e2ed00452..f2432b29d092 100644 --- a/.github/workflows/readme-check.yml +++ b/.github/workflows/readme-check.yml @@ -22,6 +22,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 with: + target: wasm32-unknown-unknown cache: false toolchain: ${{ env.RUST_VERSION }} components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std From 999289eed8fbac06384f25e53e8cbdc94e09a4e2 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 11 Nov 2024 15:30:37 +0530 Subject: [PATCH 12/14] Update .github/scripts/check-missing-readme-generation.sh Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> --- .github/scripts/check-missing-readme-generation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check-missing-readme-generation.sh b/.github/scripts/check-missing-readme-generation.sh index 7d35382ad320..13f2b6a7cb28 100755 --- a/.github/scripts/check-missing-readme-generation.sh +++ b/.github/scripts/check-missing-readme-generation.sh @@ -1,5 +1,5 @@ #!/bin/bash - +echo "Running script relative to `pwd`" # Find all README.docify.md files DOCIFY_FILES=$(find . -name "README.docify.md") From 69708be61ae533839c99820babb0efaf380b5355 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 11 Nov 2024 15:35:45 +0530 Subject: [PATCH 13/14] address reviews --- .github/workflows/checks-quick.yml | 23 +++++++++++++++++++++- .github/workflows/readme-check.yml | 31 ------------------------------ 2 files changed, 22 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/readme-check.yml diff --git a/.github/workflows/checks-quick.yml b/.github/workflows/checks-quick.yml index 36deba7dfb78..d3cfe9c40083 100644 --- a/.github/workflows/checks-quick.yml +++ b/.github/workflows/checks-quick.yml @@ -15,7 +15,6 @@ concurrency: permissions: {} jobs: - preflight: uses: ./.github/workflows/reusable-preflight.yml @@ -172,6 +171,27 @@ jobs: env: ASSERT_REGEX: "FAIL-CI" GIT_DEPTH: 1 + check-readme: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Set rust version from env file + run: | + RUST_VERSION=$(cat .github/env | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/') + echo $RUST_VERSION + echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV + + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 + with: + cache: false + toolchain: ${{ env.RUST_VERSION }} + components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std + + - name: Find README.docify.md files and check generated READMEs + run: .github/scripts/check-missing-readme-generation.sh confirm-required-checks-quick-jobs-passed: runs-on: ubuntu-latest @@ -187,6 +207,7 @@ jobs: - check-markdown - check-umbrella - check-fail-ci + - check-readme if: always() && !cancelled() steps: - run: | diff --git a/.github/workflows/readme-check.yml b/.github/workflows/readme-check.yml deleted file mode 100644 index f2432b29d092..000000000000 --- a/.github/workflows/readme-check.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Check README Updates - -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - merge_group: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - check-readme: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 - with: - target: wasm32-unknown-unknown - cache: false - toolchain: ${{ env.RUST_VERSION }} - components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std - - - name: Find README.docify.md files and check generated READMEs - run: .github/scripts/check-missing-readme-generation.sh From ca2718e23daea66c37c63f5eed19e272ec3b6a33 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Mon, 11 Nov 2024 15:51:17 +0530 Subject: [PATCH 14/14] Update checks-quick.yml to install protobuf-compiler --- .github/workflows/checks-quick.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/checks-quick.yml b/.github/workflows/checks-quick.yml index d3cfe9c40083..28f5bf932e2c 100644 --- a/.github/workflows/checks-quick.yml +++ b/.github/workflows/checks-quick.yml @@ -177,6 +177,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install prerequisites + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler + - name: Set rust version from env file run: | RUST_VERSION=$(cat .github/env | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/')