Nightly Test #995
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: Nightly Test | |
# Run the nightly tests at at 6 AM UTC | |
on: | |
schedule: | |
- cron: "0 6 * * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
lint: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: psf/black@stable | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[aws,gcp] | |
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# The GitHub editor is 127 chars wide | |
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | |
- name: Mypy | |
run: mypy | |
- name: Pylint | |
run: pylint main.py ibkr_report | |
- name: Run tests with Coverage | |
run: | | |
coverage run -m unittest discover | |
coverage report -m | |
coverage xml | |
docker: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
arch: ['linux/amd64', 'linux/arm64'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set REPO_NAME | |
run: echo "REPO_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-build-x-${{ matrix.arch }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-build-x-${{ matrix.arch }}- | |
- name: Build | |
uses: docker/[email protected] | |
with: | |
platforms: ${{ matrix.arch }} | |
push: false | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
- name: Docker container up | |
run: docker run -d --rm -p 8080:8080 --name ${{ env.REPO_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Wait 10 seconds | |
run: sleep 10 | |
- name: Check running containers | |
run: docker ps -a | |
- name: Check the container reachability | |
run: curl -s --retry 10 --retry-connrefused http://localhost:8080/ | |
- name: Check Docker logs | |
run: docker logs ${{ env.REPO_NAME }} | |
- name: Docker container down | |
run: docker stop ${{ env.REPO_NAME }} |