Skip to content

Commit

Permalink
refactor: use actions-rust-lang/setup-rust-toolchain@v1 & docker/setu…
Browse files Browse the repository at this point in the history
…p-buildx-action@v3 for e2e

* actions-rust-lang/setup-rust-toolchain@v1 incorporates using github action cache. Subsequent builds will use cache if there has been no dependency changes - https://github.com/actions-rust-lang/setup-rust-toolchain
* Use docker/setup-buildx-action@v3 to docker layers to github action cache. Subsequent builds will use cache if layers have not been invalidated by changes
* update .dockerignore to include doc related files so that layer cache is not invalidated by changes to these files
  • Loading branch information
KevFan committed Oct 19, 2023
1 parent 38f55ca commit 34f9dfd
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 84 deletions.
16 changes: 14 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
Dockerfile
*.swp
.dockerignore
.gitignore
.git

.github
doc
.idea
**/*.yaml
**/*.md
**/*.json
**/*.sh
**/*.png
**/*.svg
# OSX files
.DS_Store
.DS_Store

# Exception - Used in docker build
!limitador-server/examples/limits.yaml
2 changes: 1 addition & 1 deletion .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Add latest tag
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
run: |
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
Expand All @@ -36,17 +32,15 @@ jobs:
USER: username
PASS: password
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: supercharge/redis-github-action@1.1.0
with:
redis-version: 5
# Nightly is required for code coverage with doctests
# https://github.com/taiki-e/cargo-llvm-cov/issues/2
- uses: actions-rs/toolchain@v1
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
limitador-testing
tags: |
type=raw,value=latest
- name: Build Limitador Image
id: build-image
uses: redhat-actions/buildah-build@v2
uses: docker/build-push-action@v5
with:
image: limitador-testing
tags: latest
dockerfiles: |
./Dockerfile
context: .
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.1.0
uses: helm/kind-action@v1.8.0
with:
version: v0.11.1
version: v0.20.0
config: limitador-server/script/kind-cluster.yaml
cluster_name: limitador-local
wait: 120s
Expand All @@ -34,8 +45,7 @@ jobs:
kubectl cluster-info dump
- name: Load limitador docker image
run: |
podman save -o image.tar ${{ steps.build-image.outputs.image }}:${{ steps.build-image.outputs.tags }}
kind load image-archive --name limitador-local image.tar
kind load docker-image ${{ steps.meta.outputs.tags }} -n limitador-local
- name: Deploy limitador
run: |
kubectl apply -f limitador-server/e2e/file-watcher/configmap.yaml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: supercharge/redis-github-action@1.1.0
with:
redis-version: 5
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: crate-v${{ github.event.inputs.version }}
- name: Build
Expand Down
80 changes: 21 additions & 59 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
- uses: actions-rs/cargo@v1
with:
command: check
- run: cargo check

test:
name: Test Suite
Expand All @@ -41,100 +35,68 @@ jobs:
USER: username
PASS: password
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: supercharge/redis-github-action@1.1.0
with:
redis-version: 5
# Nightly is required for code coverage with doctests
# https://github.com/taiki-e/cargo-llvm-cov/issues/2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features -vv
- run: cargo test --all-features -vv

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
components: clippy
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets -- -D warnings
- run: cargo clippy --all-features --all-targets -- -D warnings

bench:
name: Bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: supercharge/redis-github-action@1.1.0
with:
redis-version: 5
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
- uses: actions-rs/cargo@v1
with:
command: bench
- run: cargo bench

wasm-build:
name: Build for WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: actions-rs/cargo@v1
with:
command: build
args: --target=wasm32-unknown-unknown --no-default-features --lib --manifest-path ./limitador/Cargo.toml
- run: cargo build --target=wasm32-unknown-unknown --no-default-features --lib --manifest-path ./limitador/Cargo.toml

kind:
name: Try in kind (Kubernetes in Docker)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: engineerd/setup-kind@v0.5.0
with:
version: v0.11.1
Expand Down
2 changes: 1 addition & 1 deletion limitador-server/e2e/file-watcher/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: limitador
image: localhost/limitador-testing:latest
image: limitador-testing:latest
imagePullPolicy: IfNotPresent
env:
- name: RUST_LOG
Expand Down

0 comments on commit 34f9dfd

Please sign in to comment.