Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional improvements to CI workflow #750

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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