Skip to content

Commit

Permalink
👷 Add formatting stage
Browse files Browse the repository at this point in the history
Signed-off-by: Evaline Ju <[email protected]>
  • Loading branch information
evaline-ju committed May 15, 2024
1 parent fd10557 commit 21e9115
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
CARGO_TERM_COLOR: always
TEST_IMAGE_NAME: "orchestr8-tests:0"
LINT_IMAGE_NAME: "orchestr8-lint:0"
FMT_IMAGE_NAME: "orchestr8-fmt:0"

jobs:
build:
Expand All @@ -20,6 +21,7 @@ jobs:
env:
CACHE_TEST_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:test-cache"
CACHE_LINT_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:lint-cache"
CACHE_FMT_IMAGE: "ghcr.io/foundation-model-stack/fms-guardrails-orchestrator:fmt-cache"
CACHE_REGISTRY: "ghcr.io"

steps:
Expand Down Expand Up @@ -50,14 +52,15 @@ jobs:
#CACHE_TO="type=gha,mode=min"
CACHE_TEST_TO="type=inline"
CACHE_LINT_TO="type=inline"
CACHE_FMT_TO="type=inline"
else
CACHE_TEST_TO="type=registry,ref=${{ env.CACHE_TEST_IMAGE }},mode=max"
CACHE_LINT_TO="type=registry,ref=${{ env.CACHE_LINT_IMAGE }},mode=max"
CACHE_FMT_TO="type=registry,ref=${{ env.CACHE_FMT_IMAGE }},mode=max"
fi
echo "CACHE_TEST_TO=$CACHE_TEST_TO" >> $GITHUB_ENV
echo "CACHE_LINT_TO=$CACHE_LINT_TO" >> $GITHUB_ENV
- name: Check formatting
run: cargo fmt --check
echo "CACHE_FMT_TO=$CACHE_FMT_TO" >> $GITHUB_ENV
- name: Test
uses: docker/build-push-action@v5
with:
Expand All @@ -78,4 +81,14 @@ jobs:
cache-to: ${{ env.CACHE_LINT_TO }}
push: false
platforms: linux/amd64
- name: Format
uses: docker/build-push-action@v5
with:
context: .
target: format
tags: ${{ env.FMT_IMAGE_NAME }}
cache-from: type=registry,ref=${{ env.CACHE_FMT_IMAGE }}
cache-to: ${{ env.CACHE_FMT_TO }}
push: false
platforms: linux/amd64

6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ RUN cargo install --root /app/ --path .
FROM fms-guardrails-orchestr8-builder as tests
RUN cargo test

## Lint stage ##################################################################
## Lint stage ###################################################################
FROM fms-guardrails-orchestr8-builder as lint
RUN cargo clippy --all-targets --all-features -- -D warnings

## Formatting check stage #######################################################
FROM fms-guardrails-orchestr8-builder as format
RUN cargo fmt --check

## Release Image ################################################################

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

0 comments on commit 21e9115

Please sign in to comment.