From 21f9f9f04182c6ab71d630d2ff1a7de6bbd049c1 Mon Sep 17 00:00:00 2001 From: clearloop Date: Thu, 29 Feb 2024 20:09:20 +0800 Subject: [PATCH 1/8] ci(PR): fetch the check of typos --- .github/workflows/PR.yml | 7 +++++++ .github/workflows/typos.yml | 20 -------------------- 2 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/typos.yml diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 374d187f07e..67ddc702e2b 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -16,6 +16,13 @@ env: BINARYEN_VERSION: version_111 jobs: + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: typos-action + uses: crate-ci/typos@master + status: runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml deleted file mode 100644 index 110ba5d8774..00000000000 --- a/.github/workflows/typos.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Typos - -on: - pull_request: - branches: [master, vara-stage-1, vara-stage-2, vara-stage-3] - -env: - CARGO_INCREMENTAL: 0 - CARGO_TERM_COLOR: always - RUST_BACKTRACE: short - TERM: xterm-256color - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: typos-action - uses: crate-ci/typos@master From 44714418acbdd4a93f05bbd0c34de11013a97183 Mon Sep 17 00:00:00 2001 From: clearloop Date: Thu, 29 Feb 2024 20:23:04 +0800 Subject: [PATCH 2/8] ci(PR): gather docs inside of PR.yml --- .github/actions/docs/action.yml | 35 ++++++++++++++++++++++ .github/actions/message/action.yml | 2 ++ .github/actions/message/main.js | 47 ++++++++++++++++++++---------- .github/workflows/PR.yml | 9 ++++++ .github/workflows/docs.yml | 37 +---------------------- 5 files changed, 78 insertions(+), 52 deletions(-) create mode 100644 .github/actions/docs/action.yml diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml new file mode 100644 index 00000000000..bc5c7987baf --- /dev/null +++ b/.github/actions/docs/action.yml @@ -0,0 +1,35 @@ +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - name: "Install: Rust toolchain" + uses: dsherret/rust-toolchain-file@v1 + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - name: Build docs + run: make doc + + - name: Copy logo image + run: cp ./images/logo.svg ./target/doc/ + + - name: Deploy + if: github.event_name == 'push' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc + cname: docs.gear.rs + force_orphan: true + user_name: "github-actions[bot]" + user_email: "github-actions[bot]@users.noreply.github.com" + + - name: Deploy PR + if: github.event_name == 'pull_request' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc + destination_dir: pr-${{ github.event.number }} diff --git a/.github/actions/message/action.yml b/.github/actions/message/action.yml index e7d99d895b9..3545670aef5 100644 --- a/.github/actions/message/action.yml +++ b/.github/actions/message/action.yml @@ -12,6 +12,8 @@ outputs: description: If enable cache. check: description: If trigger check. + docs: + description: If trigger docs. macos: description: If enable macos. diff --git a/.github/actions/message/main.js b/.github/actions/message/main.js index a09b0cf274d..0aa061606b7 100644 --- a/.github/actions/message/main.js +++ b/.github/actions/message/main.js @@ -3,14 +3,18 @@ */ const ps = require("child_process"); -const core = require('@actions/core'); -const github = require('@actions/github'); +const core = require("@actions/core"); +const github = require("@actions/github"); -const BUILD_LABELS = ["A0-pleasereview", 'A4-insubstantial', 'A2-mergeoncegreen']; -const CHECKS = ["check", "build"] +const BUILD_LABELS = [ + "A0-pleasereview", + "A4-insubstantial", + "A2-mergeoncegreen", +]; +const CHECKS = ["check", "build"]; const DEPBOT = "[depbot]"; const MACOS = "E2-forcemacos"; -const SCCACHE_PREFIX = '/mnt/sccache/'; +const SCCACHE_PREFIX = "/mnt/sccache/"; const SKIP_CI = "[skip-ci]"; const SKIP_CACHE = "[skip-cache]"; const [owner, repo] = ["gear-tech", "gear"]; @@ -47,11 +51,17 @@ async function mock(head_sha) { */ async function main() { const { - pull_request: { title, head: { sha, ref: branch }, labels: _labels }, - repository: { full_name: fullName } + pull_request: { + title, + head: { sha, ref: branch }, + labels: _labels, + }, + repository: { full_name: fullName }, } = github.context.payload; - const labels = _labels.map(l => l.name); - const message = ps.execSync(`git log --format=%B -n 1 ${sha}`, { encoding: "utf-8" }).trim(); + const labels = _labels.map((l) => l.name); + const message = ps + .execSync(`git log --format=%B -n 1 ${sha}`, { encoding: "utf-8" }) + .trim(); console.log("message: ", message); console.log("head-sha: ", sha); @@ -61,19 +71,24 @@ async function main() { // Calculate configurations. const isDepbot = fullName === `${owner}/${repo}` && title.includes(DEPBOT); - const skipCache = [title, message].some(s => s.includes(SKIP_CACHE)); - const skipCI = [title, message].some(s => s.includes(SKIP_CI)); - const build = !skipCI && (isDepbot || BUILD_LABELS.some(label => labels.includes(label))); + const skipCache = [title, message].some((s) => s.includes(SKIP_CACHE)); + const skipCI = [title, message].some((s) => s.includes(SKIP_CI)); + const build = + !skipCI && + (isDepbot || BUILD_LABELS.some((label) => labels.includes(label))); const macos = !skipCI && labels.includes(MACOS); + const docs = !skipCI && !isDepbot; const cache = SCCACHE_PREFIX + branch.replace("/", "_"); // Set outputs + core.setOutput("docs", docs); core.setOutput("build", build); core.setOutput("check", !skipCI); core.setOutput("macos", macos); - !skipCache && core.setOutput("cache", cache) + !skipCache && core.setOutput("cache", cache); console.log("---"); + console.log("docs: ", docs); console.log("build: ", build); console.log("cache: ", skipCache ? "false" : cache); console.log("check: ", !skipCI); @@ -83,7 +98,7 @@ async function main() { if (skipCI) await mock(sha); } -main().catch(err => { +main().catch((err) => { core.error("ERROR: ", err.message); - core.error(err.stack) -}) + core.error(err.stack); +}); diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 67ddc702e2b..69a6989507e 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -29,6 +29,7 @@ jobs: build: ${{ steps.config.outputs.build }} cache: ${{ steps.config.outputs.cache }} check: ${{ steps.config.outputs.check }} + docs: ${{ steps.config.outputs.docs }} macos: ${{ steps.config.outputs.macos }} steps: - uses: actions/checkout@v4 @@ -44,6 +45,14 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + docs: + needs: status + if: ${{ needs.status.outputs.docs == 'true' }} + runs-on: ubuntu-lastet + env: + RUSTUP_HOME: /tmp/rustup_home + uses: ./.github/actions/docs + check: needs: status if: ${{ needs.status.outputs.check == 'true' }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1271af50f00..eca66610094 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,8 +1,6 @@ name: Docs on: - pull_request: - branches: [master] push: branches: [master] @@ -15,37 +13,4 @@ jobs: runs-on: ubuntu-latest env: RUSTUP_HOME: /tmp/rustup_home - if: ${{ !contains(github.event.pull_request.title, '[skip-ci]') && github.actor != 'dependabot[bot]' }} - steps: - - uses: actions/checkout@v4 - - - name: "Install: Rust toolchain" - uses: dsherret/rust-toolchain-file@v1 - - - name: Cache - uses: Swatinem/rust-cache@v2 - - - name: Build docs - run: make doc - - - name: Copy logo image - run: cp ./images/logo.svg ./target/doc/ - - - name: Deploy - if: github.event_name == 'push' - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./target/doc - cname: docs.gear.rs - force_orphan: true - user_name: "github-actions[bot]" - user_email: "github-actions[bot]@users.noreply.github.com" - - - name: Deploy PR - if: github.event_name == 'pull_request' - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./target/doc - destination_dir: pr-${{ github.event.number }} + uses: ./.github/actions/docs From dcad0ae74edb01cf4ce2899e89f26a0dd67377cc Mon Sep 17 00:00:00 2001 From: clearloop Date: Thu, 29 Feb 2024 20:25:07 +0800 Subject: [PATCH 3/8] ci(docs): syntax of calling composite component --- .github/workflows/PR.yml | 3 ++- .github/workflows/docs.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 69a6989507e..778e1957e06 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -51,7 +51,8 @@ jobs: runs-on: ubuntu-lastet env: RUSTUP_HOME: /tmp/rustup_home - uses: ./.github/actions/docs + steps: + - uses: ./.github/actions/docs check: needs: status diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index eca66610094..f6cb99c7b6a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,4 +13,5 @@ jobs: runs-on: ubuntu-latest env: RUSTUP_HOME: /tmp/rustup_home - uses: ./.github/actions/docs + steps: + - uses: ./.github/actions/docs From 5a493b16a6b20593139c16557cc6729ace65d011 Mon Sep 17 00:00:00 2001 From: clearloop Date: Thu, 29 Feb 2024 20:32:20 +0800 Subject: [PATCH 4/8] ci(build): get out of dispach from validator checks namespace From b884bd1785ed13fc6aa6b79a9cae17b69ce66ea6 Mon Sep 17 00:00:00 2001 From: clearloop Date: Wed, 13 Mar 2024 00:15:08 +0800 Subject: [PATCH 5/8] ci(docs): address comments --- .github/actions/docs/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml index bc5c7987baf..a88d9729a68 100644 --- a/.github/actions/docs/action.yml +++ b/.github/actions/docs/action.yml @@ -1,7 +1,8 @@ runs: using: composite steps: - - uses: actions/checkout@v4 + - name: "ACTIONS: Checkout" + uses: actions/checkout@v4 - name: "Install: Rust toolchain" uses: dsherret/rust-toolchain-file@v1 From 61be4750c31f4955d9be6aa14106349a217cf6af Mon Sep 17 00:00:00 2001 From: clearloop Date: Mon, 18 Mar 2024 18:38:34 +0800 Subject: [PATCH 6/8] ci(PR): correct the machine for docs --- .github/actions/label/build.js | 19 +++++++++++-------- .github/workflows/PR.yml | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/actions/label/build.js b/.github/actions/label/build.js index 1bda6876641..2dd0add022c 100644 --- a/.github/actions/label/build.js +++ b/.github/actions/label/build.js @@ -36,17 +36,20 @@ const checkSkip = async ({ github, core }) => { ref: REF, }); - if (check_runs.filter((run) => ( - (run.name === "build" && run.conclusion !== "skipped") - || run.name === "build / linux" - || run.name === "build / macos-x86" - )).length > 0) { + if ( + check_runs.filter( + (run) => + (run.name === "build" && run.conclusion !== "skipped") || + run.name === "build / linux" || + run.name === "build / macos-x86" + ).length > 0 + ) { core.info( "Build has already been processed, check runs: ", JSON.stringify(check_runs, null, 2) ); - process.exit(0) + process.exit(0); } }; @@ -59,7 +62,7 @@ const checkSkip = async ({ github, core }) => { **/ const createChecks = async ({ core, github }) => { let status = {}; - for (check of checks) { + for (const check of checks) { const { data: res } = await github.rest.checks.create({ owner, repo, @@ -153,7 +156,7 @@ module.exports = async ({ github, core }) => { const jobs = await listJobs({ github, core, run_id: run.id }); completed = jobs.filter((job) => job.status === "completed").length; - for (job of jobs) { + for (const job of jobs) { let checkJob = labelChecks[job.name]; if ( checkJob.status !== job.status || diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 5d26c7a6c46..e1fa59c61f8 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -46,7 +46,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} docs: - runs-on: ubuntu-lastet + runs-on: ubuntu-latest env: RUSTUP_HOME: /tmp/rustup_home steps: From 7c88899261f1df212d106fbf225753ccf58a8767 Mon Sep 17 00:00:00 2001 From: clearloop Date: Mon, 18 Mar 2024 18:42:47 +0800 Subject: [PATCH 7/8] ci(docs): checkout before process docs --- .github/actions/docs/action.yml | 3 --- .github/workflows/PR.yml | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml index a88d9729a68..ac36d00958f 100644 --- a/.github/actions/docs/action.yml +++ b/.github/actions/docs/action.yml @@ -1,9 +1,6 @@ runs: using: composite steps: - - name: "ACTIONS: Checkout" - uses: actions/checkout@v4 - - name: "Install: Rust toolchain" uses: dsherret/rust-toolchain-file@v1 diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index e1fa59c61f8..496bbd9aeda 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -50,6 +50,7 @@ jobs: env: RUSTUP_HOME: /tmp/rustup_home steps: + - uses: actions/checkout@v4 - uses: ./.github/actions/docs check: From fc33a96652529b0f045d653f6454b12695178438 Mon Sep 17 00:00:00 2001 From: clearloop Date: Mon, 18 Mar 2024 19:15:02 +0800 Subject: [PATCH 8/8] ci(docs): parameters of docs --- .github/actions/docs/action.yml | 10 ++++++++-- .github/workflows/PR.yml | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml index ac36d00958f..a3cd26bb16f 100644 --- a/.github/actions/docs/action.yml +++ b/.github/actions/docs/action.yml @@ -1,3 +1,7 @@ +inputs: + github_token: + required: true + runs: using: composite steps: @@ -9,15 +13,17 @@ runs: - name: Build docs run: make doc + shell: bash - name: Copy logo image run: cp ./images/logo.svg ./target/doc/ + shell: bash - name: Deploy if: github.event_name == 'push' uses: peaceiris/actions-gh-pages@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ inputs.github_token }} publish_dir: ./target/doc cname: docs.gear.rs force_orphan: true @@ -28,6 +34,6 @@ runs: if: github.event_name == 'pull_request' uses: peaceiris/actions-gh-pages@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ inputs.github_token }} publish_dir: ./target/doc destination_dir: pr-${{ github.event.number }} diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 496bbd9aeda..bfef347cd75 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -52,6 +52,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/docs + with: + github_token: ${{ secrets.GITHUB_TOKEN }} check: needs: status