-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (132 loc) · 4.65 KB
/
Copy pathci.yml
File metadata and controls
151 lines (132 loc) · 4.65 KB
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
name: CI
on:
pull_request:
push:
branches: [main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
actions: write
packages: write
env:
# GHCR requires lowercase owner/image names.
REGISTRY: ghcr.io
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# Lint-only install: do not pip install the project (would pull torch/HF).
- name: Install Ruff
run: pip install "ruff>=0.1"
- name: Ruff check
run: make lint
test:
name: Unit tests
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# Slim install: unit tests must not need torch/transformers/streamlit.
- name: Install test dependencies
run: pip install "pytest>=7.0" "pydantic>=2.0" "pyyaml>=6.0" "numpy>=1.24"
- name: Run unit tests
run: make test
# Phase 1C/2: build all product images; push to GHCR only on main.
build-images:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
include:
- name: embedding-api
dockerfile: docker/docker_embedding/Dockerfile.embedding-api
image: proseqgo-embedding-api
build_args: TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu
- name: go-prediction-api
dockerfile: docker/docker_go_term/Dockerfile.api
image: proseqgo-go-prediction-api
build_args: TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu
- name: streamlit-ui
dockerfile: docker/docker_streamlit/Dockerfile.streamlit
image: proseqgo-streamlit-ui
build_args: ""
- name: trainer-api
dockerfile: docker/docker_training/Dockerfile.training
image: proseqgo-trainer-api
build_args: TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu
- name: mlflow
dockerfile: docker/docker_mlflow/Dockerfile
image: proseqgo-mlflow
build_args: ""
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/graalvm \
/usr/local/.ghcup || true
df -h
- name: Set image name and push flag
id: meta
run: |
owner="$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')"
echo "image=${{ env.REGISTRY }}/${owner}/${{ matrix.image }}" >> "$GITHUB_OUTPUT"
if [ '${{ github.event_name }}' = 'push' ] && [ '${{ github.ref }}' = 'refs/heads/main' ]; then
echo "push=true" >> "$GITHUB_OUTPUT"
else
echo "push=false" >> "$GITHUB_OUTPUT"
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: steps.meta.outputs.push == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# PR / non-main: prove the image builds; do not push.
- name: Build image (no push)
if: steps.meta.outputs.push != 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: false
outputs: type=cacheonly
tags: ${{ steps.meta.outputs.image }}:sha-${{ github.sha }}
build-args: ${{ matrix.build_args }}
cache-from: type=gha,scope=build-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }}
# main: publish immutable sha tag + moving main tag.
- name: Build and push image
if: steps.meta.outputs.push == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
${{ steps.meta.outputs.image }}:sha-${{ github.sha }}
${{ steps.meta.outputs.image }}:main
build-args: ${{ matrix.build_args }}
cache-from: type=gha,scope=build-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }}
provenance: false