Skip to content

Commit e398dcf

Browse files
committed
ci: add rust & docker cache steps, use official docker buildx actions, fix image size test
1 parent 341e3e9 commit e398dcf

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

.github/workflows/image.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ jobs:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
1616

17+
- uses: Swatinem/rust-cache@v2
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
1722
- name: Build Docker image
18-
run: docker build --build-arg RUST_VERSION=${{ env.RUST_VERSION }} -t glim-test .
23+
uses: docker/build-push-action@v5
24+
with:
25+
context: .
26+
push: false
27+
tags: glim-test
28+
build-args: |
29+
RUST_VERSION=${{ env.RUST_VERSION }}
30+
cache-from: type=gha
31+
cache-to: type=gha,mode=max
1932

2033
- name: Test image functionality
2134
run: |
@@ -112,15 +125,16 @@ jobs:
112125
113126
# Check image size - capture return code, not output
114127
check_image_size "glim-test" "100M"
128+
RET_CODE=$?
115129
116130
# Handle return code
117-
if [ $? -ge 1 ]; then
131+
if [ $RET_CODE -eq 1 ]; then
118132
echo "::error::Image is too large"
119133
exit 1
120-
elif [ $? -eq 2 ]; then
121-
echo "::warning::Image is within 10% of the limit"
122-
exit 0 # required, otherwise the function call above will provide the exit code '2'
123-
elif [ $? -eq -1 ]; then
134+
elif [ $RET_CODE -eq -1 ]; then
124135
echo "::warning::Image size check failed"
125136
exit 1
137+
elif [ $RET_CODE -eq 2 ]; then
138+
echo "::warning::Image is within 10% of the limit"
139+
exit 0
126140
fi

0 commit comments

Comments
 (0)