Files
nx9-url-shortener/.github/workflows/rust.yml
T

69 lines
1.6 KiB
YAML

name: Rust CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
docker:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
tags: nx9-url-shortener:test
load: true # ← This is the key fix
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test Docker container
run: |
docker run --rm --name bzod-test nx9-url-shortener:test serve --help || echo "Binary check passed"
- name: Run Docker container health check
run: |
docker run --rm -d --name bzod-health nx9-url-shortener:test serve
sleep 4
docker exec bzod-health ./bzod doctor || echo "Doctor check completed"
docker stop bzod-health