Skip to content

Commit

Permalink
Merge pull request #79 from saying121/ci
Browse files Browse the repository at this point in the history
Split the original workflow into multiple
  • Loading branch information
Thaumy authored Nov 27, 2024
2 parents 3c8621d + 878378d commit 5bc15c0
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 361 deletions.
15 changes: 15 additions & 0 deletions .github/actions/audit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Audit
description: Check the code with audit

runs:
using: composite
steps:
- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-audit

- name: Audit
shell: bash
run: |
cargo audit
19 changes: 0 additions & 19 deletions .github/actions/check/action.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .github/actions/clippy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Clippy
description: Check the code with clippy
runs:
using: composite
steps:
- name: Clippy
shell: bash
run: cargo clippy --locked --all-targets -- -D warnings
6 changes: 0 additions & 6 deletions .github/actions/make-archive/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ runs:
shell: bash
run: |
zip ${{ inputs.out }} ${{ inputs.files }} -j
- name: Archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive ${{ inputs.files }} ${{ inputs.out }}
9 changes: 9 additions & 0 deletions .github/actions/rustfmt/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Rustfmt
description: Check the code with rustfmt

runs:
using: composite
steps:
- name: Fmt
shell: bash
run: cargo fmt --check --all
13 changes: 13 additions & 0 deletions .github/actions/show-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Show env
description: Show action env

runs:
using: composite
steps:
- name: Show environment information
shell: bash
run: |
cargo -V
cargo fmt -- -V
rustc -V
uname -a
12 changes: 7 additions & 5 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Test
description: Run tests

runs:
using: composite
steps:
- name: Test dev
shell: bash
run: cargo test --verbose
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- name: Test release
- name: Test
shell: bash
run: cargo test --verbose --release
run: cargo nextest run --workspace
32 changes: 32 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Audit

on:
push:
pull_request:

jobs:
audit:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Show environment information
uses: ./.github/actions/show-env

- name: Run cargo-audit
uses: ./.github/actions/audit
49 changes: 49 additions & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check if Psh can build

on:
push:
pull_request:

env:
RUST_BACKTRACE: 1

jobs:
build:
name: Build Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
# we only need to support linux
os: [ubuntu-20.04, ubuntu-latest]
# TODO: do we want to support musl?
target: [x86_64-unknown-linux-gnu]
# make sure it runs on latest stable rust
toolchain: [stable]

env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

steps:
- uses: actions/checkout/@v4

- name: Install Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy

- name: Show environment information
uses: ./.github/actions/show-env

- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Build Psh
uses: ./.github/actions/build
with:
target: ${{ matrix.target }}
release: false
41 changes: 13 additions & 28 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ jobs:
# make sure it runs on latest stable
toolchain: [stable]

env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true

- name: Setup Rust toolchain
uses: hecrj/setup-rust-action@v2
- name: Install Toolchain
uses: dtolnay/rust-toolchain@master
with:
rust-version: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
components: rustfmt, clippy
toolchain: ${{ matrix.toolchain }}

- name: Install Protoc
uses: arduino/setup-protoc@v3
Expand All @@ -50,14 +52,8 @@ jobs:
# shell: bash
# run: sudo apt -y install musl-tools

- name: Setup protobuf
shell: bash
run: sudo apt -y install protobuf-compiler

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ matrix.os }}-${{ matrix.target }}-${{ matrix.toolchain }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Generate version
id: gen-version
Expand All @@ -69,31 +65,20 @@ jobs:
with:
version: ${{ steps.gen-version.outputs.VERSION }}

- name: Run check
uses: ./.github/actions/check

#- name: Run test
# uses: ./.github/actions/test

- name: Run build
- name: Build Psh
uses: ./.github/actions/build
with:
target: ${{ matrix.target }}
release: false

# - name: Generate artifacts name
# id: gen-name
# shell: bash
# run: echo 'NAME=psh-dev-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.toolchain }}' >> $GITHUB_OUTPUT

#- name: Generate binary extension
# id: gen-ext
# if: runner.os == 'Windows'
# shell: bash
# run: echo 'EXT=.exe' >> $GITHUB_OUTPUT

#- name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# name: ${{ steps.gen-name.outputs.NAME }}
#path: ./target/${{ matrix.target }}/debug/psh${{ steps.gen-ext.outputs.EXT }}
#path: ./target/${{ matrix.target }}/debug/psh
#if-no-files-found: error
24 changes: 8 additions & 16 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true

- name: Setup Rust toolchain
uses: hecrj/setup-rust-action@v2
- name: Install Toolchain
uses: dtolnay/rust-toolchain@master
with:
rust-version: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
components: rustfmt, clippy
toolchain: ${{ matrix.toolchain }}

- name: Install Protoc
uses: arduino/setup-protoc@v3
Expand Down Expand Up @@ -68,26 +66,20 @@ jobs:
shell: bash
run: echo 'NAME=psh-${{ steps.gen-version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.toolchain }}' >> $GITHUB_OUTPUT

- name: Generate binary extension
id: gen-ext
if: runner.os == 'Windows'
shell: bash
run: echo 'EXT=.exe' >> $GITHUB_OUTPUT

- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen-name.outputs.NAME }}
path: ./target/${{ matrix.target }}/release/psh${{ steps.gen-ext.outputs.EXT }}
path: ./target/${{ matrix.target }}/release/psh
if-no-files-found: error

- name: Archive binary
uses: ./.github/actions/make-archive
with:
files: ./target/${{ matrix.target }}/release/psh${{ steps.gen-ext.outputs.EXT }}
files: ./target/${{ matrix.target }}/release/psh
out: ${{ steps.gen-name.outputs.NAME }}.zip

- name: Create GitHub release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.gen-name.outputs.NAME }}.zip
43 changes: 43 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Clippy

on:
push:
pull_request:

env:
RUST_BACKTRACE: 1

jobs:
clippy:
name: Clippy rust
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# make sure it runs on latest stable rust
toolchain: [stable]

env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

steps:
- uses: actions/checkout/@v4

- name: Install Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy

- name: Show environment information
uses: ./.github/actions/show-env

- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Run clippy
uses: ./.github/actions/clippy
32 changes: 32 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Rustfmt

on:
push:
pull_request:

jobs:
rustfmt:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt

- name: Show environment information
uses: ./.github/actions/show-env

- name: Check fmt
uses: ./.github/actions/rustfmt
Loading

0 comments on commit 5bc15c0

Please sign in to comment.