From dd222d4ec0c0a948cdf8015f8cd8d12f1c8dd073 Mon Sep 17 00:00:00 2001 From: 7sDream Date: Thu, 9 May 2024 06:52:04 +0800 Subject: [PATCH] ci: rework ci, add deny warnings in lint --- .github/workflows/ci.yml | 34 +++++----------------- .github/workflows/common/audit.yml | 16 +++++++++++ .github/workflows/{ => common}/build.yml | 10 +++---- .github/workflows/common/depver.yml | 26 +++++++++++++++++ .github/workflows/common/lint.yaml | 27 ++++++++++++++++++ .github/workflows/daily.yml | 36 ++++-------------------- .github/workflows/release.yml | 25 ++++++---------- rust-toolchain.toml | 3 ++ 8 files changed, 97 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/common/audit.yml rename .github/workflows/{ => common}/build.yml (96%) create mode 100644 .github/workflows/common/depver.yml create mode 100644 .github/workflows/common/lint.yaml create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b8789b..8f1a985 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,37 +8,17 @@ on: branches: - master workflow_dispatch: - workflow_call: jobs: - style: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + depver: + if: "contains(github.event.head_commit.message, '(release)')" + uses: ./.github/workflows/common/depver.yml - - name: Install Rust nightly toolchains - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - name: Check code style - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - - name: Install Rust stable toolchains - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - name: Lint code by clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-targets --all-features -- -D warnings' + daily: + uses: ./.github/workflows/common/daily.yaml build: - uses: ./.github/workflows/build.yml - needs: [style] + uses: ./.github/workflows/common/build.yml + needs: [daily] with: name: fontfor diff --git a/.github/workflows/common/audit.yml b/.github/workflows/common/audit.yml new file mode 100644 index 0000000..7abd902 --- /dev/null +++ b/.github/workflows/common/audit.yml @@ -0,0 +1,16 @@ +name: Audit + +on: + workflow_dispatch: + workflow_call: + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Security audit + uses: rustsec/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/common/build.yml similarity index 96% rename from .github/workflows/build.yml rename to .github/workflows/common/build.yml index 8c0c891..98d434a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/common/build.yml @@ -11,7 +11,7 @@ on: jobs: build: strategy: - fail-fast: false + fail-fast: true matrix: include: - os: windows-latest @@ -64,7 +64,7 @@ jobs: platform: darwin arch: x64 libc: system - - os: macos-11 + - os: macos-12 rust-target: aarch64-apple-darwin platform: darwin arch: arm64 @@ -75,9 +75,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Install Rust toolchains - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.rust-target }} + run: | + rustup toolchain install stable --profile default -t ${{ matrix.rust-target }} + rustup show - name: Install AArch64 target toolchain if: matrix.platform == 'linux' && matrix.arch == 'arm64' run: | diff --git a/.github/workflows/common/depver.yml b/.github/workflows/common/depver.yml new file mode 100644 index 0000000..e49b254 --- /dev/null +++ b/.github/workflows/common/depver.yml @@ -0,0 +1,26 @@ +name: Dependencies version + +on: + workflow_dispatch: + workflow_call: + +jobs: + deps_version: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Rust toolchain + run: | + rustup install stable --profile default + rustup show + - name: Install cargo-outdated + uses: taiki-e/install-action@v2 + with: + tool: cargo-outdated + - name: Check deps crates version + run: | + cargo outdated -R --exit-code 1 --verbose diff --git a/.github/workflows/common/lint.yaml b/.github/workflows/common/lint.yaml new file mode 100644 index 0000000..ac63777 --- /dev/null +++ b/.github/workflows/common/lint.yaml @@ -0,0 +1,27 @@ +name: Lint + +on: + workflow_dispatch: + workflow_call: + +jobs: + lint: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Rust toolchain + run: | + rustup install stable --profile default + rustup install nightly --profile default + rustup show + - name: Check code style + run: | + cargo +nightly fmt --all -- --check + - name: Lint code by clippy + uses: clechasseur/rs-clippy-check@v3 + with: + args: --all-targets --all-features -- -D warnings diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index f30fa6d..63fd4db 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -2,39 +2,13 @@ name: Daily check on: schedule: - - cron: '0 23 * * *' # CST 7:00 = UTC prev day 23:00 + - cron: "0 23 * * *" # CST 7:00 = UTC prev day 23:00 workflow_dispatch: workflow_call: jobs: - deps_version: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + lint: + uses: ./.github/workflows/common/lint.yml - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Install cargo-outdated - uses: actions-rs/install@v0.1 - with: - crate: cargo-outdated - version: latest - use-tool-cache: true - - - name: Check deps crates version - uses: actions-rs/cargo@v1 - with: - command: outdated - args: -R --exit-code 1 --verbose - - security_audit: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Security audit - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + audit: + uses: ./.github/workflows/common/audit.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ceaff1c..48d68e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,35 +7,26 @@ on: - "v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]*" jobs: - daily: - uses: ./.github/workflows/daily.yml - - ci: - needs: [daily] - uses: ./.github/workflows/ci.yml + build: + uses: ./.github/workflows/common/build.yml + with: + name: fontfor release: - needs: [ci] + needs: [build] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - # Multi line outputs needs escaped before echo, ref: - # https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870 - - name: Get message + - name: Generate release note id: tag - run: | - message=$(echo "${{ github.event.head_commit.message }}" | tail -n +3) - message="${message//'%'/'%25'}" - message="${message//$'\n'/'%0A'}" - message="${message//$'\r'/'%0D'}" - echo "::set-output name=message::$message" + uses: ffurrer2/extract-release-notes@v2 - name: Download Linux binary from artifact uses: actions/download-artifact@v3 - name: Release uses: softprops/action-gh-release@v1 with: - body: ${{ steps.tag.outputs.message }} + body: ${{ steps.tag.outputs.release_notes }} draft: false prerelease: false files: fontfor-*/fontfor* diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..02cb8fc --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +profile = "default"