forked from stacklok/codegate
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (137 loc) · 5.4 KB
/
integration-tests.yml
File metadata and controls
161 lines (137 loc) · 5.4 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
152
153
154
155
156
157
158
159
160
161
# This workflow will run the integration tests for the project
name: Tests - Integration
on:
workflow_call:
inputs:
artifact-name:
description: 'The name of the artifact to download'
required: true
type: string
secrets:
copilot-key:
description: 'The Copilot key to use for integration tests'
required: true
anthropic-key:
description: 'The Anthropic key to use for integration tests'
required: true
jobs:
integration-tests:
name: Run
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12" ]
env:
CONTAINER_NAME: "codegate"
CERT_FILE: "/app/codegate_volume/certs/ca.crt"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
lfs: true
- name: Checkout LFS objects
run: git lfs pull
- name: Ensure file permissions for mounted volume
run: |
mkdir -p ./codegate_volume/certs ./codegate_volume/models ./codegate_volume/db
chmod -R 777 ./codegate_volume
- name: Download Docker image artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: ${{ inputs.artifact-name }}
- name: Load Docker image
run: |
docker load -i image.tar
echo "Loaded image:"
docker images
- name: Run container from the loaded image
run: |
# Get the image name
DOCKER_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
echo "Running container from image: $DOCKER_IMAGE"
# Run the container
docker run --name $CONTAINER_NAME -d -p 8989:8989 -p 9090:9090 \
-p 8990:8990 \
-v "$(pwd)"/codegate_volume:/app/codegate_volume \
-e CODEGATE_APP_LOG_LEVEL=DEBUG \
--restart unless-stopped $DOCKER_IMAGE
# Confirm the container started
echo "Container started:"
docker ps
# Verify container is running with correct ports
docker ps -f name=$CONTAINER_NAME
# Check mount configuration
docker inspect $CONTAINER_NAME -f '{{ json .Mounts }}' | jq
- name: Ensure certificates are available in the container
timeout-minutes: 4
run: |
# Wait for the cert file to be available in the container
while true; do
echo "Checking for $CERT_FILE in container $CONTAINER_NAME..."
if docker exec "$CONTAINER_NAME" test -f "$CERT_FILE"; then
echo "Cert file found: $CERT_FILE"
break
else
echo "Cert file not found. Retrying in 5 seconds..."
sleep 5
fi
done
# Verify volume contents are accessible
docker exec $CONTAINER_NAME ls -la /app/codegate_volume
# Print the container logs we got so far
docker logs $CONTAINER_NAME
- name: Install the CodeGate certificate
run: |
docker cp codegate:/app/codegate_volume/certs/ca.crt ./codegate.crt
sudo cp ./codegate.crt /usr/local/share/ca-certificates/codegate.crt
sudo update-ca-certificates
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1
with:
version: 2.0.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --with dev
- name: Run integration tests - Copilot
env:
CODEGATE_PROVIDERS: "copilot"
CA_CERT_FILE: "/home/runner/work/codegate/codegate/codegate_volume/certs/ca.crt"
ENV_COPILOT_KEY: ${{ secrets.copilot-key }}
run: |
poetry run python tests/integration/integration_tests.py
- name: Run integration tests - OpenAI
env:
CODEGATE_PROVIDERS: "openai"
ENV_OPENAI_KEY: ${{ secrets.copilot-key }} # We use the same key for OpenAI as the Copilot tests
run: |
poetry run python tests/integration/integration_tests.py
- name: Run integration tests - Anthropic
env:
CODEGATE_PROVIDERS: "anthropic"
ENV_ANTHROPIC_KEY: ${{ secrets.anthropic-key }}
run: |
poetry run python tests/integration/integration_tests.py
- name: Print the container logs (useful for debugging)
if: always()
run: |
docker logs $CONTAINER_NAME
echo "Models contents:"
ls -la codegate_volume/models
docker exec $CONTAINER_NAME ls -la /app/codegate_volume/models
echo "Certs contents:"
ls -la codegate_volume/certs
docker exec $CONTAINER_NAME ls -la /app/codegate_volume/certs
echo "DB contents:"
ls -la codegate_volume/db
docker exec $CONTAINER_NAME ls -la /app/codegate_volume/db