Skip to content

Commit 7e7e84e

Browse files
authored
ci: add GitHub Actions CI workflow with lint, test, and image build (#1)
1 parent 62c992c commit 7e7e84e

File tree

8 files changed

+150
-52
lines changed

8 files changed

+150
-52
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Setup Docker Buildx
2+
description: >
3+
Create a multi-arch Docker Buildx builder using remote BuildKit nodes.
4+
The builder is automatically removed when the job finishes (cleanup is
5+
enabled by default in docker/setup-buildx-action).
6+
7+
inputs:
8+
amd64-endpoint:
9+
description: BuildKit endpoint for linux/amd64
10+
default: tcp://buildkit-amd64.buildkit:1234
11+
arm64-endpoint:
12+
description: BuildKit endpoint for linux/arm64
13+
default: tcp://buildkit-arm64.buildkit:1234
14+
name:
15+
description: Builder instance name
16+
default: navigator
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
with:
24+
name: ${{ inputs.name }}
25+
driver: remote
26+
endpoint: ${{ inputs.amd64-endpoint }}
27+
platforms: linux/amd64
28+
append: |
29+
- endpoint: ${{ inputs.arm64-endpoint }}
30+
platforms: linux/arm64

.github/workflows/checks.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
CARGO_INCREMENTAL: "0"
11+
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
permissions:
14+
contents: read
15+
packages: read
16+
17+
jobs:
18+
rust:
19+
name: Rust
20+
runs-on: build-amd64
21+
container:
22+
image: ghcr.io/nvidia/nv-agent-env/ci:latest
23+
credentials:
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Format
30+
run: mise run rust:format:check
31+
32+
- name: Lint
33+
run: mise run rust:lint
34+
35+
- name: Test
36+
run: mise run test:rust
37+
38+
python:
39+
name: Python
40+
runs-on: build-amd64
41+
container:
42+
image: ghcr.io/nvidia/nv-agent-env/ci:latest
43+
credentials:
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Install dependencies
50+
run: uv sync --frozen
51+
52+
- name: Lint
53+
run: mise run python:lint
54+
55+
- name: Test
56+
run: mise run test:python

.github/workflows/ci-image.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'deploy/docker/Dockerfile.ci'
8+
- 'mise.toml'
9+
- 'build/**'
10+
- '.github/workflows/ci-image.yml'
11+
workflow_dispatch:
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
CI_IMAGE: ghcr.io/nvidia/nv-agent-env/ci
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
jobs:
22+
build-ci-image:
23+
name: Build
24+
runs-on: build-amd64
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Log in to GitHub Container Registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Set up Docker Buildx
36+
uses: ./.github/actions/setup-buildx
37+
38+
- name: Build and push CI image
39+
run: |
40+
docker buildx build \
41+
--platform linux/amd64,linux/arm64 \
42+
--cache-from type=registry,ref=${{ env.CI_IMAGE }}:buildcache \
43+
--cache-to type=registry,ref=${{ env.CI_IMAGE }}:buildcache,mode=max \
44+
--build-arg MISE_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
45+
--push \
46+
-t ${{ env.CI_IMAGE }}:${{ github.sha }} \
47+
-t ${{ env.CI_IMAGE }}:latest \
48+
-f deploy/docker/Dockerfile.ci \
49+
.

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ mise run test:e2e:sandbox # Sandbox Python e2e tests
154154

155155
```bash
156156
# Rust
157-
mise run fmt # Format code
158-
mise run fmt:check # Check formatting
159-
mise run clippy # Run Clippy lints
157+
mise run rust:format # Format code
158+
mise run rust:format:check # Check formatting
159+
mise run rust:lint # Lint with Clippy
160160

161161
# Python
162-
mise run python:fmt # Format with ruff
162+
mise run python:format # Format with ruff
163163
mise run python:lint # Lint with ruff
164164
mise run python:typecheck # Type check with ty
165165

build/ci.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CI, pre-commit, and sandbox runner tasks
22

33
[lint]
4-
description = "Run all linters (fmt, clippy, ruff)"
5-
depends = ["fmt:check", "clippy", "python:lint"]
4+
description = "Run all linters and format checks"
5+
depends = ["rust:format:check", "rust:lint", "python:lint"]
66

77
[all]
88
description = "Build, lint, and test everything"

build/python.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ depends = ["python:proto"]
112112
env = { UV_NO_SYNC = "1" }
113113
run = "uv run ruff check {{vars.python_paths}}"
114114

115-
["python:fmt"]
115+
["python:format"]
116116
description = "Format Python code with ruff"
117117
run = "uv run ruff format {{vars.python_paths}}"
118118

build/rust.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ run = "cargo build --workspace --release"
1212
description = "Check all Rust crates for errors"
1313
run = "cargo check --workspace"
1414

15-
[clippy]
16-
description = "Run Clippy lints"
15+
["rust:lint"]
16+
description = "Lint Rust code with Clippy"
1717
run = "cargo clippy --workspace --all-targets"
1818

19-
[fmt]
19+
["rust:format"]
2020
description = "Format Rust code"
2121
run = "cargo fmt --all"
2222

23-
["fmt:check"]
23+
["rust:format:check"]
2424
description = "Check Rust formatting"
2525
run = "cargo fmt --all -- --check"
2626

deploy/docker/Dockerfile.ci

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ FROM ubuntu:24.04
77
ARG DOCKER_VERSION=27.5.1
88
ARG BUILDX_VERSION=v0.21.1
99
ARG TARGETARCH
10-
ARG KUBECTL_VERSION=v1.35.1
11-
ARG HELM_VERSION=v4.1.1
12-
ARG PROTOC_VERSION=29.6
13-
ARG SCCACHE_VERSION=v0.14.0
1410

1511
ENV DEBIAN_FRONTEND=noninteractive
1612
ENV MISE_DATA_DIR=/opt/mise
1713
ENV MISE_CACHE_DIR=/opt/mise/cache
18-
ENV PATH="/opt/mise/shims:/root/.local/bin:$PATH"
14+
ENV PATH="/opt/mise/shims:/root/.cargo/bin:/root/.local/bin:$PATH"
1915

2016
# Install system dependencies
2117
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -28,7 +24,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2824
python3 \
2925
python3-venv \
3026
cmake \
31-
protobuf-compiler \
3227
socat \
3328
unzip \
3429
xz-utils \
@@ -58,50 +53,18 @@ RUN case "$TARGETARCH" in \
5853
&& /tmp/aws/install \
5954
&& rm -rf /tmp/aws /tmp/awscliv2.zip
6055

61-
# Install kubectl, helm, and protoc without GitHub API lookups
62-
RUN case "$TARGETARCH" in \
63-
amd64) karch=amd64; helm_arch=amd64; protoc_arch=x86_64 ;; \
64-
arm64) karch=arm64; helm_arch=arm64; protoc_arch=aarch_64 ;; \
65-
*) echo "Unsupported TARGETARCH: $TARGETARCH"; exit 1 ;; \
66-
esac \
67-
&& curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${karch}/kubectl" -o /usr/local/bin/kubectl \
68-
&& chmod +x /usr/local/bin/kubectl \
69-
&& curl -fsSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-${helm_arch}.tar.gz" -o /tmp/helm.tgz \
70-
&& tar -xzf /tmp/helm.tgz -C /tmp \
71-
&& mv "/tmp/linux-${helm_arch}/helm" /usr/local/bin/helm \
72-
&& chmod +x /usr/local/bin/helm \
73-
&& rm -rf /tmp/helm.tgz "/tmp/linux-${helm_arch}" \
74-
&& curl -fsSL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${protoc_arch}.zip" -o /tmp/protoc.zip \
75-
&& unzip -q /tmp/protoc.zip -d /tmp/protoc \
76-
&& mv /tmp/protoc/bin/protoc /usr/local/bin/protoc \
77-
&& chmod +x /usr/local/bin/protoc \
78-
&& rm -rf /tmp/protoc /tmp/protoc.zip
79-
80-
# Install sccache directly on amd64 (mise/aqua plugin is arch-limited)
81-
RUN if [ "$TARGETARCH" = "amd64" ]; then \
82-
curl -fsSL "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" -o /tmp/sccache.tgz \
83-
&& tar -xzf /tmp/sccache.tgz -C /tmp \
84-
&& mv "/tmp/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache" /usr/local/bin/sccache \
85-
&& chmod +x /usr/local/bin/sccache \
86-
&& rm -rf /tmp/sccache.tgz "/tmp/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl"; \
87-
else \
88-
echo "Skipping sccache install on $TARGETARCH"; \
89-
fi
90-
9156
# Install mise
9257
RUN curl https://mise.run | sh
9358

94-
# Copy mise.toml and build task includes, then install core tools
59+
# Copy mise.toml and build task includes, then install all tools via mise
9560
COPY mise.toml /opt/mise/mise.toml
9661
COPY build/ /opt/mise/build/
9762
WORKDIR /opt/mise
63+
ARG MISE_GITHUB_TOKEN
9864
RUN mise trust /opt/mise/mise.toml && \
99-
env -u RUSTC_WRAPPER mise install python rust 'cargo:cargo-edit' && \
65+
env -u RUSTC_WRAPPER mise install && \
10066
/root/.cargo/bin/rustup component remove rust-docs || true && \
10167
rm -rf /root/.rustup/toolchains/*/share/doc /root/.rustup/toolchains/*/share/man
10268

103-
# Install uv directly to avoid GitHub API rate limits in CI image builds
104-
RUN curl -LsSf https://astral.sh/uv/0.10.2/install.sh | sh
105-
10669
# Set working directory for CI jobs
10770
WORKDIR /builds

0 commit comments

Comments
 (0)