Skip to content

Commit 0f70ecb

Browse files
ci: lint with Dockerfile (#726)
1 parent daea30b commit 0f70ecb

File tree

3 files changed

+54
-73
lines changed

3 files changed

+54
-73
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
merge_group:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-20.04
14+
# Set permissions if you're using OIDC token authentication
15+
permissions:
16+
contents: read
17+
id-token: write
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 1
23+
24+
- name: Set up Depot CLI
25+
uses: depot/setup-action@v1
26+
27+
- uses: depot/build-push-action@v1
28+
with:
29+
# if no depot.json file is at the root of your repo, you must specify the project id
30+
project: qln0fqqvvd
31+
# Pass project token or user access token if you're not using OIDC token authentication
32+
token: ${{ secrets.DEPOT_TOKEN }}
33+
push: false
34+
context: .
35+
file: Dockerfile
36+
target: ci

Dockerfile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ ARG RUST_NIGHTLY_VERSION=nightly-2024-11-29
33
ARG RUSTFLAGS="-Z share-generics=y -Z threads=8"
44
ARG CARGO_HOME=/usr/local/cargo
55

6-
# Use Ubuntu as base image
7-
FROM ubuntu:22.04 AS packages
8-
9-
# Prevent apt from prompting for user input
10-
ENV DEBIAN_FRONTEND=noninteractive
11-
126
# Install essential build packages
13-
FROM ubuntu:22.04 AS packages
7+
FROM ubuntu:24.04 AS packages
148
ENV DEBIAN_FRONTEND=noninteractive
9+
1510
RUN apt-get update && \
1611
apt-get install -y \
1712
curl \
@@ -39,16 +34,30 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST_NIGH
3934
$CARGO_HOME/bin/rustc --version
4035
ENV PATH="${CARGO_HOME}/bin:${PATH}"
4136
WORKDIR /app
37+
38+
RUN cargo install cargo-machete cargo-nextest
39+
4240
COPY . .
4341

4442
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
4543
--mount=type=cache,target=${CARGO_HOME}/git \
4644
--mount=type=cache,target=/app/target \
4745
cargo fetch
4846

47+
# CI stage for checks
48+
FROM builder-base AS ci
49+
50+
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
51+
--mount=type=cache,target=${CARGO_HOME}/git \
52+
--mount=type=cache,target=/app/target \
53+
cargo machete && \
54+
cargo fmt --all -- --check && \
55+
cargo clippy --workspace --benches --tests --examples --all-features -- -D warnings && \
56+
cargo nextest run --all-features --workspace --locked
57+
4958
# Release builder
5059
FROM builder-base AS build-release
51-
ARG CARGO_HOME
60+
5261
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
5362
--mount=type=cache,target=${CARGO_HOME}/git \
5463
--mount=type=cache,target=/app/target \
@@ -58,7 +67,7 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \
5867
cp target/release-full/tag /app/build/
5968

6069
# Runtime base image
61-
FROM ubuntu:22.04 AS runtime-base
70+
FROM ubuntu:24.04 AS runtime-base
6271
RUN apt-get update && \
6372
apt-get install -y \
6473
libssl3 \

0 commit comments

Comments
 (0)