Skip to content

Commit

Permalink
Add dependencies for workflows (#8)
Browse files Browse the repository at this point in the history
* Add dependencies for code quality checks

- Removed any build steps since it's not needed for code quality checks.
- Added the installation of build tools and ALSA dependencies for Clippy.

* Ensure 'Check on Rust beta and dependency health' workflow builds and cross-compiles for all targets

- Correctly included cross-compilation steps with cargo build specifying the target.
- Ensured that all specified targets (Linux, macOS, Windows) are handled properly.
- Added necessary build tools and C compilers for each OS.

* Ensure build dependencies

- Ensured cross-compilation targets for Linux, macOS, and Windows.
- Included installation of necessary C compilers and build tools.

* Fix cross-compilation matrix in 'Cross-compilation on Rust stable' workflow

- Corrected matrix configuration to ensure valid OS and target combinations.
- Excluded invalid target-OS pairs (e.g., macOS with ARM targets).
- Verified that only compatible combinations are used for cross-compilation.

* Fix periodic workflow for valid OS-target combinations

- Corrected cross-compilation matrix to ensure valid OS-target combinations.
  • Loading branch information
roderickvd authored Aug 13, 2024
1 parent 4f8b0d2 commit 6b1a94c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install build tools and ALSA dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential libasound2-dev pkg-config;
- name: Install Rust stable
run: rustup install stable

Expand Down
69 changes: 41 additions & 28 deletions .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,58 @@ on:
- '**/docs/**'

jobs:
build:
cross-compile:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, x86_64-apple-darwin, x86_64-pc-windows-msvc]
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4

- name: Cache Cargo registry on ${{ matrix.os }} (${{ matrix.target }})
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build on ${{ matrix.os }} (${{ matrix.target }})
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ matrix.target }}
- name: Install build tools and ALSA dependencies (Linux only)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update && sudo apt-get install -y build-essential libasound2-dev pkg-config;
- name: Install Rust stable on ${{ matrix.os }}
run: rustup install stable
- name: Install C compiler (macOS)
if: matrix.os == 'macos-latest'
run: |
xcode-select --install || echo "Xcode already installed";
- name: Install Visual Studio Build Tools (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install visualstudio2022-workload-vctools --yes
- name: Add cross-compilation target ${{ matrix.target }} on ${{ matrix.os }}
run: rustup target add ${{ matrix.target }}
- name: Install Rust stable
run: rustup install stable

- name: Build ${{ matrix.target }} on ${{ matrix.os }}
run: cargo build --verbose --target ${{ matrix.target }}
- name: Cross-compile for ${{ matrix.target }} on Rust stable
run: |
rustup target add ${{ matrix.target }}
cargo build --release --verbose --target ${{ matrix.target }}
- name: Upload binaries for ${{ matrix.target }} on ${{ matrix.os }}
- name: Upload compiled binaries
uses: actions/upload-artifact@v3
with:
name: my-binary-${{ matrix.target }}-stable
path: target/${{ matrix.target }}/debug/
name: binaries-${{ matrix.target }}
path: target/${{ matrix.target }}/release/
83 changes: 47 additions & 36 deletions .github/workflows/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,67 @@ name: Check on Rust beta and dependency health
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight
workflow_dispatch:

jobs:
security-audit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust stable for security audit
run: rustup install stable

- name: Run security audit
run: cargo install cargo-audit && cargo audit
maintenance:
runs-on: ${{ matrix.os }}

unused-dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4

- name: Install Rust nightly and udeps for unused dependency check
- name: Install build tools and ALSA dependencies (Linux only)
if: matrix.os == 'ubuntu-latest'
run: |
rustup install nightly
rustup component add rustc-dev llvm-tools-preview --toolchain nightly
cargo +nightly install cargo-udeps
- name: Check for unused dependencies
run: cargo +nightly udeps --all-targets
sudo apt-get update && sudo apt-get install -y build-essential libasound2-dev pkg-config;
beta-cross-compilation:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, x86_64-apple-darwin, x86_64-pc-windows-msvc]
- name: Install C compiler (macOS)
if: matrix.os == 'macos-latest'
run: |
xcode-select --install || echo "Xcode already installed";
steps:
- uses: actions/checkout@v4
- name: Install Visual Studio Build Tools (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install visualstudio2022-workload-vctools --yes
- name: Install Rust beta on ${{ matrix.os }}
- name: Install Rust beta
run: rustup install beta

- name: Add cross-compilation target ${{ matrix.target }} on ${{ matrix.os }}
run: rustup target add ${{ matrix.target }}
- name: Security audit
run: cargo audit

- name: Build ${{ matrix.target }} on ${{ matrix.os }} (beta)
run: cargo build --verbose --target ${{ matrix.target }}
- name: Check for unused dependencies
run: cargo +nightly udeps

- name: Cross-compile for ${{ matrix.target }} on Rust beta
run: |
rustup target add ${{ matrix.target }}
cargo build --release --verbose --target ${{ matrix.target }}
- name: Upload binaries for ${{ matrix.target }} on ${{ matrix.os }} (beta)
- name: Upload compiled binaries
uses: actions/upload-artifact@v3
with:
name: my-binary-${{ matrix.target }}-beta
path: target/${{ matrix.target }}/debug/
name: binaries-${{ matrix.target }}
path: target/${{ matrix.target }}/release/

0 comments on commit 6b1a94c

Please sign in to comment.