name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 9 * * 1'
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: 🏗️ Setup build cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cache/repro-env/pkgs/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-
- name: 🛠️ Build
run: make
- name: 🔍 SHA256
run: sha256sum target/x86_64-unknown-linux-musl/release/repro-env
- name: 📦 Upload binary
uses: actions/upload-artifact@v3
with:
name: bin
path: target/x86_64-unknown-linux-musl/release/repro-env
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
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
integration-test:
needs: build
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
name: ${{ matrix.test.folder }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- 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-22.04
steps:
- uses: actions/checkout@v3
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
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
fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Run cargo fmt
run: cargo fmt --all -- --check
docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get install scdoc
- name: Build
run: make docs