Skip to content

Commit a4da4ad

Browse files
author
Obada Haddad
committed
re-enabled github workflow to replace circle-ci; add trivy image scan workflow
1 parent 4d6fa05 commit a4da4ad

File tree

3 files changed

+104
-63
lines changed

3 files changed

+104
-63
lines changed

.github/workflows/image_scan.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: scan_image_for_CVE
2+
on:
3+
push:
4+
# Every week on Monday at 00:00
5+
schedule:
6+
- cron: "0 0 * * 1"
7+
jobs:
8+
build_push_image:
9+
name: Build Docker Image then Push it to Docker.io
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Run Trivy vulnerability scanner
13+
uses: aquasecurity/trivy-action@0.33.1
14+
with:
15+
image-ref: 'codalab/codabench-compute-worker:latest'
16+
format: 'table'
17+
exit-code: '1'
18+
ignore-unfixed: true
19+
vuln-type: 'os,library'
20+
severity: 'CRITICAL,HIGH'

.github/workflows/tests.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: build_and_test
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build necessary services
6+
runs-on: self-hosted
7+
steps:
8+
- name: Check out repository code
9+
uses: actions/checkout@v5
10+
11+
- name: "Setup: Copy environment variables"
12+
run: cp .env_circleci .env
13+
14+
- name: "Setup: Create directories for MinIO (cannot be made by docker for some reason)"
15+
run: |
16+
mkdir -p var/minio/public
17+
mkdir -p var/minio/private
18+
19+
- name: "Setup: Prepare the playwright environment"
20+
run: |
21+
cd tests
22+
curl -LsSf https://astral.sh/uv/install.sh | sh
23+
$HOME/.local/bin/uv sync --frozen
24+
$HOME/.local/bin/uv run playwright install
25+
- name: "Docker: Build containers"
26+
run: |
27+
docker compose up -d
28+
29+
- name: "Get compute worker, site worker and django logs"
30+
run: |
31+
mkdir dockerLogs
32+
docker compose logs -f site_worker compute_worker django > dockerLogs/django_workers.log &
33+
linter:
34+
name: Flake8 linter
35+
runs-on: self-hosted
36+
needs: [build]
37+
steps:
38+
- name: "Lint: Check code style with flake8"
39+
run: docker compose exec django flake8 src/
40+
unit_tests:
41+
name: Unit tests
42+
runs-on: self-hosted
43+
needs: [linter,build]
44+
steps:
45+
- name: "Tests: Run unit/integration tests (excluding e2e)"
46+
run: docker compose exec django py.test src/ -m "not e2e"
47+
e2e:
48+
name: End to End tests with Playwright
49+
runs-on: self-hosted
50+
needs: [linter,build]
51+
steps:
52+
- name: "Tests: Run end-to-end (E2E) tests"
53+
run: |
54+
docker compose exec django python ./manage.py createsuperuser --no-input
55+
docker compose exec django python ./manage.py collectstatic --no-input
56+
docker compose exec django python ./manage.py migrate --no-input
57+
cd tests && CI=True $HOME/.local/bin/uv run pytest test_auth.py test_account_creation.py test_competition.py test_submission.py
58+
artifacts:
59+
name: "Store Artifacts"
60+
runs-on: self-hosted
61+
needs: [linter,build,unit_tests,e2e]
62+
steps:
63+
- name: "Docker logs"
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: "Docker logs"
67+
path: |
68+
dockerLogs/
69+
- name: "Playwright results (on-failure)"
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: "Playwright results (on-failure)"
73+
path: |
74+
tests/test-results
75+
cleanup:
76+
name: Cleanup
77+
runs-on: self-hosted
78+
if: ${{ always() }}
79+
needs: [unit_tests,e2e,linter,artifacts]
80+
steps:
81+
- name: Cleanup
82+
run: |
83+
docker compose down --rmi all
84+
rm -rf ${{ github.workspace }}/*

.github/workflows/tests.yml.DISABLED

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)