From 151ca29a0982c2f080cf132213ef070d3dfd5b36 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Wed, 31 May 2023 11:24:31 -0700 Subject: [PATCH] Update the CI workflow --- .github/actions/setup-arm/action.yml | 70 +++++++++++++ .github/workflows/ci.yml | 120 +++++++++++++++++++++++ .github/workflows/raspberry_ci.yml | 141 +++++++++++++++++++++++++++ .github/workflows/raspberry_rust.yml | 89 ----------------- .github/workflows/rust.yml | 106 -------------------- README.md | 2 +- 6 files changed, 332 insertions(+), 196 deletions(-) create mode 100644 .github/actions/setup-arm/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/raspberry_ci.yml delete mode 100644 .github/workflows/raspberry_rust.yml delete mode 100644 .github/workflows/rust.yml diff --git a/.github/actions/setup-arm/action.yml b/.github/actions/setup-arm/action.yml new file mode 100644 index 0000000..f3ff7cb --- /dev/null +++ b/.github/actions/setup-arm/action.yml @@ -0,0 +1,70 @@ +name: Setup ARM Build Environment +description: Setup an ARM build environment + +inputs: + arch: + required: true + target: + required: true + toolchain: + default: stable + required: false + components: + required: false + +runs: + using: composite + steps: + - name: Replace target string + uses: mad9000/actions-find-and-replace-string@3 + id: findandreplace + with: + source: ${{ inputs.target }} + find: "unknown-" + replace: "" + + - name: Install toolchain + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ inputs.toolchain }} + target: ${{ inputs.target }} + components: ${{ inputs.components }} + + - uses: Swatinem/rust-cache@v2 + + - name: Install Cross-Compile Support + uses: cyberjunk/gha-ubuntu-cross@v3 + with: + arch: ${{ inputs.arch }} + + - name: Install dependencies + shell: bash + run: | + sudo apt install -y \ + curl \ + gcc-aarch64-linux-gnu \ + gcc-arm-linux-gnueabihf \ + git \ + "libc6:${{ inputs.arch }}" \ + "libgcc-s1:${{ inputs.arch }}" \ + libudev-dev \ + "libudev-dev:${{ inputs.arch }}" \ + "libudev1:${{ inputs.arch }}" \ + musl-tools \ + pkg-config + + - name: Set environment variables + shell: bash + run: | + echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV + echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV + echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV + if [[ ${{ inputs.arch }} == arm64 ]]; then + echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV + fi + if [[ ${{ inputs.arch }} == armhf ]]; then + echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV + echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8059a87 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,120 @@ +name: CI + +on: + pull_request: + branches: + - main + push: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +# Cancel any currently running workflows from the same PR, branch, or +# tag when a new workflow is triggered. +# +# https://stackoverflow.com/a/66336834 +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + +jobs: + # -------------------------------------------------------------------------- + # Check + + check: + name: Check + strategy: + matrix: + os: ["macos-12", "ubuntu-22.04", "windows-2022"] + runs-on: ${{ matrix.os }} + + steps: + - name: Install dependencies + if: matrix.os == 'ubuntu-22.04' + run: sudo apt-get install musl-tools libudev-dev + + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + + - run: cargo check + + check-lib: + name: Check (lib) + runs-on: ubuntu-22.04 + + steps: + - name: Install dependencies + run: sudo apt-get install musl-tools libudev-dev + + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + + - run: cargo check --lib --no-default-features + + msrv: + name: Check MSRV + runs-on: ubuntu-22.04 + + steps: + - name: Install dependencies + run: sudo apt-get install musl-tools libudev-dev + + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@v1 + with: + toolchain: "1.65" + - uses: Swatinem/rust-cache@v2 + + - run: cargo check + + # -------------------------------------------------------------------------- + # Test + + test: + name: Unit Tests + runs-on: ubuntu-22.04 + + steps: + - name: Install dependencies + run: sudo apt-get install musl-tools libudev-dev + + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + + - run: cargo test --lib + + # -------------------------------------------------------------------------- + # Lint + + clippy: + name: Clippy + runs-on: ubuntu-22.04 + + steps: + - name: Install dependencies + run: sudo apt-get install musl-tools libudev-dev + + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + + - run: cargo clippy -- -D warnings -A clippy::too_many_arguments + + rustfmt: + name: Rustfmt + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - uses: Swatinem/rust-cache@v2 + + - run: cargo fmt --all -- --check diff --git a/.github/workflows/raspberry_ci.yml b/.github/workflows/raspberry_ci.yml new file mode 100644 index 0000000..6bc1031 --- /dev/null +++ b/.github/workflows/raspberry_ci.yml @@ -0,0 +1,141 @@ +name: Raspberry Pi CI + +on: + pull_request: + branches: + - main + push: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +# Cancel any currently running workflows from the same PR, branch, or +# tag when a new workflow is triggered. +# +# https://stackoverflow.com/a/66336834 +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + +jobs: + # -------------------------------------------------------------------------- + # Check + + check: + name: Check + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + board: + - arch: arm64 + target: aarch64-unknown-linux-gnu + - arch: armhf + target: armv7-unknown-linux-gnueabihf + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-arm + with: + arch: ${{ matrix.board.arch }} + target: ${{ matrix.board.target }} + + - run: cargo check --features=raspberry + + check-lib: + name: Check (lib) + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + board: + - arch: arm64 + target: aarch64-unknown-linux-gnu + - arch: armhf + target: armv7-unknown-linux-gnueabihf + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-arm + with: + arch: ${{ matrix.board.arch }} + target: ${{ matrix.board.target }} + + - run: cargo check --lib --no-default-features --features=raspberry + + msrv: + name: Check MSRV + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + board: + - arch: arm64 + target: aarch64-unknown-linux-gnu + - arch: armhf + target: armv7-unknown-linux-gnueabihf + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-arm + with: + arch: ${{ matrix.board.arch }} + target: ${{ matrix.board.target }} + toolchain: "1.65" + + - run: cargo check --features=raspberry + + # -------------------------------------------------------------------------- + # Test + + test: + name: Unit Tests + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + board: + - arch: arm64 + target: aarch64-unknown-linux-gnu + - arch: armhf + target: armv7-unknown-linux-gnueabihf + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-arm + with: + arch: ${{ matrix.board.arch }} + target: ${{ matrix.board.target }} + + - run: cargo test --lib --features=raspberry + + # -------------------------------------------------------------------------- + # Lint + + clippy: + name: Clippy + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + board: + - arch: arm64 + target: aarch64-unknown-linux-gnu + - arch: armhf + target: armv7-unknown-linux-gnueabihf + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-arm + with: + arch: ${{ matrix.board.arch }} + target: ${{ matrix.board.target }} + components: clippy + + - run: cargo clippy --features=raspberry -- -D warnings -A clippy::too_many_arguments diff --git a/.github/workflows/raspberry_rust.yml b/.github/workflows/raspberry_rust.yml deleted file mode 100644 index d2851b3..0000000 --- a/.github/workflows/raspberry_rust.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Rasberry Pi CI - -on: - pull_request: - branches: - - main - push: - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - rust-ci: - name: "Rust CI: ${{ matrix.job.name }} - ${{ matrix.board.target }}" - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - board: - - target: armv7-unknown-linux-gnueabihf - arch: armhf - - target: aarch64-unknown-linux-gnu - arch: arm64 - job: - - name: Check - toolchain: stable - cargo-command: check - args: --features=raspberry - - name: Check (lib) - toolchain: stable - cargo-command: check - args: --lib --no-default-features --features=raspberry - - name: Check MSRV - toolchain: "1.65" - cargo-command: check - args: --features=raspberry - - name: Unit Test - toolchain: stable - cargo-command: test - args: --lib --features=raspberry - - name: Rustfmt - toolchain: stable - components: rustfmt - cargo-command: fmt - args: --all -- --check - - name: Clippy - toolchain: stable - components: clippy - cargo-command: clippy - args: --features=raspberry -- -D warnings -A clippy::too_many_arguments - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ matrix.job.toolchain }} - target: ${{ matrix.board.target }} - components: ${{ matrix.job.components }} - - uses: Swatinem/rust-cache@v2 - - name: Replace target string - uses: mad9000/actions-find-and-replace-string@3 - id: findandreplace - with: - source: ${{ matrix.board.target }} - find: "unknown-" - replace: "" - - name: Build dependencies - if: matrix.job.cargo-command != 'fmt' - run: | - sudo sed -i 's/azure\.//' /etc/apt/sources.list - sudo apt-get update - echo "deb [arch=${{ matrix.board.arch }}] http://ports.ubuntu.com/ubuntu-ports focal main universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=${{ matrix.board.arch }}] http://ports.ubuntu.com/ubuntu-ports focal-updates main universe" | sudo tee -a /etc/apt/sources.list - sudo apt update - sudo dpkg --add-architecture ${{ matrix.board.arch }} - sudo apt-get install -y curl git libudev-dev musl-tools pkg-config "libudev1:${{ matrix.board.arch }}" "libgcc-s1:${{ matrix.board.arch }}" "libc6:${{ matrix.board.arch }}" "libudev-dev:${{ matrix.board.arch }}" gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf gcc-aarch64-linux-gnu pkg-config-aarch64-linux-gnu - echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV - echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV - echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV - echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV - if [[ ${{ matrix.board.arch }} == arm64 ]]; then - echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV - fi - if [[ ${{ matrix.board.arch }} == armhf ]]; then - echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV - echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV - fi - - run: cargo ${{ matrix.job.cargo-command }} ${{ matrix.job.args }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 9b7482a..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: CI - -on: - pull_request: - branches: - - main - push: - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - check: - name: Check - runs-on: ubuntu-20.04 - steps: - - name: Change apt mirror and install dependencies - run: | - sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list - sudo apt-get update - sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - - uses: Swatinem/rust-cache@v2 - - run: cargo check - - check-lib: - name: Check (lib) - runs-on: ubuntu-20.04 - steps: - - name: Change apt mirror and install dependencies - run: | - sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list - sudo apt-get update - sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - - uses: Swatinem/rust-cache@v2 - - run: cargo check --lib --no-default-features - - msrv: - name: Check MSRV - runs-on: ubuntu-20.04 - steps: - - name: Change apt mirror and install dependencies - run: | - sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list - sudo apt-get update - sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: "1.65" - - uses: Swatinem/rust-cache@v2 - - run: cargo check - - test-lib: - name: Unit Test - runs-on: ubuntu-20.04 - steps: - - name: Change apt mirror and install dependencies - run: | - sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list - sudo apt-get update - sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - - uses: Swatinem/rust-cache@v2 - - run: cargo test --lib - - fmt: - name: Rustfmt - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - components: rustfmt - - uses: Swatinem/rust-cache@v2 - - run: cargo fmt --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-20.04 - steps: - - name: Change apt mirror and install dependencies - run: | - sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list - sudo apt-get update - sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - components: clippy - - uses: Swatinem/rust-cache@v2 - # `too_many_arguments` is relatively arbitrary - - run: cargo clippy -- -A clippy::too_many_arguments -D warnings diff --git a/README.md b/README.md index 8d34990..fe037ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # espflash -![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&labelColor=1C2C2E&logo=github&style=flat-square) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/ci.yml?branch=main&labelColor=1C2C2E&logo=github&style=flat-square) ![Crates.io](https://img.shields.io/crates/l/espflash?labelColor=1C2C2E&style=flat-square) [![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&color=BEC5C9&labelColor=1C2C2E&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)