Integration tests #13114
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration tests | |
# pull requests: | |
# push: | |
# run on every push, which is when something gets merged also | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- master | |
- dev | |
- release/** | |
- hotfix/** | |
env: | |
DD_DOCKER_REPO: defectdojo | |
jobs: | |
build: | |
# build with docker so we can use layer caching | |
name: Build Image | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
docker-image: [django, nginx, integration-tests] | |
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 | |
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@v1 | |
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@v2 | |
env: | |
docker-image: ${{ matrix.docker-image }} | |
with: | |
context: . | |
push: false | |
tags: | | |
${{ env.DD_DOCKER_REPO }}/defectdojo-${{ env.docker-image }}:latest | |
file: Dockerfile.${{ env.docker-image }} | |
outputs: type=docker,dest=${{ env.docker-image }}_img | |
cache-from: type=gha,scope=${{ matrix.docker-image }} | |
cache-to: type=gha,mode=max,scope=${{ matrix.docker-image }} | |
# export docker images to be used in next jobs below | |
- name: Upload image ${{ matrix.docker-image }} as artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.docker-image }} | |
path: ${{ matrix.docker-image }}_img | |
retention-days: 1 | |
integration_tests: | |
# run tests with docker-compose | |
name: integration tests | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
test-case: [ | |
"tests/finding_test.py", | |
"tests/report_builder_test.py", | |
"tests/notes_test.py", | |
"tests/regulations_test.py", | |
"tests/product_type_test.py", | |
"tests/product_test.py", | |
"tests/endpoint_test.py", | |
"tests/engagement_test.py", | |
"tests/environment_test.py", | |
"tests/test_test.py", | |
"tests/user_test.py", | |
"tests/group_test.py", | |
"tests/product_group_test.py", | |
"tests/product_type_group_test.py", | |
"tests/product_member_test.py", | |
"tests/product_type_member_test.py", | |
"tests/ibm_appscan_test.py", | |
"tests/search_test.py", | |
"tests/file_test.py", | |
"tests/dedupe_test.py", | |
"tests/check_various_pages.py", | |
"tests/notifications_test.py", | |
] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# load docker images from build jobs | |
- name: Load images from artifacts | |
uses: actions/download-artifact@v2 | |
- name: Load docker images | |
run: |- | |
docker load -i nginx/nginx_img | |
docker load -i django/django_img | |
docker load -i integration-tests/integration-tests_img | |
docker images | |
- name: Set integration-test mode | |
run: ln -s docker-compose.override.integration_tests.yml docker-compose.override.yml | |
# phased startup so we can use the exit code from integrationtest container | |
- name: Start Dojo | |
# implicity starts uwsgi and rabbitmq | |
run: docker-compose up -d mysql nginx celerybeat celeryworker mailhog | |
- name: Initialize | |
run: docker-compose up --exit-code-from initializer initializer | |
- name: Integration tests | |
run: docker-compose up --exit-code-from integration-tests integration-tests | |
env: | |
DD_INTEGRATION_TEST_FILENAME: ${{ matrix.test-case }} | |
- name: Logs | |
if: always() | |
run: docker-compose logs --tail="2500" | |
- name: Shutdown | |
if: always() | |
run: docker-compose down |