Skip to content

Commit bdfc330

Browse files
Per Enstedtclaude
andcommitted
Overhaul CI/CD with comprehensive caching and Docker Hub publishing
- Enable CI on main branch for push and pull requests - Add extensive caching: apt packages, Rust dependencies, trunk binary - Split linting: separate jobs for backend/MCP (native) and frontend (WASM) - Include strom-mcp-server in test and build pipelines - Optimize trunk installation using pre-built binary instead of cargo install - Add separate workflow for Docker Hub publishing on releases - Upload both backend and MCP server artifacts This dramatically reduces CI resource consumption and build times. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1148fc8 commit bdfc330

2 files changed

Lines changed: 137 additions & 64 deletions

File tree

.github/workflows/ci.yml

Lines changed: 86 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ name: CI
22

33
on:
44
push:
5-
branches: [disabled-main]
5+
branches: [main]
66
pull_request:
7-
branches: [disabled-main]
7+
branches: [main]
88

99
env:
1010
CARGO_TERM_COLOR: always
1111
RUST_BACKTRACE: 1
12+
# Trunk version for caching
13+
TRUNK_VERSION: "0.21.5"
1214

1315
jobs:
1416
fmt:
@@ -22,11 +24,17 @@ jobs:
2224
with:
2325
components: rustfmt
2426

27+
- name: Cache Rust dependencies
28+
uses: Swatinem/rust-cache@v2
29+
with:
30+
shared-key: fmt
31+
cache-on-failure: true
32+
2533
- name: Check formatting
2634
run: cargo fmt --all -- --check
2735

2836
clippy:
29-
name: Clippy
37+
name: Clippy (Backend & MCP)
3038
runs-on: ubuntu-latest
3139
steps:
3240
- uses: actions/checkout@v4
@@ -36,26 +44,44 @@ jobs:
3644
with:
3745
components: clippy
3846

39-
- name: Install GStreamer dependencies
40-
run: |
41-
sudo apt-get update
42-
sudo apt-get install -y \
43-
libgstreamer1.0-dev \
44-
libgstreamer-plugins-base1.0-dev \
45-
gstreamer1.0-plugins-base \
46-
gstreamer1.0-plugins-good \
47-
gstreamer1.0-plugins-bad \
48-
gstreamer1.0-plugins-ugly \
49-
gstreamer1.0-libav \
50-
gstreamer1.0-tools
47+
- name: Cache apt packages
48+
uses: awalsh128/cache-apt-pkgs-action@v1
49+
with:
50+
packages: libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools
51+
version: 1.0
5152

5253
- name: Cache Rust dependencies
5354
uses: Swatinem/rust-cache@v2
5455
with:
56+
shared-key: clippy-backend
5557
cache-on-failure: true
5658

57-
- name: Run Clippy
58-
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
59+
- name: Run Clippy on backend
60+
run: cargo clippy --package strom-backend --all-targets --all-features -- -D warnings
61+
62+
- name: Run Clippy on MCP server
63+
run: cargo clippy --package strom-mcp-server --all-targets --all-features -- -D warnings
64+
65+
clippy-frontend:
66+
name: Clippy (Frontend WASM)
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Install Rust stable with WASM target
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
components: clippy
75+
targets: wasm32-unknown-unknown
76+
77+
- name: Cache Rust dependencies
78+
uses: Swatinem/rust-cache@v2
79+
with:
80+
shared-key: clippy-frontend
81+
cache-on-failure: true
82+
83+
- name: Run Clippy on frontend
84+
run: cargo clippy --package strom-frontend --target wasm32-unknown-unknown --all-features -- -D warnings
5985

6086
test:
6187
name: Test Suite
@@ -66,56 +92,61 @@ jobs:
6692
- name: Install Rust stable
6793
uses: dtolnay/rust-toolchain@stable
6894

69-
- name: Install GStreamer dependencies
70-
run: |
71-
sudo apt-get update
72-
sudo apt-get install -y \
73-
libgstreamer1.0-dev \
74-
libgstreamer-plugins-base1.0-dev \
75-
gstreamer1.0-plugins-base \
76-
gstreamer1.0-plugins-good \
77-
gstreamer1.0-plugins-bad \
78-
gstreamer1.0-plugins-ugly \
79-
gstreamer1.0-libav \
80-
gstreamer1.0-tools
95+
- name: Cache apt packages
96+
uses: awalsh128/cache-apt-pkgs-action@v1
97+
with:
98+
packages: libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools
99+
version: 1.0
81100

82101
- name: Cache Rust dependencies
83102
uses: Swatinem/rust-cache@v2
84103
with:
104+
shared-key: test
85105
cache-on-failure: true
86106

87-
- name: Run tests
88-
run: cargo test --workspace --all-features
107+
- name: Run tests on backend
108+
run: cargo test --package strom-backend --all-features
109+
110+
- name: Run tests on MCP server
111+
run: cargo test --package strom-mcp-server --all-features
89112

90113
build:
91-
name: Build
114+
name: Build (Backend + Frontend + MCP)
92115
runs-on: ubuntu-latest
93116
steps:
94117
- uses: actions/checkout@v4
95118

96-
- name: Install Rust stable
119+
- name: Install Rust stable with WASM target
97120
uses: dtolnay/rust-toolchain@stable
121+
with:
122+
targets: wasm32-unknown-unknown
98123

99-
- name: Install GStreamer dependencies
124+
- name: Cache apt packages
125+
uses: awalsh128/cache-apt-pkgs-action@v1
126+
with:
127+
packages: libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools
128+
version: 1.0
129+
130+
- name: Cache trunk binary
131+
id: cache-trunk
132+
uses: actions/cache@v4
133+
with:
134+
path: ~/.cargo/bin/trunk
135+
key: trunk-${{ env.TRUNK_VERSION }}-${{ runner.os }}
136+
137+
- name: Install trunk
138+
if: steps.cache-trunk.outputs.cache-hit != 'true'
100139
run: |
101-
sudo apt-get update
102-
sudo apt-get install -y \
103-
libgstreamer1.0-dev \
104-
libgstreamer-plugins-base1.0-dev \
105-
gstreamer1.0-plugins-base \
106-
gstreamer1.0-plugins-good \
107-
gstreamer1.0-plugins-bad \
108-
gstreamer1.0-plugins-ugly \
109-
gstreamer1.0-libav \
110-
gstreamer1.0-tools
111-
112-
- name: Install trunk for frontend build
113-
run: cargo install trunk
140+
wget -qO- https://github.com/trunk-rs/trunk/releases/download/v${{ env.TRUNK_VERSION }}/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- -C ~/.cargo/bin
114141
115142
- name: Cache Rust dependencies
116143
uses: Swatinem/rust-cache@v2
117144
with:
145+
shared-key: build
118146
cache-on-failure: true
147+
# Cache trunk build artifacts
148+
cache-directories: |
149+
frontend/dist
119150
120151
- name: Build frontend
121152
run: |
@@ -125,28 +156,19 @@ jobs:
125156
- name: Build backend (with embedded frontend)
126157
run: cargo build --release --package strom-backend
127158

159+
- name: Build MCP server
160+
run: cargo build --release --package strom-mcp-server
161+
128162
- name: Upload backend binary
129163
uses: actions/upload-artifact@v4
130164
with:
131165
name: strom-backend
132166
path: target/release/strom-backend
133167
retention-days: 7
134168

135-
docker:
136-
name: Docker Build
137-
runs-on: ubuntu-latest
138-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
139-
steps:
140-
- uses: actions/checkout@v4
141-
142-
- name: Set up Docker Buildx
143-
uses: docker/setup-buildx-action@v3
144-
145-
- name: Build Docker image
146-
uses: docker/build-push-action@v5
169+
- name: Upload MCP server binary
170+
uses: actions/upload-artifact@v4
147171
with:
148-
context: .
149-
push: false
150-
tags: strom:latest
151-
cache-from: type=gha
152-
cache-to: type=gha,mode=max
172+
name: strom-mcp-server
173+
path: target/release/strom-mcp-server
174+
retention-days: 7
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
REGISTRY: docker.io
9+
IMAGE_NAME: ${{ secrets.HUB_DOCKER_USERNAME }}/strom
10+
11+
jobs:
12+
docker-publish:
13+
name: Build and Push to Docker Hub
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
username: ${{ secrets.HUB_DOCKER_USERNAME }}
29+
password: ${{ secrets.HUB_DOCKER_PASSWORD }}
30+
31+
- name: Extract metadata (tags, labels)
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ${{ env.IMAGE_NAME }}
36+
tags: |
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=semver,pattern={{major}}
40+
type=raw,value=latest,enable={{is_default_branch}}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
platforms: linux/amd64

0 commit comments

Comments
 (0)