Skip to content

Commit 8e2b47a

Browse files
authored
ci: add GitHub Actions workflow for E2E testing (#255)
Add a new GitHub Actions workflow to automate end-to-end testing on push, pull requests, scheduled runs, and manual triggers. The workflow includes jobs to build the modctl binary, download the specified model from Hugging Face, and run tests using modctl. This setup improves CI coverage by caching dependencies and artifacts, ensuring efficient builds and reliable testing of the modctl tool with the Qwen model. Signed-off-by: Peng Tao <[email protected]>
1 parent c5f6f4e commit 8e2b47a

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: E2E Test
2+
3+
on:
4+
push:
5+
branches: [main, release-*]
6+
paths-ignore: ["**.md", "**.png", "**.jpg", "**.svg", "**/docs/**"]
7+
pull_request:
8+
branches: [main, release-*]
9+
paths-ignore: ["**.md", "**.png", "**.jpg", "**.svg", "**/docs/**"]
10+
schedule:
11+
- cron: "0 1 * * *"
12+
workflow_dispatch:
13+
inputs:
14+
model:
15+
description: "Model to test"
16+
required: false
17+
default: "Qwen/Qwen3-0.6B"
18+
type: string
19+
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
env:
25+
REGISTRY: ghcr.io
26+
ORGANIZATION: ${{ github.repository_owner }}
27+
MODEL: ${{ github.event.inputs.model || 'Qwen/Qwen3-0.6B' }}
28+
MODEL_DIR: modctl-test-model
29+
30+
jobs:
31+
build-modctl:
32+
name: Build modctl
33+
timeout-minutes: 60
34+
runs-on: ubuntu-latest
35+
env:
36+
PACKAGE_DIR: modctl-test-package
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
with:
41+
submodules: recursive
42+
43+
- name: Install Go
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version-file: go.mod
47+
cache-dependency-path: go.sum
48+
49+
- name: Create Cache Dir
50+
run: |
51+
mkdir -p ${{ env.PACKAGE_DIR }}
52+
53+
- name: Cache Package
54+
id: cache-package
55+
uses: actions/cache@v4
56+
with:
57+
path: ${{ env.PACKAGE_DIR }}
58+
key: modctl-test-packages
59+
60+
- name: Install dependencies
61+
run: |
62+
sudo apt-get update
63+
sudo apt-get install -y pkg-config
64+
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential \
65+
cmake pkg-config libssl-dev libssh2-1-dev zlib1g-dev \
66+
libhttp-parser-dev python3 wget tar git
67+
mkdir -p ${{ env.PACKAGE_DIR }}
68+
if [ ! -f "${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz" ]; then
69+
wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.5.1.tar.gz -O ${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz
70+
fi
71+
tar -xzf ${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz
72+
cd libgit2-1.5.1 && mkdir build && cd build
73+
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
74+
make -j$(nproc)
75+
sudo make install
76+
sudo ldconfig
77+
env:
78+
LIBGIT2_SYS_USE_PKG_CONFIG: "1"
79+
80+
- name: Build modctl
81+
run: |
82+
go build -tags "static system_libgit2 enable_libgit2"
83+
84+
- name: Upload modctl
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: modctl-artifact
88+
path: modctl
89+
90+
download-model:
91+
name: Download Model
92+
timeout-minutes: 60
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Cache model
96+
uses: actions/cache@v4
97+
id: cache-model
98+
with:
99+
path: ${{ env.MODEL_DIR }}
100+
key: ${{env.MODEL_DIR}}-${{ env.MODEL }}
101+
102+
- name: Set up Python
103+
if: steps.cache-model.outputs.cache-hit != 'true'
104+
uses: actions/setup-python@v4
105+
with:
106+
python-version: "3.10"
107+
108+
- name: Download HF Model
109+
if: steps.cache-model.outputs.cache-hit != 'true'
110+
run: |
111+
pip install 'huggingface_hub'
112+
hf auth login --token ${{ secrets.HF_TOKEN }}
113+
hf download ${{ env.MODEL }} --local-dir ${{ env.MODEL_DIR }}
114+
115+
- name: Upload model
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: model-artifact
119+
path: ${{ env.MODEL_DIR }}
120+
121+
test-modctl:
122+
name: Run modctl test
123+
timeout-minutes: 60
124+
runs-on: ubuntu-latest
125+
needs: [build-modctl, download-model]
126+
steps:
127+
- name: Download modctl artifact
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: modctl-artifact
131+
path: modctl
132+
- name: Download model artifact
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: model-artifact
136+
path: ${{ env.MODEL_DIR }}
137+
138+
- name: Setup modctl
139+
run: |
140+
echo "Setting up modctl"
141+
sudo cp modctl/modctl /bin/modctl
142+
sudo chmod +x /bin/modctl
143+
modctl version
144+
modctl login -u ${{ github.actor }} \
145+
-p ${{ secrets.GITHUB_TOKEN }} \
146+
${{ env.REGISTRY }}
147+
148+
- name: Test modctl E2E
149+
run: |
150+
echo "generating modelfile for ${{ env.MODEL_DIR }}"
151+
modctl modelfile generate \
152+
--arch transformer \
153+
--family qwen3 \
154+
--format safetensors \
155+
--param-size 0.6B \
156+
.
157+
echo "modelfile generated"
158+
url=${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.MODEL }}:latest
159+
url_lower=$(echo "${url,,}")
160+
echo "Building and pushing model to $url_lower"
161+
modctl build -f Modelfile \
162+
-t $url_lower \
163+
--raw --output-remote --log-level debug \
164+
.
165+
echo "build/push completed"
166+
mkdir download
167+
echo "Pulling model from $url_lower"
168+
modctl pull $url_lower \
169+
--extract-dir download \
170+
--log-level debug
171+
echo "pull completed"

0 commit comments

Comments
 (0)