diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e0..b837f62 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rust +name: Rust CI on: push: @@ -8,15 +8,54 @@ on: env: CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 jobs: - build: - + test: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - 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 + 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" + # Optional: Add more smoke tests if needed