Skip to content

Commit

Permalink
ci: rework ci, add deny warnings in lint
Browse files Browse the repository at this point in the history
  • Loading branch information
7sDream committed May 8, 2024
1 parent cbf4383 commit dd222d4
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 80 deletions.
34 changes: 7 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions .github/workflows/common/audit.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:
strategy:
fail-fast: false
fail-fast: true
matrix:
include:
- os: windows-latest
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/common/depver.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions .github/workflows/common/lint.yaml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 5 additions & 31 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 8 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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*
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
profile = "default"

0 comments on commit dd222d4

Please sign in to comment.