Skip to content

Commit

Permalink
Additional improvements to CI workflow (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham authored Feb 7, 2025
1 parent 258e46b commit c73ea4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 49 deletions.
28 changes: 15 additions & 13 deletions .github/actions/setup-target/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ description: Setup an ARM or x86_64 build environment

inputs:
arch:
required: true
default: x86_64
required: false
target:
required: true
default: x86_64-unknown-linux-gnu
required: false
toolchain:
default: stable
required: false
Expand All @@ -15,10 +17,10 @@ inputs:
runs:
using: composite
steps:
- name: Replace target string
if: inputs.arch != 'x86_64'
uses: mad9000/actions-find-and-replace-string@5
- if: inputs.arch != 'x86_64'
name: Replace target string
id: findandreplace
uses: mad9000/actions-find-and-replace-string@5
with:
source: ${{ inputs.target }}
find: "unknown-"
Expand All @@ -33,14 +35,14 @@ runs:

- uses: Swatinem/rust-cache@v2

- name: Install Cross-Compile Support
if: inputs.arch != 'x86_64'
- if: inputs.arch != 'x86_64'
name: Install Cross-Compile Support
uses: junelife/gha-ubuntu-cross@v6
with:
arch: ${{ inputs.arch }}

- name: Install dependencies (Raspberry Pi)
if: inputs.arch != 'x86_64'
- if: inputs.arch != 'x86_64'
name: Install dependencies (Raspberry Pi)
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y \
Expand All @@ -53,14 +55,14 @@ runs:
musl-tools \
pkg-config
- name: Install dependencies (x86_64 linux)
if: inputs.target == 'x86_64-unknown-linux-gnu' || inputs.target == 'x86_64-unknown-linux-musl'
- if: inputs.target == 'x86_64-unknown-linux-gnu' || inputs.target == 'x86_64-unknown-linux-musl'
name: Install dependencies (x86_64 linux)
shell: bash
run: |
sudo apt-get update && sudo apt-get -y install musl-tools pkg-config
- name: Set environment variables
if: inputs.arch != 'x86_64'
- if: inputs.arch != 'x86_64'
name: Set environment variables
shell: bash
run: |
echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV
Expand Down
45 changes: 9 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

env:
CARGO_TERM_COLOR: always
MSRV: "1.82"

# Cancel any currently running workflows from the same PR, branch, or
# tag when a new workflow is triggered.
Expand Down Expand Up @@ -59,10 +60,8 @@ jobs:
arch: ${{ matrix.platform.arch }}
target: ${{ matrix.platform.target }}

- run: cargo check

- run: cargo run --package=cargo-espflash -- espflash completions bash
- run: cargo run --package=espflash -- completions bash
- run: cargo run -p cargo-espflash -- espflash completions bash
- run: cargo run -p espflash -- completions bash

check-lib:
name: Check lib (${{ matrix.platform.target }})
Expand Down Expand Up @@ -112,64 +111,38 @@ jobs:
with:
arch: ${{ matrix.platform.arch }}
target: ${{ matrix.platform.target }}
toolchain: "1.82"
toolchain: ${{ env.MSRV }}

- run: cargo check -p espflash --lib

# --------------------------------------------------------------------------
# Test

test:
name: Unit Tests (${{ matrix.platform.target }})
strategy:
fail-fast: false
matrix:
platform:
- target: "x86_64-unknown-linux-gnu"
arch: "x86_64"
- target: "aarch64-unknown-linux-gnu"
arch: "arm64"
- target: "armv7-unknown-linux-gnueabihf"
arch: "armhf"
name: Unit Tests
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-target
with:
arch: ${{ matrix.platform.arch }}
target: ${{ matrix.platform.target }}

- run: cargo test --lib

# --------------------------------------------------------------------------
# Lint

clippy:
name: Clippy (${{ matrix.platform.target }})
strategy:
fail-fast: false
matrix:
platform:
- target: "x86_64-unknown-linux-gnu"
arch: "x86_64"
- target: "aarch64-unknown-linux-gnu"
arch: "arm64"
- target: "armv7-unknown-linux-gnueabihf"
arch: "armhf"
name: Clippy
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-target
- uses: dtolnay/rust-toolchain@stable
with:
arch: ${{ matrix.platform.arch }}
target: ${{ matrix.platform.target }}
components: clippy
- uses: Swatinem/rust-cache@v2

- run: cargo clippy -- -D warnings -A clippy::too_many_arguments
- run: cargo clippy -- -D warnings

rustfmt:
name: Rustfmt
Expand Down

0 comments on commit c73ea4d

Please sign in to comment.