Skip to content

Commit b043f64

Browse files
build: converting to Rust's Alpine image (#75)
1 parent a61e331 commit b043f64

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ jobs:
6464
fetch-depth: 0
6565
- name: Unit test.
6666
run: earthly --ci +unit-test
67+
static-binary-test:
68+
name: Static Binary Test
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Download Earthly.
72+
uses: earthly/actions-setup@v1
73+
with:
74+
version: v0.8.15
75+
- name: Checkout code.
76+
uses: actions/checkout@v4
77+
- name: Static binary test.
78+
run: earthly --ci +static-binary-test
6779
end-to-end-test:
6880
name: End to End Test
6981
runs-on: ubuntu-latest

Earthfile

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@ COPY_METADATA:
1212
COPY --dir ".git/" "./"
1313

1414

15-
alpine-base:
16-
FROM alpine:3.20.3@sha256:1e42bbe2508154c9126d48c2b8a75420c3544343bf86fd041fb7527e017a4b4a
15+
rust-base:
16+
FROM rust:1.78.0-alpine3.20
1717
# renovate: datasource=repology depName=alpine_3_20/bash versioning=loose
1818
ENV BASH_VERSION="5.2.26-r0"
19-
RUN apk add --no-cache bash=$BASH_VERSION
19+
# renovate: datasource=repology depName=alpine_3_20/musl-dev versioning=loose
20+
ENV MUSL_VERSION="1.2.5-r0"
21+
RUN apk add --no-cache bash=$BASH_VERSION musl-dev=$MUSL_VERSION
22+
RUN rustup component add rustfmt clippy
2023
WORKDIR "/conventional_commits_next_version"
2124

2225

23-
rust-base:
24-
FROM +alpine-base
25-
# renovate: datasource=repology depName=alpine_3_20/rust versioning=loose
26-
ENV RUST_VERSION="1.78.0-r0"
27-
RUN apk add --no-cache cargo=$RUST_VERSION
28-
29-
3026
check-clean-git-history:
3127
FROM +rust-base
3228
# renovate: datasource=github-releases depName=DeveloperC286/clean_git_history
@@ -54,19 +50,18 @@ COPY_SOURCECODE:
5450
COPY --dir "Cargo.toml" "src/" "end-to-end-tests/" "./"
5551

5652

57-
rust-formatting-base:
53+
sourcecode-base:
5854
FROM +rust-base
59-
RUN apk add --no-cache rustfmt=$RUST_VERSION
6055
DO +COPY_SOURCECODE
6156

6257

6358
check-rust-formatting:
64-
FROM +rust-formatting-base
59+
FROM +sourcecode-base
6560
RUN ./ci/check-rust-formatting.sh
6661

6762

6863
python-base:
69-
FROM +alpine-base
64+
FROM +rust-base
7065
# renovate: datasource=repology depName=alpine_3_20/python3 versioning=loose
7166
ENV PYTHON_VERSION="3.12.8-r1"
7267
# renovate: datasource=repology depName=alpine_3_20/git versioning=loose
@@ -127,7 +122,7 @@ check-formatting:
127122

128123

129124
fix-rust-formatting:
130-
FROM +rust-formatting-base
125+
FROM +sourcecode-base
131126
RUN ./ci/fix-rust-formatting.sh
132127
SAVE ARTIFACT "src/" AS LOCAL "./"
133128

@@ -158,14 +153,12 @@ fix-formatting:
158153

159154

160155
check-rust-linting:
161-
FROM +rust-base
162-
RUN apk add --no-cache rust-clippy=$RUST_VERSION
163-
DO +COPY_SOURCECODE
156+
FROM +sourcecode-base
164157
RUN ./ci/check-rust-linting.sh
165158

166159

167160
check-shell-linting:
168-
FROM +alpine-base
161+
FROM +rust-base
169162
# renovate: datasource=repology depName=alpine_3_20/shellcheck versioning=loose
170163
ENV SHELLCHECK_VERSION="0.10.0-r1"
171164
RUN apk add --no-cache shellcheck=$SHELLCHECK_VERSION
@@ -189,19 +182,23 @@ check-linting:
189182

190183

191184
compile:
192-
FROM +rust-base
193-
DO +COPY_SOURCECODE
185+
FROM +sourcecode-base
194186
RUN ./ci/compile.sh
195187
SAVE ARTIFACT "target/" AS LOCAL "./"
196188
SAVE ARTIFACT "Cargo.lock" AS LOCAL "./"
197189

198190

199191
unit-test:
200-
FROM +rust-base
201-
DO +COPY_SOURCECODE
192+
FROM +sourcecode-base
202193
RUN ./ci/unit-test.sh
203194

204195

196+
static-binary-test:
197+
FROM ubuntu:24.04
198+
COPY "+compile/target/" "target/"
199+
RUN ./target/debug/conventional_commits_next_version --help
200+
201+
205202
end-to-end-test:
206203
FROM +python-base
207204
RUN pip3 install -r "end-to-end-tests/requirements.txt" --break-system-packages
@@ -210,7 +207,7 @@ end-to-end-test:
210207

211208

212209
release-artifacts:
213-
FROM +alpine-base
210+
FROM +rust-base
214211
# renovate: datasource=repology depName=alpine_3_20/github-cli versioning=loose
215212
ENV GITHUB_CLI_VERSION="2.47.0-r4"
216213
RUN apk add --no-cache github-cli=$GITHUB_CLI_VERSION
@@ -221,7 +218,6 @@ release-artifacts:
221218

222219

223220
publish:
224-
FROM +rust-base
221+
FROM +sourcecode-base
225222
COPY "README.md" "./"
226-
DO +COPY_SOURCECODE
227223
RUN --secret CARGO_REGISTRY_TOKEN ./ci/publish.sh

0 commit comments

Comments
 (0)