diff --git a/.github/actions/package-arm/action.yml b/.github/actions/package-arm/action.yml deleted file mode 100644 index 99ca2a9..0000000 --- a/.github/actions/package-arm/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Package Rasberry Pi Release - -inputs: - arch: - required: false - target: - required: true - github_token: - required: true - -runs: - using: composite - steps: - - uses: ./.github/actions/setup-arm - with: - arch: ${{ inputs.arch }} - target: ${{ inputs.target }} - - - name: Build - shell: bash - run: | - cargo build --release --all --target ${{ inputs.target }} --features=raspberry - - - name: Compress - shell: bash - run: | - zip -j cargo-espflash-${{ inputs.target }}.zip target/${{ inputs.target }}/release/cargo-espflash - zip -j espflash-${{ inputs.target }}.zip target/${{ inputs.target }}/release/espflash - - - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ inputs.github_token }} - file: "*.zip" - file_glob: true - tag: ${{ github.ref }} diff --git a/.github/actions/package/action.yml b/.github/actions/package/action.yml index 00bc5f3..241a804 100644 --- a/.github/actions/package/action.yml +++ b/.github/actions/package/action.yml @@ -1,32 +1,28 @@ name: Package Release - inputs: - runs_on: + arch: + required: false + github_token: required: true + features: + required: false target: required: true - github_token: + runs_on: required: true runs: using: composite steps: - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/setup-target with: + arch: ${{ inputs.arch }} target: ${{ inputs.target }} - - uses: Swatinem/rust-cache@v2 - - - name: Install dependencies - if: ${{ inputs.runs_on == 'ubuntu-22.04' }} - shell: bash - run: | - sudo apt-get install musl-tools libudev-dev - - name: Build shell: bash run: | - cargo build --release --all --target ${{ inputs.target }} + cargo build --release --all --target ${{ inputs.target }} ${{ inputs.features }} - name: Compress (Unix) if: ${{ inputs.runs_on != 'windows-2022' }} diff --git a/.github/actions/setup-arm/action.yml b/.github/actions/setup-target/action.yml similarity index 80% rename from .github/actions/setup-arm/action.yml rename to .github/actions/setup-target/action.yml index 671fa3d..92c4d1b 100644 --- a/.github/actions/setup-arm/action.yml +++ b/.github/actions/setup-target/action.yml @@ -1,5 +1,5 @@ -name: Setup ARM Build Environment -description: Setup an ARM build environment +name: Setup target Build Environment +description: Setup an ARM or x86_64 build environment inputs: arch: @@ -16,6 +16,7 @@ runs: using: composite steps: - name: Replace target string + if: inputs.arch != 'x86_64' uses: mad9000/actions-find-and-replace-string@3 id: findandreplace with: @@ -33,11 +34,13 @@ runs: - uses: Swatinem/rust-cache@v2 - name: Install Cross-Compile Support + if: inputs.arch != 'x86_64' uses: junelife/gha-ubuntu-cross@v6 with: arch: ${{ inputs.arch }} - - name: Install dependencies + - name: Install dependencies (Raspberry Pi) + if: inputs.arch != 'x86_64' shell: bash run: | sudo apt install -y \ @@ -53,7 +56,13 @@ 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' + shell: bash + run: sudo apt-get install musl-tools libudev-dev + - name: Set environment variables + if: inputs.arch != 'x86_64' shell: bash run: | echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd2cb0d..5b7c2a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,106 +23,166 @@ jobs: # Check check: - name: Check + name: Check (${{ matrix.platform.target }}) strategy: fail-fast: false matrix: platform: - os: "macos-12" target: "x86_64-apple-darwin" + arch: "x86_64" - os: "ubuntu-22.04" target: "x86_64-unknown-linux-gnu" + arch: "x86_64" - os: "ubuntu-22.04" target: "x86_64-unknown-linux-musl" + arch: "x86_64" - os: "windows-2022" target: "x86_64-pc-windows-msvc" + arch: "x86_64" + - os: "ubuntu-22.04" + target: "aarch64-unknown-linux-gnu" + arch: "arm64" + features: "--features=raspberry" + - os: "ubuntu-22.04" + target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" runs-on: ${{ matrix.platform.os }} steps: - - name: Install dependencies - if: matrix.platform.os == 'ubuntu-22.04' - run: sudo apt-get install musl-tools libudev-dev - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-target with: - targets: ${{ matrix.platform.target }} - - uses: Swatinem/rust-cache@v2 + arch: ${{ matrix.platform.arch }} + target: ${{ matrix.platform.target }} - - run: cargo check + - run: cargo check ${{ matrix.platform.features }} check-lib: - name: Check (lib) + name: Check lib (${{ 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" + features: "--features=raspberry" + - target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" 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 + - uses: actions/checkout@v4 - - run: cargo check --lib --no-default-features + - uses: ./.github/actions/setup-target + with: + arch: ${{ matrix.platform.arch }} + target: ${{ matrix.platform.target }} + + - run: cargo check --lib --no-default-features ${{ matrix.platform.features }} msrv: - name: Check MSRV + name: Check MSRV (${{ 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" + features: "--features=raspberry" + - target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" 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 + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-target with: + arch: ${{ matrix.platform.arch }} + target: ${{ matrix.platform.target }} toolchain: "1.65" - - uses: Swatinem/rust-cache@v2 - - run: cargo check + - run: cargo check ${{ matrix.platform.features }} # -------------------------------------------------------------------------- # Test test: - name: Unit Tests + 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" + features: "--features=raspberry" + - target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" 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 + - uses: actions/checkout@v4 - - run: cargo test --lib + - uses: ./.github/actions/setup-target + with: + arch: ${{ matrix.platform.arch }} + target: ${{ matrix.platform.target }} + + - run: cargo test --lib ${{ matrix.platform.features }} # -------------------------------------------------------------------------- # Lint clippy: - name: 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" + features: "--features=raspberry" + - target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" 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: actions/checkout@v4 + + - uses: ./.github/actions/setup-target 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 ${{ matrix.platform.features }} -- -D warnings -A clippy::too_many_arguments rustfmt: name: Rustfmt runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt diff --git a/.github/workflows/raspberry_ci.yml b/.github/workflows/raspberry_ci.yml deleted file mode 100644 index 6bc1031..0000000 --- a/.github/workflows/raspberry_ci.yml +++ /dev/null @@ -1,141 +0,0 @@ -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/release.yml b/.github/workflows/release.yml index abd15b4..301be25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,81 +8,48 @@ env: CARGO_TERM_COLOR: always jobs: - # -------------------------------------------------------------------------- - # Linux - - armv7-unknown-linux-gnueabihf: - runs-on: ubuntu-22.04 + release: + name: ${{ matrix.platform.target }} + strategy: + fail-fast: false + matrix: + platform: + # Linux + - os: "ubuntu-22.04" + target: "x86_64-unknown-linux-gnu" + arch: "x86_64" + - os: "ubuntu-22.04" + target: "x86_64-unknown-linux-musl" + arch: "x86_64" + - os: "ubuntu-22.04" + target: "aarch64-unknown-linux-gnu" + arch: "arm64" + features: "--features=raspberry" + - os: "ubuntu-22.04" + target: "armv7-unknown-linux-gnueabihf" + arch: "armhf" + features: "--features=raspberry" + # Windows + - os: "windows-2022" + target: "x86_64-pc-windows-msvc" + arch: "x86_64" + # macOs + - os: "macos-12" + target: "aarch64-apple-darwin" + # This is not true, but simplifies the logic of the action. + arch: "x86_64" + - os: "macos-12" + target: "x86_64-apple-darwin" + arch: "x86_64" + runs-on: ${{ matrix.platform.os }} steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package-arm - with: - arch: armhf - target: armv7-unknown-linux-gnueabihf - github_token: ${{ secrets.GITHUB_TOKEN }} - aarch64-unknown-linux-gnu: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package-arm - with: - arch: arm64 - target: aarch64-unknown-linux-gnu - github_token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v4 - x86_64-unknown-linux-gnu: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - uses: ./.github/actions/package with: - runs_on: ubuntu-22.04 - target: x86_64-unknown-linux-gnu - github_token: ${{ secrets.GITHUB_TOKEN }} - - x86_64-unknown-linux-musl: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package - with: - runs_on: ubuntu-22.04 - target: x86_64-unknown-linux-musl - github_token: ${{ secrets.GITHUB_TOKEN }} - - # -------------------------------------------------------------------------- - # macOS - - aarch64-apple-darwin: - runs-on: macos-12 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package - with: - runs_on: macos-12 - target: aarch64-apple-darwin - github_token: ${{ secrets.GITHUB_TOKEN }} - - x86_64-apple-darwin: - runs-on: macos-12 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package - with: - runs_on: macos-12 - target: x86_64-apple-darwin - github_token: ${{ secrets.GITHUB_TOKEN }} - - # -------------------------------------------------------------------------- - # Windows - - x86_64-pc-windows-msvc: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/package - with: - runs_on: windows-2022 - target: x86_64-pc-windows-msvc + arch: ${{ matrix.platform.arch }} github_token: ${{ secrets.GITHUB_TOKEN }} + features: ${{ matrix.platform.features }} + target: ${{ matrix.platform.target }} + runs_on: ${{ matrix.platform.os }}