ci: chart tests and real helm e2e on k3d, cache all CI downloads #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_TOOLCHAIN: "1.97.0" | |
| K3D_VERSION: v5.9.0 | |
| TEST_IMAGES: >- | |
| ghcr.io/openprojectx/dockerhub/rustfs/rustfs:1.0.0-beta.8 | |
| ghcr.io/openprojectx/dockerhub/rancher/k3s:v1.34.9-k3s1 | |
| K3S_SYSTEM_IMAGES: >- | |
| docker.io/rancher/mirrored-pause:3.6 | |
| docker.io/rancher/mirrored-coredns-coredns:1.14.4 | |
| docker.io/rancher/local-path-provisioner:v0.0.36 | |
| jobs: | |
| lint-and-unit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache rust toolchain | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.rustup/toolchains | |
| key: rustup-${{ runner.os }}-1.97.0 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: "1.97.0" | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Format | |
| run: cargo fmt --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets --features integration,e2e -- -D warnings | |
| - name: Unit tests | |
| run: cargo test | |
| chart-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Chart lint, render and validation tests | |
| run: bash scripts/chart-tests.sh | |
| container-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache rust toolchain | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.rustup/toolchains | |
| key: rustup-${{ runner.os }}-1.97.0 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: "1.97.0" | |
| - uses: Swatinem/rust-cache@v2 | |
| - uses: ./.github/actions/cached-images | |
| with: | |
| images: ${{ env.TEST_IMAGES }} | |
| cache-key: test-images-rustfs-beta8-k3s-1.34.9 | |
| - name: Integration tests (RustFS container) | |
| run: cargo test --features integration --test integration_rustfs | |
| - name: E2E tests (k3s + RustFS containers) | |
| run: cargo test --features e2e --test e2e_k3s | |
| # Validates the Dockerfile and seeds the buildx GHA cache on the default | |
| # branch, so tag-triggered release builds can restore it (Actions cache is | |
| # isolated per ref except for the default branch). | |
| image-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # Real Helm flow against a k3d cluster: CRDs chart, operator chart with a | |
| # values-bootstrapped ClusterConnection, resources chart, convergence and | |
| # finalizer cleanup — using the image built from this commit. | |
| chart-e2e: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Build operator image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| load: true | |
| tags: rustfs-operator:ci | |
| cache-from: type=gha | |
| - name: Cache k3d binary | |
| id: k3d-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.local/bin/k3d | |
| key: k3d-${{ env.K3D_VERSION }}-linux-amd64 | |
| - name: Install k3d (cache miss) | |
| if: steps.k3d-cache.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p ~/.local/bin | |
| curl -fsSL "https://github.com/k3d-io/k3d/releases/download/${K3D_VERSION}/k3d-linux-amd64" -o ~/.local/bin/k3d | |
| chmod +x ~/.local/bin/k3d | |
| - uses: ./.github/actions/cached-images | |
| with: | |
| images: ${{ env.TEST_IMAGES }} ${{ env.K3S_SYSTEM_IMAGES }} | |
| cache-key: chart-e2e-images-v1 | |
| - name: Run chart e2e | |
| run: IMAGE=rustfs-operator:ci bash scripts/chart-e2e.sh |