ci: improve Rust workflow checks
This commit is contained in:
1 parent
7ee6ab2feb
commit
743502b183
1 file changed
+70
-64
+70
-64
@@ -1,79 +1,85 @@
|
|||||||
name: Rust CI
|
name: Rust CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: ["main"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: ["main"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
name: Test & Quality Checks
|
||||||
steps:
|
runs-on: ubuntu-latest
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
steps:
|
||||||
uses: dtolnay/rust-toolchain@stable
|
- name: Checkout Repository
|
||||||
with:
|
uses: actions/checkout@v4
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: Cache Cargo
|
- name: Install Rust Toolchain
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Cache Cargo Dependencies
|
||||||
run: cargo fmt -- --check
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Check Formatting
|
||||||
run: cargo clippy --all-targets -- -D warnings
|
run: cargo fmt --check
|
||||||
|
|
||||||
- name: Build
|
- name: Run Clippy
|
||||||
run: cargo build --verbose
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
- name: Run tests
|
- name: Build Release
|
||||||
run: cargo test --verbose
|
run: cargo build --release --verbose
|
||||||
|
|
||||||
docker:
|
- name: Run Tests
|
||||||
runs-on: ubuntu-latest
|
run: cargo test --all-features --verbose
|
||||||
needs: test
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write # Required for GHCR push
|
|
||||||
|
|
||||||
steps:
|
docker:
|
||||||
- uses: actions/checkout@v4
|
name: Build Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
permissions:
|
||||||
uses: docker/login-action@v3
|
contents: read
|
||||||
with:
|
packages: write
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels)
|
steps:
|
||||||
id: meta
|
- name: Checkout Repository
|
||||||
uses: docker/metadata-action@v5
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=sha
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Extract Docker Metadata
|
||||||
uses: docker/build-push-action@v6
|
id: meta
|
||||||
with:
|
uses: docker/metadata-action@v5
|
||||||
context: .
|
with:
|
||||||
file: ./Dockerfile
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
push: ${{ github.ref == 'refs/heads/main' }}
|
tags: |
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
type=sha
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
Reference in new issue
Block a user