Skip to content

chore: use multi-stage builds for server images in both development and production environments #1235

chore: use multi-stage builds for server images in both development and production environments

chore: use multi-stage builds for server images in both development and production environments #1235

Workflow file for this run

name: Run Unit Tests
on:
push:
branches:
- master
paths:
- '**/**'
- '!README.md'
- '!webview/**'
- '!website/**'
- '!.github/workflows/build-webview.yaml'
- '!.github/workflows/build-balena-disk-image.yaml'
- '!docs/**'
pull_request:
branches:
- master
paths:
- '**/**'
- '!README.md'
- '!webview/**'
- '!website/**'
- '!.github/workflows/build-webview.yaml'
- '!.github/workflows/build-balena-disk-image.yaml'
- '!docs/**'
workflow_call:
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/.venv
installer-parallel: true
- name: Install dependencies
run: |
poetry install --only=docker-image-builder
- name: Cache Docker layers
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-x86
restore-keys: |
${{ runner.os }}-x86
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build Containers
run: |
poetry run python tools/image_builder \
--dockerfiles-only \
--disable-cache-mounts \
--service celery \
--service redis \
--service test
- name: Start the test container
run: |
docker compose -f docker-compose.test.yml up -d --build
- name: Run the unit tests inside the container
run: |
docker compose -f docker-compose.test.yml exec anthias-test ./manage.py test --noinput --parallel --exclude-tag=integration
- name: Run the integration tests inside the container
run: |
docker compose -f docker-compose.test.yml exec anthias-test bash ./bin/prepare_test_environment.sh -s
docker compose -f docker-compose.test.yml exec anthias-test ./manage.py test --noinput --tag=integration
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Stop the test container
run: |
docker compose -f docker-compose.test.yml down