Skip to content

Commit 1658aa6

Browse files
authored
Run tests in ci (#70)
* Run tests in CI * Split ci and release workflows
1 parent 1e92504 commit 1658aa6

File tree

3 files changed

+114
-71
lines changed

3 files changed

+114
-71
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,26 @@
1-
name: Release model-runner images for CE
2-
run-name: Release model-runner images for CE, version ${{ inputs.releaseTag }}
1+
name: CI
32

43
on:
5-
workflow_dispatch:
6-
inputs:
7-
pushLatest:
8-
description: 'Tag images produced by this job as latest'
9-
required: false
10-
type: boolean
11-
default: false
12-
releaseTag:
13-
description: 'Release tag'
14-
required: false
15-
type: string
16-
default: "test"
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
178

189
jobs:
19-
build:
10+
test:
2011
runs-on: ubuntu-latest
2112
steps:
22-
- name: Checkout repo
13+
- name: Checkout code
2314
uses: actions/checkout@v4
2415

25-
- name: Format tags
26-
id: tags
27-
shell: bash
28-
run: |
29-
echo "cpu<<EOF" >> "$GITHUB_OUTPUT"
30-
echo "docker/model-runner:${{ inputs.releaseTag }}" >> "$GITHUB_OUTPUT"
31-
if [ "${{ inputs.pushLatest }}" == "true" ]; then
32-
echo "docker/model-runner:latest" >> "$GITHUB_OUTPUT"
33-
fi
34-
echo 'EOF' >> "$GITHUB_OUTPUT"
35-
echo "cuda<<EOF" >> "$GITHUB_OUTPUT"
36-
echo "docker/model-runner:${{ inputs.releaseTag }}-cuda" >> "$GITHUB_OUTPUT"
37-
if [ "${{ inputs.pushLatest }}" == "true" ]; then
38-
echo "docker/model-runner:latest-cuda" >> "$GITHUB_OUTPUT"
39-
fi
40-
echo 'EOF' >> "$GITHUB_OUTPUT"
41-
42-
- name: Log in to DockerHub
43-
uses: docker/login-action@v3
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
4418
with:
45-
username: "docker"
46-
password: ${{ secrets.ORG_ACCESS_TOKEN }}
19+
go-version: 1.24.2
20+
cache: true
4721

48-
- name: Set up Buildx
49-
uses: docker/setup-buildx-action@v3
50-
with:
51-
version: "lab:latest"
52-
driver: cloud
53-
endpoint: "docker/make-product-smarter"
54-
install: true
22+
- name: Run tests
23+
run: go test -v ./...
5524

56-
- name: Build CPU image
57-
uses: docker/build-push-action@v5
58-
with:
59-
file: Dockerfile
60-
platforms: linux/amd64, linux/arm64
61-
build-args: |
62-
"LLAMA_SERVER_VERSION=latest"
63-
push: true
64-
sbom: true
65-
provenance: mode=max
66-
tags: ${{ steps.tags.outputs.cpu }}
67-
68-
- name: Build CUDA image
69-
uses: docker/build-push-action@v5
70-
with:
71-
file: Dockerfile
72-
platforms: linux/amd64, linux/arm64
73-
build-args: |
74-
"LLAMA_SERVER_VERSION=latest"
75-
"LLAMA_SERVER_VARIANT=cuda"
76-
"BASE_IMAGE=nvidia/cuda:12.9.0-cudnn-runtime-ubuntu24.04"
77-
push: true
78-
sbom: true
79-
provenance: mode=max
80-
tags: ${{ steps.tags.outputs.cuda }}
25+
- name: Run tests with race detection
26+
run: go test -race ./...

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release model-runner images for CE
2+
run-name: Release model-runner images for CE, version ${{ inputs.releaseTag }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
pushLatest:
8+
description: 'Tag images produced by this job as latest'
9+
required: false
10+
type: boolean
11+
default: false
12+
releaseTag:
13+
description: 'Release tag'
14+
required: false
15+
type: string
16+
default: "test"
17+
18+
jobs:
19+
test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: 1.24.2
29+
cache: true
30+
31+
- name: Run tests
32+
run: go test ./...
33+
34+
build:
35+
needs: test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout repo
39+
uses: actions/checkout@v4
40+
41+
- name: Format tags
42+
id: tags
43+
shell: bash
44+
run: |
45+
echo "cpu<<EOF" >> "$GITHUB_OUTPUT"
46+
echo "docker/model-runner:${{ inputs.releaseTag }}" >> "$GITHUB_OUTPUT"
47+
if [ "${{ inputs.pushLatest }}" == "true" ]; then
48+
echo "docker/model-runner:latest" >> "$GITHUB_OUTPUT"
49+
fi
50+
echo 'EOF' >> "$GITHUB_OUTPUT"
51+
echo "cuda<<EOF" >> "$GITHUB_OUTPUT"
52+
echo "docker/model-runner:${{ inputs.releaseTag }}-cuda" >> "$GITHUB_OUTPUT"
53+
if [ "${{ inputs.pushLatest }}" == "true" ]; then
54+
echo "docker/model-runner:latest-cuda" >> "$GITHUB_OUTPUT"
55+
fi
56+
echo 'EOF' >> "$GITHUB_OUTPUT"
57+
58+
- name: Log in to DockerHub
59+
uses: docker/login-action@v3
60+
with:
61+
username: "docker"
62+
password: ${{ secrets.ORG_ACCESS_TOKEN }}
63+
64+
- name: Set up Buildx
65+
uses: docker/setup-buildx-action@v3
66+
with:
67+
version: "lab:latest"
68+
driver: cloud
69+
endpoint: "docker/make-product-smarter"
70+
install: true
71+
72+
- name: Build CPU image
73+
uses: docker/build-push-action@v5
74+
with:
75+
file: Dockerfile
76+
platforms: linux/amd64, linux/arm64
77+
build-args: |
78+
"LLAMA_SERVER_VERSION=latest"
79+
push: true
80+
sbom: true
81+
provenance: mode=max
82+
tags: ${{ steps.tags.outputs.cpu }}
83+
84+
- name: Build CUDA image
85+
uses: docker/build-push-action@v5
86+
with:
87+
file: Dockerfile
88+
platforms: linux/amd64, linux/arm64
89+
build-args: |
90+
"LLAMA_SERVER_VERSION=latest"
91+
"LLAMA_SERVER_VARIANT=cuda"
92+
"BASE_IMAGE=nvidia/cuda:12.9.0-cudnn-runtime-ubuntu24.04"
93+
push: true
94+
sbom: true
95+
provenance: mode=max
96+
tags: ${{ steps.tags.outputs.cuda }}

pkg/inference/models/manager_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package models
22

33
import (
44
"context"
5-
"github.com/google/go-containerregistry/pkg/registry"
65
"net/http/httptest"
76
"net/url"
87
"os"
98
"path/filepath"
109
"strings"
1110
"testing"
1211

12+
"github.com/google/go-containerregistry/pkg/registry"
13+
1314
"github.com/docker/model-distribution/builder"
1415
reg "github.com/docker/model-distribution/registry"
1516

@@ -108,7 +109,7 @@ func TestPullModel(t *testing.T) {
108109
m := NewManager(log, ClientConfig{
109110
StoreRootPath: tempDir,
110111
Logger: log.WithFields(logrus.Fields{"component": "model-manager"}),
111-
})
112+
}, nil)
112113

113114
r := httptest.NewRequest("POST", "/models/create", strings.NewReader(`{"from": "`+tag+`"}`))
114115
if tt.acceptHeader != "" {

0 commit comments

Comments
 (0)