Skip to content

add support for multi-instances #678

add support for multi-instances

add support for multi-instances #678

name: Tests
# This file contains 3 jobs that run in parallel
on:
workflow_dispatch: # Allow manually running
workflow_call: # Allow another workflow to call this one
pull_request:
types:
- opened
- reopened
- edited
- synchronize
branches: # Target
- 'main'
- 'dev'
# push:
# branches:
# - 'group-updates'
# tags:
# - 'v*'
jobs:
python_unit_test_and_coverage:
name: Python tests and coverage
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
echo "Installing python requirements"
pip install -r requirements-dev.txt
- name: Run Black format
run: python3 -m black --verbose --check --line-length 120 app
- name: Prepare enviornment variables
run: |
echo "NAUTICAL_DB_PATH=${GITHUB_WORKSPACE}/dev/config" >> "$GITHUB_ENV"
echo "SOURCE_LOCATION=${GITHUB_WORKSPACE}/dev/source" >> "$GITHUB_ENV"
echo "DEST_LOCATION=${GITHUB_WORKSPACE}/dev/destination" >> "$GITHUB_ENV"
echo "LOG_LEVEL=DEBUG" >> "$GITHUB_ENV"
- name: Create necessary folders
run: |
mkdir -p $NAUTICAL_DB_PATH
mkdir -p $SOURCE_LOCATION
mkdir -p $DEST_LOCATION
- name: Run tests and collect coverage
run: |
echo "NAUTICAL_DB_PATH: ${NAUTICAL_DB_PATH}"
python3 -m pytest --cov app --cov-report html --cov-report term --cov-report xml
- name: Upload reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Required for v4
with:
fail_ci_if_error: true
files: coverage.xml
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: python-code-coverage
path: htmlcov/
retention-days: 5
test_docker_architecture:
name: Validate Docker Architecture
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Dockerfile supports multi-arch
run: |
echo "Checking if the base docker image supports amd64 and arm64..."
bash ./tests/_validate_dockerfile.sh
bash_unit_test_and_coverage:
name: Integration tests
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export Docker image
uses: docker/build-push-action@v6.10.0
with:
context: .
load: true # Do not push this image
tags: minituff/nautical-test
build-args: TEST_MODE=0
- name: Run built image against Docker image
run: |
cd tests
docker compose run nautical-backup-test1
docker compose run nautical-backup-test2
- name: Run integration tests against Docker image
timeout-minutes: 3
run: |
cd tests
rm -rf source config
mkdir -p source/watchtower-test
echo "This is a test file" >> source/watchtower-test/test-file.txt
docker compose -f watchtower.yml up -d
docker compose run nautical-backup-test3
docker compose -f watchtower.yml down
bash ./_validate_rsync.sh
# - name: Upload reports to Codecov
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Required for v4
# with:
# fail_ci_if_error: true
# files: tests/coverage/coverage.xml # The json file will not work here
# - name: Archive code coverage results
# uses: actions/upload-artifact@v4
# with:
# name: bash-code-coverage
# path: tests/coverage/
# retention-days: 5