-
-
Notifications
You must be signed in to change notification settings - Fork 203
188 lines (173 loc) · 5.22 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Build
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
jobs:
build:
name: Test ${{ matrix.os }} with `${{ matrix.extras }}` on ${{ matrix.model }}
runs-on: ${{ matrix.os }}
env:
RELEASE: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python_version: ['3.10']
extras: ['-E all']
model: ['openai/gpt-4o-mini', 'anthropic/claude-3-haiku-20240307']
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install apt dependencies
run: sudo apt-get install universal-ctags pandoc tmux
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install ${{ matrix.extras }}
- name: Install playwright
if: contains(matrix.extras, 'browser') || contains(matrix.extras, 'all')
run: poetry run playwright install chromium
# old comment: OpenAI sometimes randomly aborts connections
- name: Run tests
uses: nick-fields/retry@v2
env:
TERM: xterm
MODEL: ${{ matrix.model }}
with:
timeout_minutes: 5
max_attempts: 1 # favor pytest retries (mark with flaky)
retry_wait_seconds: 10
command: make test SLOW=true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
MODEL: ${{ matrix.model }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: MODEL
flags: ${{ matrix.model }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
build-docker:
runs-on: ubuntu-latest
env:
SHOULD_PUSH: ${{ github.ref == 'refs/tags/v*' || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: env.SHOULD_PUSH == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment variables
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
# Sanitize the ref name to be used as a Docker tag
SANITIZED_REF_NAME=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
echo "SANITIZED_REF_NAME=${SANITIZED_REF_NAME}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
# First build the base image locally (needed for subsequent builds)
- name: Build Docker image (base)
uses: docker/build-push-action@v3
with:
tags: gptme:latest
file: ./scripts/Dockerfile
context: .
push: false
# Push base image to registry if on master/tag
- name: Push Docker image (base)
uses: docker/build-push-action@v3
if: env.SHOULD_PUSH == 'true'
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme:latest
ghcr.io/${{ env.OWNER_LC }}/gptme:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile
context: .
push: true
# Build and push eval image
- name: Build and push Docker image (eval)
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:latest
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile.eval
context: .
push: ${{ env.SHOULD_PUSH }}
# Now the full eval image
# NOTE: takes a long time and leads to a big (1GB+) image
#- name: Build and push Docker image (eval-full)
# uses: docker/build-push-action@v3
# with:
# tags: |
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:latest
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:${{ env.SANITIZED_REF_NAME }}
# file: ./scripts/Dockerfile.eval
# context: .
# push: true
# build-args: |
# RUST=yes
# BROWSER=yes
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install
- name: Check for lint
run: |
make lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install -E server -E browser
- name: Typecheck
run: |
make typecheck