Skip to content

Commit

Permalink
arm64: unit tests (#11830)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
  • Loading branch information
valentijnscholten and Maffooch authored Feb 25, 2025
1 parent f470502 commit ded75a4
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 31 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/build-docker-images-for-testing.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
name: "Build Docker Images For Testing"

on:
# inspired by https://github.com/orgs/community/discussions/26801 we take the runs-on as parameter so we can run arm64 on native hardwarde
workflow_dispatch:
inputs:
runner:
type: string
default: "ubuntu-latest"
workflow_call:
inputs:
runner:
type: string
default: "ubuntu-latest"

jobs:
build:
# build with docker so we can use layer caching
name: Build Docker Images
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner }}
strategy:
matrix:
# integration tests are only build (and run) on debian x64
docker-image: [django, nginx, integration-tests]
os: [alpine, debian]
runner: ["${{ inputs.runner }}"]
exclude:
- docker-image: integration-tests
os: alpine
- docker-image: integration-tests
os: alpine
- docker-image: integration-tests
runner: ubuntu-24.04-arm

steps:
- name: Show Platform
run: echo Runner value for this run = ${{ inputs.runner }}

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -29,28 +44,25 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
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@0adf9959216b96bec444f325f1e493d4aa344497 # v6.14.0
timeout-minutes: 10
timeout-minutes: 15
env:
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
with:
context: .
push: false
tags: defectdojo/defectdojo-${{ matrix.docker-image }}:${{ matrix.os }}
tags: defectdojo/defectdojo-${{ matrix.docker-image }}:${{ matrix.os }},${{ env.IMAGE_REPOSITORY }}/defectdojo-${{ matrix.docker-image }}:${{ matrix.os }}
file: Dockerfile.${{ matrix.docker-image }}-${{ matrix.os }}
outputs: type=docker,dest=${{ matrix.docker-image }}-${{ matrix.os }}_img
outputs: type=docker,dest=${{ matrix.docker-image }}-${{ matrix.os }}-${{ inputs.runner }}_img

# export docker images to be used in next jobs below
- name: Upload image ${{ matrix.docker-image }} as artifact
timeout-minutes: 10
timeout-minutes: 15
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: built-docker-image-${{ matrix.docker-image }}-${{ matrix.os }}
path: ${{ matrix.docker-image }}-${{ matrix.os }}_img
name: built-docker-image-${{ matrix.docker-image }}-${{ matrix.os }}-${{ inputs.runner }}
path: ${{ matrix.docker-image }}-${{ matrix.os }}-${{ inputs.runner }}_img
retention-days: 1
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
- name: Load docker images
timeout-minutes: 10
run: |-
docker load -i built-docker-image/nginx-${{ matrix.os }}_img
docker load -i built-docker-image/django-${{ matrix.os }}_img
docker load -i built-docker-image/integration-tests-debian_img
docker load -i built-docker-image/nginx-${{ matrix.os }}-ubuntu-latest_img
docker load -i built-docker-image/django-${{ matrix.os }}-ubuntu-latest_img
docker load -i built-docker-image/integration-tests-debian-ubuntu-latest_img
docker images
- name: Set integration-test mode
run: ln -s docker-compose.override.integration_tests.yml docker-compose.override.yml

- name: Start Dojo
- name: Start Dojo
run: docker compose up --no-deps -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
env:
DJANGO_VERSION: ${{ matrix.os }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/k8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
merge-multiple: true

- name: Load docker images
timeout-minutes: 10
timeout-minutes: 15
run: |-
eval $(minikube docker-env)
docker load -i built-docker-image/nginx-${{ matrix.os }}_img
docker load -i built-docker-image/django-${{ matrix.os }}_img
docker load -i built-docker-image/nginx-${{ matrix.os }}-ubuntu-latest_img
docker load -i built-docker-image/django-${{ matrix.os }}-ubuntu-latest_img
docker images
- name: Configure HELM repos
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-2-tag-docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "Release-2: Tag, Release, Push"
env:
GIT_USERNAME: "DefectDojo release bot"
GIT_EMAIL: "dojo-release-bot@users.noreply.github.com"
workflow_name: 'release 2 tag release docker push' # needed in cache key, which doesn't support comma's

on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
git tag -a ${{ github.event.inputs.release_number }} -m "[bot] release ${{ github.event.inputs.release_number }}"
git push origin ${{ github.event.inputs.release_number }}
release-helm-chart:
needs: tag
uses: ./.github/workflows/release-x-manual-helm-chart.yml
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-x-manual-docker-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "release-X: Release docker containers"
env:
GIT_USERNAME: "DefectDojo release bot"
GIT_EMAIL: "dojo-release-bot@users.noreply.github.com"
workflow_name: 'release docker containers' # needed in cache key, which doesn't support comma's

on:
workflow_dispatch:
inputs:
Expand All @@ -29,7 +29,6 @@ jobs:
matrix:
docker-image: [django, nginx]
os: [alpine, debian]
platform: [amd64]
steps:
- name: Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/rest-framework-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: Rest Framework Unit Tests

on:
workflow_call:
inputs:
runner:
type: string
default: "ubuntu-latest"

jobs:
unit_tests:
name: Rest Framework Unit Tests
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner }}

strategy:
matrix:
Expand All @@ -29,8 +33,8 @@ jobs:
- name: Load docker images
timeout-minutes: 10
run: |-
docker load -i built-docker-image/nginx-${{ matrix.os }}_img
docker load -i built-docker-image/django-${{ matrix.os }}_img
docker load -i built-docker-image/nginx-${{ matrix.os }}-${{ inputs.runner }}_img
docker load -i built-docker-image/django-${{ matrix.os }}-${{ inputs.runner }}_img
docker images
# run tests with docker compose
Expand All @@ -43,7 +47,7 @@ jobs:

# no celery or initializer needed for unit tests
- name: Unit tests
timeout-minutes: 10
timeout-minutes: 15
run: docker compose up --no-deps --exit-code-from uwsgi uwsgi
env:
DJANGO_VERSION: ${{ matrix.os }}
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,33 @@ on:

jobs:
build-docker-containers:
strategy:
matrix:
runner: ["ubuntu-latest", "ubuntu-24.04-arm"] # we need to pass runner names instead of amd64/amd64
fail-fast: false
uses: ./.github/workflows/build-docker-images-for-testing.yml
secrets: inherit

with:
runner: ${{ matrix.runner }}

test-rest-framework:
strategy:
matrix:
runner: ["ubuntu-latest", "ubuntu-24.04-arm"]
fail-fast: false
needs: build-docker-containers
uses: ./.github/workflows/rest-framework-tests.yml
secrets: inherit
with:
runner: ${{ matrix.runner}}

# only run integration tests on ubuntu-latest (x64)
test-user-interface:
needs: build-docker-containers
uses: ./.github/workflows/integration-tests.yml
secrets: inherit


# only run k8s tests on ubuntu-latest (x64)
test-k8s:
needs: build-docker-containers
uses: ./.github/workflows/k8s-tests.yml
Expand Down

0 comments on commit ded75a4

Please sign in to comment.