merge traffic #1279
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: tests | |
on: | |
push: | |
branches: | |
- master | |
pull_request_target: | |
schedule: | |
- cron: "42 7 * * 0" # Every Sunday morning when I am fast asleep :) | |
# This is useful for keeping the cache fit and ready | |
workflow_dispatch: | |
env: | |
POETRY_VERSION: "1.7.0" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest # ${{ matrix.os }} | |
strategy: | |
matrix: | |
# os: [ubuntu-latest, macos-latest, windows-latest] | |
# onnxruntime needed for 3.11 | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
git fetch --prune --unshallow --tags | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Update full Python version | |
- name: Full Python version | |
run: | | |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")" | |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")" >> $GITHUB_ENV | |
- name: Download extra data from private repository | |
uses: actions/checkout@v4 | |
with: | |
repository: xoolive/traffic_data | |
token: ${{ secrets.PRIVATE_TOKEN }} | |
persist-credentials: false | |
path: ./traffic_data | |
- name: Create LFS file list (private repository) | |
working-directory: ./traffic_data | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
shell: bash | |
- name: Restore LFS cache (private repository) | |
uses: actions/cache@v3 | |
id: lfs-cache | |
with: | |
path: ./traffic_data/.git/lfs | |
key: lfs-${{ hashFiles('./traffic_data/.lfs-assets-id') }}-v1 | |
- name: Git LFS Pull (private repository) | |
working-directory: ./traffic_data | |
run: | | |
git remote set-url origin https://xoolive:${{ secrets.PRIVATE_TOKEN }}@github.com/xoolive/traffic_data.git | |
git lfs pull | |
unzip ENV_PostOPS_AIRAC_2111_04NOV2021_With_Airspace_Closure.zip -d airac_2111 | |
shell: bash | |
# virtualenv cache should depends on OS, Python version and `poetry.lock` (and optionally workflow files). | |
- name: Cache Packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.local | |
.venv | |
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install and configure Poetry | |
uses: snok/install-poetry@v1.3.4 | |
with: | |
version: ${{ env.POETRY_VERSION }} | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Display Python version | |
run: poetry run python -c "import sys; print(sys.version)" | |
- name: Cache folder for traffic | |
uses: actions/cache@v3 | |
id: cache-folder | |
with: | |
path: | | |
~/.cache/traffic/ | |
~/.cache/opensky/ | |
~/.cache/cartes/ | |
key: traffic-${{ runner.os }} | |
- name: Ubuntu system dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y libgdal-dev libgeos-dev libproj-dev proj-bin proj-data libarchive-dev | |
# Weird issue with libarchive-dev | |
sudo ln -s -f /usr/lib/x86_64-linux-gnu/libarchive.a /usr/lib/x86_64-linux-gnu/liblibarchive.a | |
- name: Dynamic versioning | |
run: poetry self add "poetry-dynamic-versioning[plugin]" || true | |
- name: Install dependencies | |
run: | | |
poetry install -E full -E web | |
- name: Style checking | |
run: | | |
poetry run ruff src tests | |
poetry run ruff format --check src tests | |
- name: Type checking | |
run: | | |
poetry run mypy src tests | |
- name: Run tests | |
env: | |
LD_LIBRARY_PATH: /usr/local/lib | |
TRAFFIC_NOPLUGIN: "" | |
OPENSKY_USERNAME: ${{ secrets.OPENSKY_USERNAME }} | |
OPENSKY_PASSWORD: ${{ secrets.OPENSKY_PASSWORD }} | |
# PKCS12_PASSWORD: ${{ secrets.PKCS12_PASSWORD }} | |
run: | | |
export TRAFFIC_CONFIG=$(poetry run python -c "from traffic import config_file; print(config_file)") | |
sed -i "/nm_path =/ s,= $,= $PWD/traffic_data/airac_2111," $TRAFFIC_CONFIG | |
# sed -i "/pkcs12_filename =/ s,= .*$,= $PWD/traffic_data/CC0000007011_501_openssl.p12," $TRAFFIC_CONFIG | |
# sed -i "/pkcs12_password =/ s,= $,= $PKCS12_PASSWORD," $TRAFFIC_CONFIG | |
# Don't purge OpenSky cache files here :) | |
sed -i "/purge = / d" $TRAFFIC_CONFIG | |
poetry run traffic cache --fill # download files to have in cache first | |
poetry run pytest --cov --cov-report xml | |
- name: Upload coverage to Codecov | |
if: ${{ github.event_name != 'pull_request_target' }} | |
uses: codecov/codecov-action@v3 | |
with: | |
env_vars: PYTHON_VERSION |