diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml new file mode 100644 index 00000000000..a3cd26bb16f --- /dev/null +++ b/.github/actions/docs/action.yml @@ -0,0 +1,39 @@ +inputs: + github_token: + required: true + +runs: + using: composite + steps: + - name: "Install: Rust toolchain" + uses: dsherret/rust-toolchain-file@v1 + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - 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: ${{ inputs.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: ${{ inputs.github_token }} + publish_dir: ./target/doc + destination_dir: pr-${{ github.event.number }} 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/actions/message/main.js b/.github/actions/message/main.js index 77cd3fd8e20..0294aca8803 100644 --- a/.github/actions/message/main.js +++ b/.github/actions/message/main.js @@ -3,15 +3,19 @@ */ 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 WINDOWS_NATIVE = "E1-forcenatwin"; const MACOS = "E2-forcemacos"; -const RELEASE = "E3-forcerelease" +const RELEASE = "E3-forcerelease"; const SKIP_CI = "[skip-ci]"; const [owner, repo] = ["gear-tech", "gear"]; @@ -27,7 +31,7 @@ const [owner, repo] = ["gear-tech", "gear"]; async function mock(head_sha) { const token = core.getInput("token"); const octokit = github.getOctokit(token); - for (check of CHECKS) { + for (const check of CHECKS) { const { data: res } = await octokit.rest.checks.create({ owner, repo, @@ -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,8 +71,10 @@ async function main() { // Calculate configurations. const isDepbot = fullName === `${owner}/${repo}` && title.includes(DEPBOT); - const skipCI = [title, message].some(s => s.includes(SKIP_CI)); - const build = !skipCI && (isDepbot || BUILD_LABELS.some(label => labels.includes(label))); + const skipCI = [title, message].some((s) => s.includes(SKIP_CI)); + const build = + !skipCI && + (isDepbot || BUILD_LABELS.some((label) => labels.includes(label))); const win_native = !skipCI && labels.includes(WINDOWS_NATIVE); const macos = !skipCI && labels.includes(MACOS); const release = !skipCI && labels.includes(RELEASE); @@ -85,7 +97,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 06d668a06ec..bfef347cd75 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -2,7 +2,7 @@ name: PR on: pull_request: - branches: [ master ] + branches: [master] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -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: @@ -38,6 +45,16 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + docs: + runs-on: ubuntu-latest + env: + RUSTUP_HOME: /tmp/rustup_home + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/docs + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + check: needs: status if: ${{ needs.status.outputs.check == 'true' }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1271af50f00..f6cb99c7b6a 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,5 @@ 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 diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml deleted file mode 100644 index bb20e38458e..00000000000 --- a/.github/workflows/typos.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Typos - -on: - pull_request: - branches: [ master ] - -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