Skip to content

Pull Request Checks. #10

Pull Request Checks.

Pull Request Checks. #10

Workflow file for this run

name: Pull Request Checks.
on:
workflow_dispatch:
push:
branches:
- master
- develop
paths:
- ./src/**
- ./tests/**
- ./docker/**
pull_request:
branches:
- master
- develop
paths-ignore:
- '**.rst'
jobs:
pytest:
name: PyTest
runs-on: ubuntu-latest
steps:
- name: Checkout.
uses: actions/checkout@v4
# NOTE: Use ``docker compose --file docker/compose.yaml config | less``
# to see the config with interpolated variables from ``.env``.
# More about interpolation: https://docs.docker.com/compose/environment-variables/variable-interpolation/
#
# NOTE: More on caching can be found in the following:
# - https://github.com/docker/build-push-action?tab=readme-ov-file#usage
# - https://docs.docker.com/build/cache/backends/gha/
- name: Setup Docker Buildx.
uses: docker/setup-buildx-action@v3
- name: Build Server Image.
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/dockerfile
target: ci
# NOTE: ``bumpver`` will be looking for this. Futher, this should
# match tags in ``./docker/compose.ci.yaml`` which are updated
# by bumpver.
#
# NOTE: Adding an image tag that is version specific should not be done
# as this must be consistent with the caching config - updating the
# version string in the caching config requires the ``workflow``
# permission for the pipeline, which is overkill imo.
tags: acederberg/captura-ci:latest
pull: false
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- name: Setup.
run: |
docker_config_path='/home/captura/app/tests/assets/act.yaml'
echo "CAPTURA_CONFIG_CLIENT_TEST=$docker_config_path" > .env
echo "CAPTURA_CONFIG_CLIENT=$docker_config_path" >> .env
echo "CAPTURA_CONFIG_APP_TEST=$docker_config_path" >> .env
echo "CAPTURA_CONFIG_APP=$docker_config_path" >> .env
echo "CAPTURA_FLAKEY=/home/captura/flakey.yaml" >> .env
- name: Start Docker Compose Project.
run: |
docker compose \
--file docker/compose.ci.yaml \
--env-file .env \
up --detach --quiet-pull
# NOTE: ``act.yaml`` defined everything necessary for the client and server.
- name: Generate Dummy Data In Server.
run: |
version=$( \
docker compose \
--file docker/compose.ci.yaml \
exec db mysql --version \
)
echo "MySQL Version: $version" >> $GITHUB_STEP_SUMMARY
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& poetry run simulatus initialize \
&& poetry run simulatus apply'
# echo -e "# Dummy Data Report\n\n~~~" >> $GITHUB_STEP_SUMMARY
# docker compose \
# --file docker/compose.ci.yaml \
# exec server \
# bash -c ' \
# source ~/app/.venv/bin/activate \
# && poetry run simulatus --loud reports aggregate' \
# >> $GITHUB_STEP_SUMMARY
# echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY
- name: Run Tests.
run: |
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& pip install poetry \
&& poetry run coverage run -m pytest --count 1'
continue-on-error: true
# --------------------------------------------------------------------- #
# NOTE: ``master/develop`` only.
- name: Create Coverage Report.
id: coverage-report
if: |
contains('
refs/heads/master
refs/heads/development
', github.ref)
run: |
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& poetry run coverage html --directory ./coverage-report'
continue-on-error: true
- name: Copy Coverage Report To Host.
id: coverage-report-to-host
if: |
contains('
refs/heads/master
refs/heads/development
', github.ref)
run: |
docker compose \
--file docker/compose.ci.yaml \
cp server:/home/captura/app/coverage-report ./coverage-report
- name: Upload Coverage Report.
id: coverage-report-upload
if: |
contains('
refs/heads/master
refs/heads/development
', github.ref)
uses: actions/upload-pages-artifact@v3
with:
path: './coverage-report'
# --------------------------------------------------------------------- #
# NOTE: Finalize.
#
- name: Stop Compose Project.
if: always()
run: docker compose --file docker/compose.ci.yaml down
# NOTE: Publish only when on master/development.
coverage:
name: PyTest Coverage
if: |
contains('
refs/heads/master
refs/heads/development
', github.ref)
needs: pytest
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: coverage-report-pages
uses: actions/deploy-pages@v4