Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/agent-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2025 RAIDS Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Agent Build

on:
push:
branches: [main]
paths:
- "crater-agent/**"
- ".github/workflows/agent-build.yml"
tags:
- "v*.*.*"

env:
REGISTRY: ghcr.io
REPOSITORY: raids-lab
IMAGE_NAME: crater-agent

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha

- name: Build and push multi-platform image
uses: docker/build-push-action@v6
with:
context: ./crater-agent
file: ./crater-agent/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

- uses: quartx-analytics/ghcr-cleaner@v1
with:
owner-type: org
token: ${{ secrets.PAT_TOKEN }}
repository-owner: ${{ github.repository_owner }}
package-name: ${{ env.IMAGE_NAME }}
delete-untagged: true
keep-at-most: 2
skip-tags: v*
42 changes: 42 additions & 0 deletions .github/workflows/agent-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2025 RAIDS Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Agent PR Check

on:
pull_request:
branches: [main]
paths:
- "crater-agent/**"
- ".github/workflows/agent-pr.yml"

jobs:
agent-build-check:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build agent image
uses: docker/build-push-action@v6
with:
context: ./crater-agent
file: ./crater-agent/Dockerfile
push: false
tags: crater-agent:pr-check
1 change: 0 additions & 1 deletion .github/workflows/backend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jobs:
mkdir -p bin/${{ matrix.platform.image_platform }}
go build -ldflags="-X main.AppVersion=${{ steps.set-version.outputs.app_version }} -X main.CommitSHA=${{ steps.set-version.outputs.commit_sha }} -X main.BuildType=${{ steps.set-version.outputs.build_type }} -X main.BuildTime=${{ steps.set-version.outputs.build_time }} -w -s" -o bin/${{ matrix.platform.image_platform }}/migrate cmd/gorm-gen/models/migrate.go
go build -ldflags="-X main.AppVersion=${{ steps.set-version.outputs.app_version }} -X main.CommitSHA=${{ steps.set-version.outputs.commit_sha }} -X main.BuildType=${{ steps.set-version.outputs.build_type }} -X main.BuildTime=${{ steps.set-version.outputs.build_time }} -w -s" -o bin/${{ matrix.platform.image_platform }}/controller cmd/crater/main.go
go build -ldflags="-w -s" -o bin/${{ matrix.platform.image_platform }}/model-metadata-refresh cmd/model-metadata-refresh/main.go
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.platform.goos }}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/storage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ on:
paths:
- "backend/internal/storage/**"
- "backend/cmd/storage-server/**"
- "backend/cmd/model-dataset-governance/**"
- "backend/internal/governance/modeldataset/**"
- "backend/dao/model/**"
- "backend/dao/query/**"
- "backend/pkg/config/**"
- "backend/storage-server.Dockerfile"
- "backend/go.mod"
- "backend/go.sum"
Expand Down Expand Up @@ -134,7 +129,6 @@ jobs:
run: |
mkdir -p bin/${{ matrix.platform.image_platform }}
go build -ldflags="-X main.AppVersion=${{ steps.set-version.outputs.app_version }} -X main.CommitSHA=${{ steps.set-version.outputs.commit_sha }} -X main.BuildType=${{ steps.set-version.outputs.build_type }} -X main.BuildTime=${{ steps.set-version.outputs.build_time }} -w -s" -o bin/${{ matrix.platform.image_platform }}/storage-server cmd/storage-server/main.go
go build -ldflags="-X main.AppVersion=${{ steps.set-version.outputs.app_version }} -X main.CommitSHA=${{ steps.set-version.outputs.commit_sha }} -X main.BuildType=${{ steps.set-version.outputs.build_type }} -X main.BuildTime=${{ steps.set-version.outputs.build_time }} -w -s" -o bin/${{ matrix.platform.image_platform }}/model-dataset-governance cmd/model-dataset-governance/main.go
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.platform.goos }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dist-ssr
*.dll
*.so
*.dylib
backend/crater
bin
testbin/*
Dockerfile.cross
Expand All @@ -51,6 +52,7 @@ etc/*

# Configuration backups (created by make config-link)
*.bak
crater-agent/config/*backup*.json

# Test binary, build with `go test -c`
*.test
Expand Down Expand Up @@ -79,3 +81,5 @@ kubeconfig*

# Claude Code
.claude/
storage/etc/config.yaml
.codex
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,33 @@ config-unlink: ## Remove configuration symlinks (only symlinks, not regular file
config-restore: ## Restore configuration files from .bak backups
@bash hack/config.sh restore

##@ Development

.PHONY: run-agent
run-agent: ## Run the local Python crater-agent service.
@echo "$(GREEN)Starting crater-agent on http://localhost:8000 ...$(RESET)"
@cd crater-agent && \
if [ ! -d .venv ]; then python3.11 -m venv .venv || python3 -m venv .venv; fi && \
.venv/bin/python -m pip install -e . && \
.venv/bin/python -m uvicorn crater_agent.app:app --host 0.0.0.0 --port 8000

.PHONY: run-backend
run-backend: ## Run the local Go backend.
@$(MAKE) -C backend run

.PHONY: run-frontend
run-frontend: ## Run the local React frontend.
@$(MAKE) -C frontend run

.PHONY: run-dev
run-dev: ## Run agent, backend, and frontend together for local development.
@echo "$(GREEN)Starting crater agent, backend, and frontend. Press Ctrl-C to stop all.$(RESET)"
@set -e; \
trap 'for pid in $$(jobs -p); do kill $$pid 2>/dev/null || true; done' INT TERM EXIT; \
$(MAKE) run-agent & \
$(MAKE) run-backend & \
$(MAKE) run-frontend & \
wait

# 默认目标
.DEFAULT_GOAL := help

1 change: 0 additions & 1 deletion backend/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ build_binaries:
- go run github.com/swaggo/swag/cmd/swag@latest init
- go build -ldflags="-w -s" -o "${BIN_DIR}/migrate" cmd/gorm-gen/models/migrate.go
- go build -ldflags="-w -s" -o "${BIN_DIR}/controller" main.go
- go build -ldflags="-w -s" -o "${BIN_DIR}/model-metadata-refresh" cmd/model-metadata-refresh/main.go
artifacts:
paths:
- "${BIN_DIR}"
Expand Down
3 changes: 1 addition & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ ENV GIN_MODE=release
COPY LICENSE NOTICE /usr/share/doc/crater/
COPY $BIN_DIR/bin-${TARGETPLATFORM//\//_}/controller .
COPY $BIN_DIR/bin-${TARGETPLATFORM//\//_}/migrate .
COPY $BIN_DIR/bin-${TARGETPLATFORM//\//_}/model-metadata-refresh .
RUN chmod +x controller migrate model-metadata-refresh
RUN chmod +x controller migrate

EXPOSE 8088:8088

Expand Down
7 changes: 0 additions & 7 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ build-migrate: fmt lint ## Build migration binary.
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/migrate cmd/gorm-gen/models/migrate.go
@echo "$(GREEN)✅ Migration binary built successfully: bin/migrate$(RESET)"

.PHONY: build-model-metadata-refresh
build-model-metadata-refresh: fmt lint ## Build model metadata refresh binary.
@echo "$(YELLOW)Building model metadata refresh binary...$(RESET)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/model-metadata-refresh cmd/model-metadata-refresh/main.go
@echo "$(GREEN)Model metadata refresh binary built successfully: bin/model-metadata-refresh$(RESET)"

##@ Development Tools

## Location to install tools to
Expand Down Expand Up @@ -240,5 +234,4 @@ run-storage: prepare fmt imports ## Run storage server from backend module.
build-storage: fmt lint ## Build storage server binary.
@echo "$(YELLOW)Building storage server binary...$(RESET)"
go build -ldflags="-w -s $(VERSION_LDFLAGS)" -o bin/storage-server cmd/storage-server/main.go
go build -ldflags="-w -s $(VERSION_LDFLAGS)" -o bin/model-dataset-governance cmd/model-dataset-governance/main.go
@echo "$(GREEN)Storage server binary built successfully: bin/storage-server$(RESET)"
3 changes: 0 additions & 3 deletions backend/cmd/gorm-gen/curd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func main() {
model.User{},
model.Account{},
model.UserAccount{},
model.ModelDatasetSource{},
model.Dataset{},
model.AccountDataset{},
model.UserDataset{},
Expand All @@ -46,8 +45,6 @@ func main() {
model.CronJobRecord{},
model.CronJobConfig{},
model.ModelDownload{},
model.ModelDownloadSubmission{},
model.ModelDatasetDiscovery{},
model.UserModelDownload{},
model.GpuAnalysis{},
model.SystemConfig{},
Expand Down
Loading
Loading