Skip to content

Commit

Permalink
Add raspberry feature checks in CI. (#255)
Browse files Browse the repository at this point in the history
* ci: ✨ Add Rasberry CI

* ci: 🐛 Fix typo

* ci: 🐛 Fix args order

* ci: 🐛 Fix args order

* chore: ⚡️ Split Raspberry CI into a file

* refactor: ♻️ Split Raspberry CI files into CI and Package

* ci: 🐛 Add features arg to clippy check

* ci: ⚡️ Remove fmt check
  • Loading branch information
SergioGasquez authored Oct 5, 2022
1 parent 046c467 commit 1367675
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 57 deletions.
53 changes: 1 addition & 52 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ on:
required: false
default: ""
type: string
arch:
required: false
default: ""
type: string

env:
CARGO_TERM_COLOR: always
Expand All @@ -28,77 +24,30 @@ jobs:
fail-fast: false
matrix:
crate: ["espflash", "cargo-espflash"]

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ inputs.target }}
override: true

- uses: Swatinem/rust-cache@v1

- name: Replace target string
if: inputs.arch != ''
uses: mad9000/actions-find-and-replace-string@1
id: findandreplace
with:
source: ${{ inputs.target }}
find: "unknown-"
replace: ""

- name: Build dependencies raspberry targets
if: inputs.runs_on == 'ubuntu-latest' && inputs.arch != ''
run: |
sudo sed -i 's/azure\.//' /etc/apt/sources.list
sudo apt-get update
echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal main universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{ inputs.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 ${{ inputs.arch }}
sudo apt-get install -y curl git libudev-dev musl-tools pkg-config "libudev1:${{ inputs.arch }}" "libgcc-s1:${{ inputs.arch }}" "libc6:${{ inputs.arch }}" "libudev-dev:${{ inputs.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 [[ ${{ 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
- name: Build dependencies for other ubuntu targets
if: inputs.runs_on == 'ubuntu-latest' && inputs.arch == ''
if: inputs.runs_on == 'ubuntu-latest'
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-rs/cargo@v1
if: ${{ inputs.arch == '' }}
with:
command: build
args: --release --all --target ${{ inputs.target }}

- uses: actions-rs/cargo@v1
if: ${{ inputs.arch != '' }}
with:
command: build
args: --release --all --target ${{ inputs.target }} --features=raspberry

- name: Compress (Unix)
if: ${{ inputs.runs_on != 'windows-latest' }}
run: zip -j ${{ matrix.crate }}-${{ inputs.target }}.zip target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }}

- name: Compress (Windows)
if: ${{ inputs.runs_on == 'windows-latest' }}
run: Compress-Archive target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }} ${{ matrix.crate }}-${{ inputs.target }}.zip

- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/raspberry_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Rasberry Pi Package

on:
workflow_call:
inputs:
target:
required: true
type: string
arch:
required: false
default: ""
type: string

env:
CARGO_TERM_COLOR: always

jobs:
publish-release:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
crate: ["espflash", "cargo-espflash"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ inputs.target }}
override: true
- uses: Swatinem/rust-cache@v1
- name: Replace target string
uses: mad9000/actions-find-and-replace-string@1
id: findandreplace
with:
source: ${{ inputs.target }}
find: "unknown-"
replace: ""
- name: Build dependencies
run: |
sudo sed -i 's/azure\.//' /etc/apt/sources.list
sudo apt-get update
echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal main universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{ inputs.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 ${{ inputs.arch }}
sudo apt-get install -y curl git libudev-dev musl-tools pkg-config "libudev1:${{ inputs.arch }}" "libgcc-s1:${{ inputs.arch }}" "libc6:${{ inputs.arch }}" "libudev-dev:${{ inputs.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 [[ ${{ 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
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all --target ${{ inputs.target }} --features=raspberry
- name: Compress
run: zip -j ${{ matrix.crate }}-${{ inputs.target }}.zip target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }}
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.crate }}-${{ inputs.target }}.zip
tag: ${{ github.ref }}
85 changes: 85 additions & 0 deletions .github/workflows/raspberry_rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Rasberry Pi CI

on:
pull_request:
branches:
- master
push:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
rust-ci:
name: "Rust CI: ${{ matrix.job.name }} - ${{ matrix.board.target }}"
runs-on: ubuntu-latest
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 MSRV
toolchain: "1.60"
cargo-command: check
args: --features=raspberry
- name: Unit Test
toolchain: stable
cargo-command: test
args: --lib --features=raspberry
- name: Clippy
toolchain: stable
components: clippy
cargo-command: clippy
args: --features=raspberry -- -A clippy::too_many_arguments
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.job.toolchain }}
target: ${{ matrix.board.target }}
components: ${{ matrix.job.components }}
override: true
- uses: Swatinem/rust-cache@v1
- name: Replace target string
uses: mad9000/actions-find-and-replace-string@1
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
- uses: actions-rs/cargo@v1
with:
command: ${{ matrix.job.cargo-command }}
args: ${{ matrix.job.args }}
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ jobs:
# Linux

armv7-unknown-linux-gnueabihf:
uses: ./.github/workflows/package.yml
uses: ./.github/workflows/raspberry_package.yml
with:
runs_on: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
arch: armhf

aarch64-unknown-linux-gnu:
uses: ./.github/workflows/package.yml
uses: ./.github/workflows/raspberry_package.yml
with:
runs_on: ubuntu-latest
target: aarch64-unknown-linux-gnu
arch: arm64

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: CI

on:
pull_request:
branches:
- master
push:
workflow_dispatch:

name: CI
env:
CARGO_TERM_COLOR: always

jobs:
check:
Expand Down

0 comments on commit 1367675

Please sign in to comment.