11
11
COMPOSE_BAKE_ARGS : " --build-arg PIP_NO_CACHE_DIR=1"
12
12
CHROME_BIN : chromium-browser
13
13
DISPLAY : :99.0
14
- PYTHON_VERSION : ' 3.9'
14
+ PYTHON_VERSION : ' 3.9.21 '
15
15
AWSCLI_VERSION : ' 1.18.66'
16
16
REGISTRY : ${{ secrets.DOCKER_USERNAME }}
17
17
IMAGE_TAG : ${{ github.sha }}
38
38
39
39
- name : Install dependencies and configure system
40
40
run : |
41
+ pip install --upgrade pip
41
42
pip install awscli==${{ env.AWSCLI_VERSION }}
42
43
sudo rm -f /etc/boto.cfg
43
44
mkdir -p $HOME/.config/pip
@@ -48,17 +49,17 @@ jobs:
48
49
49
50
- name : Run code quality checks
50
51
run : |
51
- docker compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c "
52
- echo 'Installing linting tools ...' &&
52
+ docker compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c "
53
+ echo 'Installing black, flake8, pylint and isort ...' &&
53
54
pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 &&
54
55
echo 'Running black check...' &&
55
- black --check --diff ./ &&
56
+ black --check --diff ./ || { echo 'Black check failed!'; exit 1; } &&
56
57
echo 'Running isort check...' &&
57
- isort --check-only --diff --profile=black ./ &&
58
+ isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; exit 1; } &&
58
59
echo 'Running flake8 check...' &&
59
- flake8 --config=.flake8 ./ &&
60
+ flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; exit 1; } &&
60
61
echo 'Running pylint check...' &&
61
- pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ &&
62
+ pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; exit 1; } &&
62
63
echo 'All code quality checks passed!'"
63
64
64
65
- name : Django Migration Check
69
70
build-and-push :
70
71
name : Build & Push Docker Images
71
72
runs-on : ubuntu-latest
73
+ # REMOVED: No dependencies - runs in parallel
72
74
outputs :
73
75
image-digest : ${{ steps.build.outputs.digest }}
74
76
steps :
91
93
${{ runner.os }}-buildx-
92
94
93
95
- name : Docker login
96
+ if : github.event_name == 'push'
94
97
uses : docker/login-action@v3
95
98
with :
96
99
username : ${{ secrets.DOCKER_USERNAME }}
@@ -99,29 +102,19 @@ jobs:
99
102
- name : Build and push Docker images
100
103
id : build
101
104
run : |
102
- # Build and push images with unique tags
103
- docker buildx build \
104
- --cache-from type=local,src=/tmp/.buildx-cache \
105
- --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \
106
- --push \
107
- --tag ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} \
108
- --tag ${{ env.REGISTRY }}/evalai:latest \
109
- .
110
-
111
- # Build compose services and push
112
105
export COMPOSE_DOCKER_CLI_BUILD=1
113
106
export DOCKER_BUILDKIT=1
114
107
115
108
docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }}
116
- docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd push
117
109
118
- # Clean up cache
119
- rm -rf /tmp/.buildx-cache
120
- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
110
+ if [ "${{ github.event_name }}" = "push" ]; then
111
+ docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd push
112
+ fi
121
113
122
114
test :
123
115
name : Run Tests
124
116
runs-on : ubuntu-latest
117
+ # REMOVED: No dependencies - runs in parallel with build
125
118
strategy :
126
119
matrix :
127
120
test-type : [frontend, backend]
@@ -140,20 +133,14 @@ jobs:
140
133
with :
141
134
version : latest
142
135
143
- - name : Docker login
144
- uses : docker/login-action@v3
145
- with :
146
- username : ${{ secrets.DOCKER_USERNAME }}
147
- password : ${{ secrets.DOCKER_PASSWORD }}
148
-
149
136
- name : Install test dependencies
150
- run : pip install awscli==${{ env.AWSCLI_VERSION }} coveralls
137
+ run : |
138
+ pip install --upgrade pip
139
+ pip install awscli==${{ env.AWSCLI_VERSION }} coveralls
151
140
152
- - name : Pull Docker images
141
+ - name : Build images for testing (if not available)
153
142
run : |
154
- # Pull the latest images (they might be building in parallel)
155
- timeout 300 bash -c 'until docker pull ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} 2>/dev/null; do echo "Waiting for image..."; sleep 10; done'
156
- docker compose pull
143
+ docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }}
157
144
158
145
- name : Setup display for frontend tests
159
146
if : matrix.test-type == 'frontend'
@@ -175,22 +162,21 @@ jobs:
175
162
176
163
- name : Upload coverage to Codecov
177
164
if : matrix.test-type == 'backend'
178
- uses : codecov/codecov-action@v3
179
- with :
180
- fail_ci_if_error : false
165
+ run : |
166
+ bash <(curl -s https://codecov.io/bash)
181
167
182
168
- name : Upload coverage to Coveralls
183
169
if : matrix.test-type == 'backend'
184
170
continue-on-error : true
185
171
env :
186
172
COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_REPO_TOKEN }}
187
173
run : |
188
- coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, continuing..."
174
+ coveralls --rcfile=.coveragerc
189
175
190
176
deploy :
191
- name : Deploy & Notify
177
+ name : Package & Deploy Services
192
178
runs-on : ubuntu-latest
193
- needs : [build-and-push, test, quality-check]
179
+ needs : [build-and-push, test, quality-check] # Waits for ALL jobs to complete
194
180
if : github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
195
181
environment : production
196
182
steps :
@@ -203,10 +189,13 @@ jobs:
203
189
cache : ' pip'
204
190
205
191
- name : Install deployment dependencies
206
- run : pip install awscli==${{ env.AWSCLI_VERSION }}
192
+ run : |
193
+ pip install --upgrade pip
194
+ pip install awscli==${{ env.AWSCLI_VERSION }}
207
195
208
- - name : Configure SSH
196
+ - name : Configure SSH and decrypt keys
209
197
run : |
198
+ eval "$(ssh-agent -s)"
210
199
mkdir -p ~/.ssh
211
200
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
212
201
chmod 600 ~/.ssh/deploy_key
@@ -215,11 +204,14 @@ jobs:
215
204
216
205
- name : Deploy services
217
206
run : |
218
- eval "$(ssh-agent -s)"
219
207
ssh-add ~/.ssh/deploy_key
220
208
./scripts/deployment/push.sh
221
209
./scripts/deployment/deploy.sh auto_deploy
222
210
211
+ - name : Clean up pip cache
212
+ run : |
213
+ rm -f $HOME/.cache/pip/log/debug.log
214
+
223
215
- name : Notify on failure
224
216
if : failure()
225
217
uses : 8398a7/action-slack@v3
0 commit comments