Add test step to CI and fix test #113
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: CI | |
on: | |
push: | |
branches: [ "main" ] | |
tags: [ "*" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
formatting: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- run: cargo fmt --check | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install native system dependencies | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev | |
if: runner.os == 'linux' | |
- uses: r7kamura/rust-problem-matchers@v1 | |
- run: cargo clippy -- -D warnings | |
test: | |
strategy: | |
matrix: | |
# TODO: [ubuntu-latest, macos-latest, windows-latest] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install native system dependencies | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev | |
if: runner.os == 'linux' | |
- uses: r7kamura/rust-problem-matchers@v1 | |
- run: cargo test --workspace | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: spacestationnt/ssnt | |
- name: Login to Docker Hub | |
if: ${{ github.event_name == 'push' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: ${{ github.event_name == 'push' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
# cache strategy: | |
# merges (main branch) read and write from docker hub `cache` tag. | |
# PRs read from both docker hub and github caches. docker hub for initial compilation and github | |
# for consecutive builds | |
cache-from: | | |
${{ github.event_name != 'push' && 'type=gha' || '' }} | |
spacestationnt/ssnt:cache | |
cache-to: | | |
${{ github.event_name != 'push' && 'type=gha,mode=max' || '' }} | |
${{ github.event_name == 'push' && 'type=registry,ref=spacestationnt/ssnt:cache,mode=max' || '' }} |