Bump docker/setup-qemu-action from 2 to 3 #144
Workflow file for this run
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: Python CI | |
# 1. Run linting and static code checks | |
# 2. Test python syncing script | |
# 3. Build and publish docker container | |
# 4. Test published docker container | |
on: | |
pull_request: | |
types: ['opened', 'reopened', 'synchronize'] | |
workflow_dispatch: | |
inputs: | |
numChaos: | |
description: 'Number of items the chaos monkey should manipulate during test' | |
required: false | |
default: '4' | |
CREATE_REMINDERS: | |
description: Create reminders for birthdays and deceased days? | |
required: false | |
type: boolean | |
default: true | |
DELETE_ON_SYNC: | |
description: Delete Monica contact if the corresponding Google contact has been deleted? | |
required: false | |
type: boolean | |
default: true | |
STREET_REVERSAL: | |
description: Do a street reversal in address sync if the first character is a number? | |
required: false | |
type: boolean | |
default: false | |
FIELDS: | |
description: What fields should be synced? (both directions) | |
required: false | |
default: career,address,phone,email,labels,notes | |
GOOGLE_LABELS_INCLUDE: | |
description: Define Google contact labels/tags/groups you want to include in sync | |
required: false | |
default: | |
GOOGLE_LABELS_EXCLUDE: | |
description: Define Google contact labels/tags/groups you want to exclude from sync | |
required: false | |
default: | |
MONICA_LABELS_INCLUDE: | |
description: Define Monica contact labels/tags/groups you want to include in sync | |
required: false | |
default: | |
MONICA_LABELS_EXCLUDE: | |
description: Define Monica contact labels/tags/groups you want to exclude from sync | |
required: false | |
default: | |
# 1. Run linting and static code checks | |
jobs: | |
black_formatting: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: psf/black@stable | |
with: | |
options: "-l 105 --check --diff" | |
src: "." | |
codespell_check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: codespell-project/actions-codespell@master | |
with: | |
check_filenames: true | |
skip: .*,*.csv | |
bandit_security: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: jpetrucciani/bandit-check@master | |
with: | |
path: '.' | |
bandit_flags: '--recursive --skip B403,B101,B301' | |
flake8_lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source repository | |
uses: actions/checkout@v4 | |
- name: Setup Python environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: flake8 Lint | |
uses: py-actions/flake8@v2 | |
with: | |
ignore: "E203,W503,E231,E402" | |
max-line-length: "105" | |
path: "." | |
args: '--count --show-source --statistics' | |
isort_check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source repository | |
uses: actions/checkout@v4 | |
- name: Setup Python environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- uses: isort/isort-action@master | |
with: | |
configuration: "--check-only --profile black" | |
mypy_typecheck: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: jpetrucciani/mypy-check@master | |
with: | |
path: '.' | |
mypy_flags: '--install-types --non-interactive' | |
# 2. Test python syncing script | |
python_test: | |
runs-on: ubuntu-latest | |
needs: [black_formatting, codespell_check, bandit_security, flake8_lint, isort_check, mypy_typecheck] | |
env: | |
TEST_RUNNER: python | |
steps: | |
# Setup environment | |
- name: Check out source repository | |
uses: actions/checkout@v4 | |
- name: Setup python environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Setup testing environment | |
uses: ./.github/actions/setup-environment | |
with: | |
GOOGLE_TOKEN: ${{ secrets.GOOGLE_TOKEN }} | |
CREATE_REMINDERS: ${{ github.event.inputs.CREATE_REMINDERS }} | |
DELETE_ON_SYNC: ${{ github.event.inputs.DELETE_ON_SYNC }} | |
STREET_REVERSAL: ${{ github.event.inputs.STREET_REVERSAL }} | |
FIELDS: ${{ github.event.inputs.FIELDS }} | |
GOOGLE_LABELS_INCLUDE: ${{ github.event.inputs.GOOGLE_LABELS_INCLUDE }} | |
GOOGLE_LABELS_EXCLUDE: ${{ github.event.inputs.GOOGLE_LABELS_EXCLUDE }} | |
MONICA_LABELS_INCLUDE: ${{ github.event.inputs.MONICA_LABELS_INCLUDE }} | |
MONICA_LABELS_EXCLUDE: ${{ github.event.inputs.MONICA_LABELS_EXCLUDE }} | |
# Test initial sync | |
- name: Prepare initial sync | |
run: python test/ChaosMonkey.py --initial --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run initial sync | |
run: python GMSync.py --initial | |
timeout-minutes: 5 | |
- name: Check initial sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_initial.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_initial.log)" ]] | |
# Test delta sync | |
- name: Prepare delta sync | |
run: python test/ChaosMonkey.py --delta --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run delta sync | |
run: python GMSync.py --delta | |
timeout-minutes: 5 | |
- name: Check delta sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_delta.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_delta.log)" ]] | |
# Test full sync | |
- name: Prepare full sync | |
run: python test/ChaosMonkey.py --full --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run full sync | |
run: python GMSync.py --full | |
timeout-minutes: 5 | |
- name: Check full sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_full.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_full.log)" ]] | |
# Test sync back | |
- name: Prepare sync back | |
run: python test/ChaosMonkey.py --syncback --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run sync back | |
run: python GMSync.py --syncback | |
timeout-minutes: 5 | |
- name: Check sync back results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_syncback.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_syncback.log)" ]] | |
# Test database check | |
- name: Prepare database check | |
run: python test/ChaosMonkey.py --check --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run database check | |
run: python GMSync.py --check | |
timeout-minutes: 5 | |
- name: Check database check results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_databasecheck.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_databasecheck.log)" ]] | |
# End testing | |
- name: Cleanup testing environment | |
uses: ./.github/actions/cleanup-environment | |
if: always() | |
with: | |
TEST_RUNNER: ${{ env.TEST_RUNNER }} | |
REPO_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Upload log files | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: logs | |
path: | | |
logs/ | |
data/${{ env.TEST_RUNNER }}_syncState.db | |
# 3. Build and publish docker container | |
docker_build: | |
runs-on: ubuntu-latest | |
needs: python_test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
no-cache: true | |
push: true | |
tags: antonplagemann/google-monica-sync:next | |
# 4. Test published docker container | |
docker_test: | |
runs-on: ubuntu-latest | |
needs: docker_build | |
env: | |
TEST_RUNNER: docker | |
steps: | |
# Setup environment | |
- name: Check out source repository | |
uses: actions/checkout@v4 | |
- name: Setup python environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Setup testing environment | |
uses: ./.github/actions/setup-environment | |
with: | |
GOOGLE_TOKEN: ${{ secrets.GOOGLE_TOKEN }} | |
CREATE_REMINDERS: ${{ github.event.inputs.CREATE_REMINDERS }} | |
DELETE_ON_SYNC: ${{ github.event.inputs.DELETE_ON_SYNC }} | |
STREET_REVERSAL: ${{ github.event.inputs.STREET_REVERSAL }} | |
FIELDS: ${{ github.event.inputs.FIELDS }} | |
GOOGLE_LABELS_INCLUDE: ${{ github.event.inputs.GOOGLE_LABELS_INCLUDE }} | |
GOOGLE_LABELS_EXCLUDE: ${{ github.event.inputs.GOOGLE_LABELS_EXCLUDE }} | |
MONICA_LABELS_INCLUDE: ${{ github.event.inputs.MONICA_LABELS_INCLUDE }} | |
MONICA_LABELS_EXCLUDE: ${{ github.event.inputs.MONICA_LABELS_EXCLUDE }} | |
# Test initial sync | |
- name: Prepare initial sync | |
run: python test/ChaosMonkey.py --initial --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run initial sync | |
run: docker-compose -f test/docker-compose-sync.yml -f test/docker-compose-sync-initial.yml --env-file .env up | |
timeout-minutes: 5 | |
- name: Check initial sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_initial.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_initial.log)" ]] | |
# Test delta sync | |
- name: Prepare delta sync | |
run: python test/ChaosMonkey.py --delta --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run delta sync | |
run: docker-compose -f test/docker-compose-sync.yml -f test/docker-compose-sync-delta.yml --env-file .env up | |
timeout-minutes: 5 | |
- name: Check delta sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_delta.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_delta.log)" ]] | |
# Test full sync | |
- name: Prepare full sync | |
run: python test/ChaosMonkey.py --full --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run full sync | |
run: docker-compose -f test/docker-compose-sync.yml -f test/docker-compose-sync-full.yml --env-file .env up | |
timeout-minutes: 5 | |
- name: Check full sync results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_full.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_full.log)" ]] | |
# Test sync back | |
- name: Prepare sync back | |
run: python test/ChaosMonkey.py --syncback --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run sync back | |
run: docker-compose -f test/docker-compose-sync.yml -f test/docker-compose-sync-syncback.yml --env-file .env up | |
timeout-minutes: 5 | |
- name: Check sync back results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_syncback.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_syncback.log)" ]] | |
# Test database check | |
- name: Prepare database check | |
run: python test/ChaosMonkey.py --check --num ${{ github.event.inputs.numChaos || 4 }} | |
- name: Run database check | |
run: docker-compose -f test/docker-compose-sync.yml -f test/docker-compose-sync-check.yml --env-file .env up | |
timeout-minutes: 5 | |
- name: Check database check results | |
if: always() | |
run: | | |
mv logs/sync.log logs/${{ env.TEST_RUNNER }}_sync_databasecheck.log && \ | |
[[ -z "$(grep -e ERROR -e WARNING logs/${{ env.TEST_RUNNER }}_sync_databasecheck.log)" ]] | |
# End testing | |
- name: Cleanup testing environment | |
uses: ./.github/actions/cleanup-environment | |
if: always() | |
with: | |
TEST_RUNNER: ${{ env.TEST_RUNNER }} | |
REPO_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Upload log files | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: logs | |
path: | | |
logs/ | |
data/${{ env.TEST_RUNNER }}_syncState.db |