Skip to content

Commit 0c3af2c

Browse files
committed
👷 Add formatting stage
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
1 parent 661301d commit 0c3af2c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/workflows/test.yml

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
CARGO_TERM_COLOR: always
1111
TEST_IMAGE_NAME: "orchestr8-tests:0"
1212
LINT_IMAGE_NAME: "orchestr8-lint:0"
13+
FMT_IMAGE_NAME: "orchestr8-fmt:0"
1314

1415
jobs:
1516
build:
@@ -20,6 +21,7 @@ jobs:
2021
env:
2122
CACHE_TEST_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:test-cache"
2223
CACHE_LINT_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:lint-cache"
24+
CACHE_FMT_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:fmt-cache"
2325
CACHE_REGISTRY: "ghcr.io"
2426

2527
steps:
@@ -50,12 +52,15 @@ jobs:
5052
#CACHE_TO="type=gha,mode=min"
5153
CACHE_TEST_TO="type=inline"
5254
CACHE_LINT_TO="type=inline"
55+
CACHE_FMT_TO="type=inline"
5356
else
5457
CACHE_TEST_TO="type=registry,ref=${{ env.CACHE_TEST_IMAGE }},mode=max"
5558
CACHE_LINT_TO="type=registry,ref=${{ env.CACHE_LINT_IMAGE }},mode=max"
59+
CACHE_FMT_TO="type=registry,ref=${{ env.CACHE_FMT_IMAGE }},mode=max"
5660
fi
5761
echo "CACHE_TEST_TO=$CACHE_TEST_TO" >> $GITHUB_ENV
5862
echo "CACHE_LINT_TO=$CACHE_LINT_TO" >> $GITHUB_ENV
63+
echo "CACHE_FMT_TO=$CACHE_FMT_TO" >> $GITHUB_ENV
5964
- name: Test
6065
uses: docker/build-push-action@v5
6166
with:
@@ -76,4 +81,14 @@ jobs:
7681
cache-to: ${{ env.CACHE_LINT_TO }}
7782
push: false
7883
platforms: linux/amd64
84+
- name: Format
85+
uses: docker/build-push-action@v5
86+
with:
87+
context: .
88+
target: format
89+
tags: ${{ env.FMT_IMAGE_NAME }}
90+
cache-from: type=registry,ref=${{ env.CACHE_FMT_IMAGE }}
91+
cache-to: ${{ env.CACHE_FMT_TO }}
92+
push: false
93+
platforms: linux/amd64
7994

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ RUN cargo install --root /app/ --path .
3737
FROM fms-guardrails-orchestr8-builder as tests
3838
RUN cargo test
3939

40-
## Lint stage ##################################################################
40+
## Lint stage ###################################################################
4141
FROM fms-guardrails-orchestr8-builder as lint
4242
RUN cargo clippy --all-targets --all-features -- -D warnings
4343

44+
## Formatting check stage #######################################################
45+
FROM fms-guardrails-orchestr8-builder as format
46+
RUN cargo fmt --check
47+
4448
## Release Image ################################################################
4549

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

0 commit comments

Comments
 (0)