Run test jobs in parallel for CI/CD.

master
Dimitri Huisman 3 years ago
parent 5d1264e381
commit e16e9f19fd

@ -30,18 +30,22 @@ on:
################################################ ################################################
jobs: jobs:
build-test-deploy: build:
name: build and test name: build images
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Extract branch name - name: Extract branch name
shell: bash shell: bash
run: | run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: install python packages - name: create folder for storing images
run: python3 -m pip install -r tests/requirements.txt run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: check docker-compose version - name: check docker-compose version
run: docker-compose -v run: docker-compose -v
- name: login docker - name: login docker
@ -50,19 +54,36 @@ jobs:
DOCKER_PW: ${{ secrets.Docker_Password }} DOCKER_PW: ${{ secrets.Docker_Password }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
run: echo "$DOCKER_PW" | docker login --username $DOCKER_UN --password-stdin run: echo "$DOCKER_PW" | docker login --username $DOCKER_UN --password-stdin
# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- name: build all docker images - name: build all docker images
env: env:
MAILU_VERSION: ${{ env.BRANCH }} MAILU_VERSION: ${{ env.BRANCH }}
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
run: docker-compose -f tests/build.yml build run: docker-compose -f tests/build.yml build
- name: save all docker images
run: docker save ${{ secrets.DOCKER_ORG }}/admin ${{ secrets.DOCKER_ORG }}/clamav ${{ secrets.DOCKER_ORG }}/docs ${{ secrets.DOCKER_ORG }}/dovecot ${{ secrets.DOCKER_ORG }}/fetchmail ${{ secrets.DOCKER_ORG }}/nginx ${{ secrets.DOCKER_ORG }}/none ${{ secrets.DOCKER_ORG }}/postfix ${{ secrets.DOCKER_ORG }}/postgresql ${{ secrets.DOCKER_ORG }}/radicale ${{ secrets.DOCKER_ORG }}/rainloop ${{ secrets.DOCKER_ORG }}/roundcube ${{ secrets.DOCKER_ORG }}/rspamd ${{ secrets.DOCKER_ORG }}/setup ${{ secrets.DOCKER_ORG }}/traefik-certdumper ${{ secrets.DOCKER_ORG }}/unbound -o /images/images.tar.gz
test-core:
name: Perform core tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs - name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*' run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: test core suite - name: test core suite
@ -72,13 +93,28 @@ jobs:
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
- name: 'test clamvav' test-fetchmail:
run: python tests/compose/test.py filters 2 name: Perform fetchmail tests
env: runs-on: ubuntu-latest
MAILU_VERSION: ${{ env.BRANCH }} needs:
TRAVIS_BRANCH: ${{ env.BRANCH }} - build
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: test fetch - name: test fetch
run: python tests/compose/test.py fetchmail 1 run: python tests/compose/test.py fetchmail 1
env: env:
@ -86,6 +122,57 @@ jobs:
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
test-filters:
name: Perform filter tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: 'test clamvav'
run: python tests/compose/test.py filters 2
env:
MAILU_VERSION: ${{ env.BRANCH }}
TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
test-rainloop:
name: Perform rainloop tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: test rainloop - name: test rainloop
run: python tests/compose/test.py rainloop 1 run: python tests/compose/test.py rainloop 1
env: env:
@ -93,6 +180,28 @@ jobs:
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
test-roundcube:
name: Perform roundcube tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: test roundcube - name: test roundcube
run: python tests/compose/test.py roundcube 1 run: python tests/compose/test.py roundcube 1
env: env:
@ -100,6 +209,28 @@ jobs:
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
test-webdav:
name: Perform webdav tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: install python packages
run: python3 -m pip install -r tests/requirements.txt
- name: copy all certs
run: sudo -- sh -c 'mkdir -p /mailu && cp -r tests/certs /mailu && chmod 600 /mailu/certs/*'
- name: test webdav - name: test webdav
run: python tests/compose/test.py webdav 1 run: python tests/compose/test.py webdav 1
env: env:
@ -107,6 +238,34 @@ jobs:
TRAVIS_BRANCH: ${{ env.BRANCH }} TRAVIS_BRANCH: ${{ env.BRANCH }}
DOCKER_ORG: ${{ secrets.DOCKER_ORG }} DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
deploy:
name: Deploy images
runs-on: ubuntu-latest
needs:
- build
- test-core
- test-fetchmail
- test-filters
- test-rainloop
- test-roundcube
- test-webdav
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: create folder for storing images
run: sudo mkdir -p /images
- name: configure images folder for caching
# For staging we do not deploy images. So we do not have to load them from cache.
if: ${{ env.BRANCH != 'staging' }}
using: actions/cache@v2
with:
path: /images
key: ${{ env.BRANCH }}-${{ github.run_id }}-${{ github.run_number }}
- name: Load docker images
run: docker load -i /images/images.tar.gz
- name: deploy built docker images - name: deploy built docker images
env: env:
DOCKER_UN: ${{ secrets.Docker_Login }} DOCKER_UN: ${{ secrets.Docker_Login }}
@ -124,10 +283,8 @@ jobs:
#Returns true when none of the **previous** steps have failed or been canceled. #Returns true when none of the **previous** steps have failed or been canceled.
if: ${{ success() }} if: ${{ success() }}
needs: needs:
- build-test-deploy - deploy
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: CI/CD succeeded. - name: CI/CD succeeded.
run: exit 0 run: exit 0

@ -0,0 +1,5 @@
echo "Creating user required for next test ..."
# Should not fail and update the password; update mode
docker-compose -f tests/compose/filters/docker-compose.yml exec -T admin flask mailu admin admin mailu.io 'password' --mode=update || exit 1
docker-compose -f tests/compose/filters/docker-compose.yml exec -T admin flask mailu user user mailu.io 'password' || exit 1
echo "User created successfully"
Loading…
Cancel
Save