Cargo: Enforce navigator-rs version #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test all targets | |
on: [push, pull_request] | |
permissions: | |
contents: write | |
jobs: | |
quick-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- uses: actions-rs/[email protected] | |
with: | |
toolchain: stable | |
override: true | |
- name: Check Type | |
run: cargo fmt -- --check | |
- name: Check Clippy | |
run: cargo clippy | |
- name: Build | |
run: cargo build | |
build-bin: | |
needs: quick-tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- TARGET: armv7-unknown-linux-gnueabihf | |
- TARGET: aarch64-unknown-linux-gnu | |
- TARGET: armv7-unknown-linux-musleabihf | |
- TARGET: aarch64-unknown-linux-musl | |
steps: | |
- name: Building ${{ matrix.TARGET }} | |
run: echo "${{ matrix.TARGET }}" | |
- uses: actions/checkout@v3 | |
- name: Rust Setup | |
uses: actions-rs/[email protected] | |
with: | |
toolchain: stable | |
target: ${{ matrix.TARGET }} | |
override: true | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "rust-cache" | |
shared-key: "build-bin-${{ matrix.TARGET }}" | |
- name: Rust Cross Build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --verbose --release --target=${{ matrix.TARGET }} | |
- name: Move to it's target | |
run: | | |
mkdir dist | |
mkdir "dist/${{ matrix.TARGET }}" | |
mv $(find "./target" -type f -name "navigator-webassistant") "dist/${{ matrix.TARGET }}" | |
- name: Upload bin | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.TARGET }} | |
path: dist/${{ matrix.TARGET }} | |
- name: Upload bin | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bin | |
path: dist | |
test-local: | |
needs: build-bin | |
runs-on: raspbian-armv7-kernel-5.10.33 | |
steps: | |
- uses: actions/checkout@master | |
- name: Download bin | |
uses: actions/download-artifact@v3 | |
with: | |
name: armv7-unknown-linux-gnueabihf | |
path: dist | |
- name: Run in background | |
run: | | |
chmod +x ./dist/navigator-webassistant | |
./dist/navigator-webassistant > navigator.log 2>&1 & | |
PID=$! | |
sleep 10 | |
if ps -p $PID > /dev/null; then | |
echo "navigator-webassistant started successfully with PID $PID." | |
else | |
echo "Error: navigator-webassistant failed to start." | |
exit 1 | |
fi | |
kill $PID | |
release-assets: | |
needs: ["test-local"] | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags/')" | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- TARGET: armv7-unknown-linux-gnueabihf | |
- TARGET: aarch64-unknown-linux-gnu | |
- TARGET: armv7-unknown-linux-musleabihf | |
- TARGET: aarch64-unknown-linux-musl | |
steps: | |
- name: Download ${{ matrix.TARGET }} artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ matrix.TARGET }} | |
path: ${{ matrix.TARGET }} | |
- name: Compress Asset | |
run: | | |
sudo apt update | |
sudo apt install -y zip | |
cd ${{ matrix.TARGET }} | |
chmod +x ./navigator-webassistant | |
zip -rT ../${{ matrix.TARGET }}.zip * | |
- name: Upload assets to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ matrix.TARGET }}.zip | |
tag: ${{ github.ref }} | |
asset_name: ${{ matrix.TARGET }}.zip |