Skip to content

Commit

Permalink
ci: lint with Dockerfile (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka authored Dec 15, 2024
1 parent daea30b commit 0f70ecb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 73 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/build.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
merge_group:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-20.04
# Set permissions if you're using OIDC token authentication
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Depot CLI
uses: depot/setup-action@v1

- uses: depot/build-push-action@v1
with:
# if no depot.json file is at the root of your repo, you must specify the project id
project: qln0fqqvvd
# Pass project token or user access token if you're not using OIDC token authentication
token: ${{ secrets.DEPOT_TOKEN }}
push: false
context: .
file: Dockerfile
target: ci
27 changes: 18 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ ARG RUST_NIGHTLY_VERSION=nightly-2024-11-29
ARG RUSTFLAGS="-Z share-generics=y -Z threads=8"
ARG CARGO_HOME=/usr/local/cargo

# Use Ubuntu as base image
FROM ubuntu:22.04 AS packages

# Prevent apt from prompting for user input
ENV DEBIAN_FRONTEND=noninteractive

# Install essential build packages
FROM ubuntu:22.04 AS packages
FROM ubuntu:24.04 AS packages
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
curl \
Expand Down Expand Up @@ -39,16 +34,30 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST_NIGH
$CARGO_HOME/bin/rustc --version
ENV PATH="${CARGO_HOME}/bin:${PATH}"
WORKDIR /app

RUN cargo install cargo-machete cargo-nextest

COPY . .

RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo fetch

# CI stage for checks
FROM builder-base AS ci

RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo machete && \
cargo fmt --all -- --check && \
cargo clippy --workspace --benches --tests --examples --all-features -- -D warnings && \
cargo nextest run --all-features --workspace --locked

# Release builder
FROM builder-base AS build-release
ARG CARGO_HOME

RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
Expand All @@ -58,7 +67,7 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \
cp target/release-full/tag /app/build/

# Runtime base image
FROM ubuntu:22.04 AS runtime-base
FROM ubuntu:24.04 AS runtime-base
RUN apt-get update && \
apt-get install -y \
libssl3 \
Expand Down

0 comments on commit 0f70ecb

Please sign in to comment.