Merge branch 'main' into ci_container #20000
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: CI | |
on: [push, pull_request] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
container: | |
image: python:3.12-bullseye | |
env: | |
node-version: '20' | |
mailroom-version: '9.3.59' | |
services: | |
redis: | |
image: redis:6.2-alpine | |
ports: | |
- 6379:6379 | |
postgres: | |
image: postgis/postgis:15-3.3-alpine | |
env: | |
POSTGRES_DB: temba | |
POSTGRES_USER: temba | |
POSTGRES_PASSWORD: temba | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
minio: | |
image: bitnami/minio:latest | |
env: | |
MINIO_ROOT_USER: root | |
MINIO_ROOT_PASSWORD: tembatemba | |
MINIO_DEFAULT_BUCKETS: test-default,test-attachments:public,test-sessions,test-logs,test-archives | |
ports: | |
- 9000:9000 | |
options: --health-cmd "mc ready local" --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Linux packages | |
run: | | |
apt-get update | |
apt-get install -y --no-install-recommends libgdal-dev ffmpeg | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-in-project: true | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
- name: Install Mailroom | |
run: | | |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/mailroom | |
cd mailroom | |
go install github.com/${{ github.repository_owner }}/mailroom/cmd/mailroom | |
# start mailroom but use different redis db so that it doesn't actually handle tasks | |
./mailroom -db=postgres://temba:temba@postgres:5432/temba?sslmode=disable -redis=redis://redis:6379/15 -log-level=info > mailroom.log & | |
working-directory: ${{ github.workspace }} | |
- name: Install and start DynamoDB | |
uses: rrainn/[email protected] | |
with: | |
port: 6000 | |
- name: Initialize environment | |
run: | | |
npm install -g yarn less | |
poetry install | |
yarn install | |
ln -s settings.py.dev temba/settings.py | |
poetry run python manage.py migrate | |
poetry run python manage.py migrate_dynamo --testing | |
working-directory: ${{ github.workspace }} # https://github.com/actions/runner/issues/2058#issuecomment-2085119510 | |
- name: Run pre-test checks | |
run: | | |
# test that everything is well formatted, no missing migrations etc | |
poetry run python code_check.py --debug | |
# check we can collect and compress all static files | |
poetry run python manage.py collectstatic --noinput --verbosity=0 | |
poetry run python manage.py compress --extension=".html" --settings=temba.settings_compress | |
working-directory: ${{ github.workspace }} | |
- name: Run tests | |
run: | | |
poetry run coverage run manage.py test --keepdb --noinput --verbosity=2 | |
poetry run coverage report -i | |
poetry run coverage xml | |
poetry run coverage html | |
working-directory: ${{ github.workspace }} | |
- name: Save coverage report as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: htmlcov/ | |
- name: Mailroom log | |
if: failure() | |
run: cat mailroom.log | |
- name: Upload coverage | |
if: success() | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true |