forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (63 loc) · 2.35 KB
/
unit-tests.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
name: Unit tests
# pull requests:
# push:
# run on every push, which is when something gets merged also
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- dev
env:
DD_DOCKER_REPO: defectdojo
docker-image: django # we only need to build the django image for unit tests
jobs:
unit_tests:
name: unit tests
runs-on: ubuntu-latest
steps:
# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# - name: Read Docker Image Identifiers
# id: read-docker-image-identifiers
# run: echo "IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
driver-opts: image=moby/buildkit:master # needed to get the fix for https://github.com/moby/buildkit/issues/2426
- name: Build
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
push: false
load: true
tags: |
${{ env.DD_DOCKER_REPO }}/defectdojo-${{ env.docker-image }}:latest
file: Dockerfile.${{ env.docker-image }}
cache-from: type=gha
cache-to: type=gha,mode=max
# run tests with docker-compose
- name: Set unit-test mode
run: docker/setEnv.sh unit_tests_cicd
# phased startup so we can use the exit code from unit test container
- name: Start MySQL
run: docker-compose --env-file ./docker/environments/mysql-redis.env up -d mysql
# no celery or initializer needed for unit tests
- name: Unit tests
run: docker-compose --profile mysql-redis --env-file ./docker/environments/mysql-redis.env up --no-deps --exit-code-from uwsgi uwsgi
- name: Logs
if: failure()
run: docker-compose --profile mysql-redis --env-file ./docker/environments/mysql-redis.env logs --tail="2500" uwsgi
- name: Shutdown
if: always()
run: docker-compose --profile mysql-redis --env-file ./docker/environments/mysql-redis.env down