mirror of
https://github.com/imjasonh/krust
synced 2026-07-08 06:45:32 +00:00
- Add comprehensive e2e tests for build functionality - Add integration job to CI that tests `docker run $(krust build)` - Test KRUST_REPO environment variable usage - Test --no-push flag and clean stdout for command substitution - Add tests for verbose logging - Remove outdated basic_test.rs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
121 lines
3.3 KiB
YAML
121 lines
3.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
rust: [stable, beta]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Cache cargo index
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Cache cargo build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
- name: Run unit tests
|
|
run: cargo test --verbose
|
|
- name: Run e2e tests
|
|
run: cargo test --test '*' --verbose
|
|
|
|
fmt:
|
|
name: Rustfmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt
|
|
- name: Check formatting
|
|
run: cargo fmt -- --check
|
|
|
|
clippy:
|
|
name: Clippy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy
|
|
- name: Run clippy
|
|
run: cargo clippy -- -D warnings
|
|
|
|
integration:
|
|
name: Integration Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-unknown-linux-musl
|
|
- name: Install musl tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y musl-tools
|
|
- name: Build krust
|
|
run: cargo build --release
|
|
- name: Add krust to PATH
|
|
run: echo "${{ github.workspace }}/target/release" >> $GITHUB_PATH
|
|
- name: Test krust version
|
|
run: krust version
|
|
- name: Build and run example with krust
|
|
run: |
|
|
cd example/hello-krust
|
|
# Build and push to ttl.sh (ephemeral registry)
|
|
export KRUST_REPO=ttl.sh/${{ github.run_id }}
|
|
IMAGE_REF=$(krust build ./)
|
|
echo "Built image: $IMAGE_REF"
|
|
# Run the image
|
|
docker run --rm $IMAGE_REF
|
|
- name: Test docker run with command substitution
|
|
run: |
|
|
cd example/hello-krust
|
|
export KRUST_REPO=ttl.sh/${{ github.run_id }}-test2
|
|
docker run --rm $(krust build ./)
|
|
- name: Test build with --no-push
|
|
run: |
|
|
cd example/hello-krust
|
|
krust build --no-push --image local.test/hello:latest ./
|
|
|
|
# Takes too long to run on CI, so it's commented out for now.
|
|
# coverage:
|
|
# name: Code coverage
|
|
# runs-on: ubuntu-latest
|
|
# steps:
|
|
# - uses: actions/checkout@v4
|
|
# - name: Install Rust
|
|
# uses: dtolnay/rust-toolchain@stable
|
|
# - name: Install cargo-tarpaulin
|
|
# run: cargo install cargo-tarpaulin
|
|
# - name: Generate code coverage
|
|
# run: cargo tarpaulin --verbose --workspace
|