forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.52 KB
/
Copy pathunit-tests.yml
File metadata and controls
82 lines (68 loc) · 2.52 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
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@v2
# - 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@v1
# build with docker so we can use layer caching
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-${{ env.docker-image }}
key: ${{ runner.os }}-buildx-${{ env.docker-image }}-${{ github.workflow }}-${{ github.sha }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-buildx-${{ env.docker-image }}-${{ github.workflow }}-${{ github.sha }}
${{ runner.os }}-buildx-${{ env.docker-image }}-${{ github.workflow }}
${{ runner.os }}-buildx-${{ env.docker-image }}
- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: |
${{ env.DD_DOCKER_REPO }}/defectdojo-${{ env.docker-image }}:latest
file: Dockerfile.${{ env.docker-image }}
cache-from: type=local,src=/tmp/.buildx-cache-${{ env.docker-image }}
cache-to: type=local,dest=/tmp/.buildx-cache-${{ env.docker-image }}
# 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 up -d
# no celery or initializer needed for unit tests
- name: Unit tests
run: docker-compose up --no-deps --exit-code-from uwsgi uwsgi
- name: Logs
if: failure()
run: docker-compose logs --tail="2500" uwsgi
- name: Shutdown
if: always()
run: docker-compose down