-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (150 loc) · 4.61 KB
/
test.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
name: "Test"
on:
push:
branches:
- "main"
paths:
# Always run when workflow configs change
- ".github/workflows/**"
# Run when package changes
- "**"
release:
types: [published]
pull_request:
branches:
- "main"
paths:
# Always run when workflow configs change
- ".github/workflows/**"
# Run when package changes
- "**"
workflow_dispatch: {}
jobs:
test_parser:
runs-on: large
permissions:
contents: read
id-token: write
needs:
- build_api_cpu
- build_api_gpu
strategy:
matrix:
python-version:
- 3.9
env:
COMPOSE_FILE: docker-compose.gha.yaml
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
steps:
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github
service_account: [email protected]
- uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- id: meta
uses: docker/metadata-action@v5
- run: |
echo "Pulling ${DOCKER_METADATA_OUTPUT_VERSION}"
docker compose up --detach --no-build
- uses: actions/setup-python@v4
id: setup_python
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
parser/poetry.lock
- name: Install dependencies (tests)
run: |
pip install pytest pytest-mock
pip install -e sdk
- name: Install dependencies (parser)
working-directory: parser
run: |
sudo apt update && sudo apt upgrade -y
sudo apt install -y libmagic-dev poppler-utils tesseract-ocr libxext6 pandoc libreoffice
pip install -e .
- name: Cache nltk files
uses: actions/cache@v4
with:
path: /usr/share/nltk_data
key: ${{ runner.os }}-nltk-${{ hashFiles('parser/poetry.lock') }}
restore-keys: |
${{ runner.os }}-nltk-
- name: Download nltk files
run: |
python -m nltk.downloader punkt --dir /usr/share/nltk_data
- name: Run tests (parser)
working-directory: parser
run: |
pytest -sv tests
build_api_gpu:
runs-on: large
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-and-push-docker
with:
service: compass_parser/api_gpu
context: parser_api
build_contexts: compass_parser=./parser
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github
service_account: [email protected]
file: parser_api/gpu.Dockerfile
build_api_cpu:
runs-on: large
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-and-push-docker
with:
service: compass_parser/api
context: parser_api
build_contexts: compass_parser=./parser
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github
service_account: [email protected]
file: parser_api/cpu.Dockerfile
test_client:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
matrix:
python-version:
- 3.9
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
id: setup_python
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
poetry.lock
- name: Install dependencies (tests)
run: |
pip install pytest pytest-asyncio pytest-mock requests-mock
- name: Install dependencies
working-directory: sdk
run: |
pip install -e .
- name: Run tests
working-directory: sdk
run: |
echo $COHERE_API_KEY
pytest -sv tests/test_compass_client.py