Skip to content

Commit fafe006

Browse files
committed
👷 Lint stage
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
1 parent 1ae4e6b commit fafe006

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
TEST_IMAGE_NAME: "orchestr8-tests:0"
12+
LINT_IMAGE_NAME: "orchestr8-lint:0"
1213

1314
jobs:
1415
build:
@@ -17,7 +18,8 @@ jobs:
1718
packages: write
1819
contents: read
1920
env:
20-
CACHE_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:test-cache"
21+
CACHE_TEST_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:test-cache"
22+
CACHE_LINT_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:lint-cache"
2123
CACHE_REGISTRY: "ghcr.io"
2224

2325
steps:
@@ -46,23 +48,34 @@ jobs:
4648
if [ "${{ github.event_name }}" == "pull_request" ]
4749
then
4850
#CACHE_TO="type=gha,mode=min"
49-
CACHE_TO="type=inline"
51+
CACHE_TEST_TO="type=inline"
52+
CACHE_LINT_TO="type=inline"
5053
else
51-
CACHE_TO="type=registry,ref=${{ env.CACHE_IMAGE }},mode=max"
54+
CACHE_TEST_TO="type=registry,ref=${{ env.CACHE_TEST_IMAGE }},mode=max"
55+
CACHE_LINT_TO="type=registry,ref=${{ env.CACHE_LINT_IMAGE }},mode=max"
5256
fi
53-
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
57+
echo "CACHE_TEST_TO=$CACHE_TEST_TO" >> $GITHUB_ENV
58+
echo "CACHE_LINT_TO=$CACHE_LINT_TO" >> $GITHUB_ENV
59+
- name: Check formatting
60+
run: cargo fmt -- -check
5461
- name: Test
5562
uses: docker/build-push-action@v5
5663
with:
5764
context: .
5865
target: tests
5966
tags: ${{ env.TEST_IMAGE_NAME }}
60-
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
61-
cache-to: ${{ env.CACHE_TO }}
67+
cache-from: type=registry,ref=${{ env.CACHE_TEST_IMAGE }}
68+
cache-to: ${{ env.CACHE_TEST_TO }}
6269
push: false
6370
platforms: linux/amd64
6471
- name: Lint with clippy
65-
run: cargo clippy --all-targets --all-features -- -D warnings
66-
- name: Check formatting
67-
run: cargo fmt -- -check
72+
uses: docker/build-push-action@v5
73+
with:
74+
context: .
75+
target: lint
76+
tags: ${{ env.LINT_IMAGE_NAME }}
77+
cache-from: type=registry,ref=${{ env.CACHE_LINT_IMAGE }}
78+
cache-to: ${{ env.CACHE_LINT_TO }}
79+
push: false
80+
platforms: linux/amd64
6881

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ RUN cargo install --root /app/ --path .
3737
FROM fms-guardrails-orchestr8-builder as tests
3838
RUN cargo test
3939

40+
## Lint stage ##################################################################
41+
FROM fms-guardrails-orchestr8-builder as lint
42+
RUN cargo clippy --all-targets --all-features -- -D warnings
43+
4044
## Release Image ################################################################
4145

4246
FROM ${UBI_MINIMAL_BASE_IMAGE}:${UBI_BASE_IMAGE_TAG} as fms-guardrails-orchestr8-release

0 commit comments

Comments
 (0)