Skip to content

Rust

Rust #197

Workflow file for this run

name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 9 * * 1'
env:
CARGO_TERM_COLOR: always
jobs:
build-bootstrapped:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: 🏗️ Setup build cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cache/repro-env/pkgs/
target/
key: ${{ runner.os }}-cargo-release-bootstrapped-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-bootstrapped-
- name: 🛠️ Build
run: make
- name: 🔍 SHA256
run: sha256sum target/x86_64-unknown-linux-musl/release/repro-env
- name: 📦 Upload binary
uses: actions/upload-artifact@v4
with:
name: bin
path: target/x86_64-unknown-linux-musl/release/repro-env
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-
- name: Build
run: cargo build --release --verbose
build-ubuntu:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install -y repro-env
- name: 🏗️ Setup build cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cache/repro-env/pkgs/
target/
key: ${{ runner.os }}-cargo-release-ubuntu-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-ubuntu-
- name: 🛠️ Build
run: repro-env build -- make build2
- name: 🔍 SHA256
run: sha256sum target/x86_64-unknown-linux-musl/release/repro-env
integration-test:
needs: build-bootstrapped
strategy:
fail-fast: false
matrix:
test:
- folder: examples/rust
cmd: cargo build --release
output: target/release/rust
sha256: ea8997342bef06680784c9ea6ef7e22f7ba089e98927e870905503d0bf39acb1
- folder: examples/golang
cmd: go build .
output: hello
sha256: dd41bdb93af4fb798f6b079368d6ee50a6907044c292ba6d2c98420ca8f012bf
- folder: examples/debian
cmd: gcc -static -o hello hello.c
output: hello
sha256: 2b24cfa838189c3aa6fa2440afe8508654830b6d3bad85d9b31958ae5c3fb429
- folder: examples/archlinux
cmd: gcc -static -o hello hello.c
output: hello
sha256: 04e03fd681793db603feb66a4c8e8df3858f1e31372dc017d7a0cf255faf84c5
#- folder: examples/alpine
# cmd: gcc -static -o hello hello.c
# output: hello
# sha256: a312585d54252990c2264351769f1cf2539f674db1142c7ea18fe10096debf12
name: ${{ matrix.test.folder }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: 🏗️ Setup build cache
uses: actions/cache@v4
with:
path: |
~/.cache/repro-env/pkgs/
key: repro-env-${{ matrix.test.folder }}
- name: 🛠️ Build artifact
run: chmod +x bin/repro-env && bin/repro-env -C ${{ matrix.test.folder }} build -- ${{ matrix.test.cmd }}
- name: 🔍 Verify artifact
run: cd ${{ matrix.test.folder }} && echo "${{ matrix.test.sha256 }} ${{ matrix.test.output }}" | sha256sum -c -
unit-test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug-
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test --verbose
deny:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run cargo deny
run: |
docker run --rm -v "$PWD:/src" -w /src alpine:edge sh -c '
set -e
apk add cargo-deny --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing/ || apk add cargo-deny --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community/ || apk add cargo-deny
apk add cargo
exec cargo deny check
'
fmt:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run cargo fmt
run: cargo fmt --all -- --check
docs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install scdoc
- name: Build
run: make docs