Skip to content

Merge pull request #163 from modoboa/dependabot/pip/testfixtures-7.2.2 #66

Merge pull request #163 from modoboa/dependabot/pip/testfixtures-7.2.2

Merge pull request #163 from modoboa/dependabot/pip/testfixtures-7.2.2 #66

Workflow file for this run

name: Modoboa amavis plugin
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
branches: [ master ]
env:
POSTGRES_HOST: localhost
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: modoboa
MYSQL_PASSWORD: modoboa
MYSQL_DATABASE: modoboa
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379/tcp
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
database: ['postgres', 'mysql']
python-version: [3.8, 3.9, '3.10']
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update -y && sudo apt-get install -y librrd-dev rrdtool redis-server
python -m pip install --upgrade pip
#pip install -e git+https://github.com/modoboa/modoboa.git#egg=modoboa
pip install -r requirements.txt
pip install -r test-requirements.txt
cd ..
git clone https://github.com/modoboa/modoboa.git
cd modoboa
python setup.py develop
cd ../modoboa-amavis
python setup.py develop
echo "Testing redis connection"
redis-cli -h $REDIS_HOST -p $REDIS_PORT ping
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
- name: Install postgres requirements
if: ${{ matrix.database == 'postgres' }}
run: |
pip install 'psycopg[binary]>=3.1'
pip install coverage
echo "DB=postgres" >> $GITHUB_ENV
- name: Install mysql requirements
if: ${{ matrix.database == 'mysql' }}
run: |
pip install 'mysqlclient<2.1.2'
echo "DB=mysql" >> $GITHUB_ENV
- name: Test with pytest
if: ${{ matrix.python-version != '3.10' || matrix.database != 'postgres' }}
run: |
cd test_project
python3 manage.py test modoboa_amavis
env:
# use localhost for the host here because we are running the job on the VM.
# If we were running the job on in a container this would be postgres
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
MYSQL_USER: root
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
- name: Test with pytest and coverage
if: ${{ matrix.python-version == '3.10' && matrix.database == 'postgres' }}
run: |
cd test_project
coverage run --source ../modoboa_amavis manage.py test modoboa_amavis
coverage xml
coverage report
env:
# use localhost for the host here because we are running the job on the VM.
# If we were running the job on in a container this would be postgres
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
MYSQL_USER: root
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
- name: Upload coverage result
if: ${{ matrix.python-version == '3.10' && matrix.database == 'postgres' }}
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: test_project/coverage.xml
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download coverage results
uses: actions/download-artifact@v3
with:
name: coverage-results
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
release:
if: github.event_name != 'pull_request'
needs: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build packages
run: |
sudo apt-get install librrd-dev rrdtool libssl-dev gettext
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
cd ..
git clone https://github.com/modoboa/modoboa.git
cd modoboa
python setup.py develop
cd ../modoboa-amavis/modoboa_amavis
django-admin compilemessages
cd ..
python setup.py sdist bdist_wheel
- name: Publish to Test PyPI
if: endsWith(github.event.ref, '/master')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution to PyPI
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
skip_existing: true