Skip to content

use websockets library as ws backend #207

use websockets library as ws backend

use websockets library as ws backend #207

Workflow file for this run

name: Main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
packages: write
on:
pull_request:
branches:
- "*"
push:
branches:
- main
- dev
tags:
- "v*.*.*"
env:
# Change this to invalidate existing cache.
CACHE_PREFIX: v0
PYTHONPATH: ./
jobs:
checks:
name: Python ${{ matrix.python }} - ${{ matrix.task.name }}
runs-on: [ubuntu-latest]
environment: OSSBUILD
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python: ["3.10"]
task:
- name: Test
run: |
pytest -v --color=yes tests/
include:
- python: "3.10"
task:
name: Lint
run: ruff check . --exclude tests/
# - python: "3.10"
# task:
# name: Type check
# run: mypy .
- python: "3.10"
task:
name: Build
run: |
python -m build
- python: "3.10"
task:
name: Style
run: |
isort --check .
- python: "3.10"
task:
name: Docs
run: cd docs && make html
steps:
- uses: actions/checkout@v3
- name: Setup Python environment
uses: ./.github/actions/setup-venv
with:
python-version: ${{ matrix.python }}
cache-prefix: ${{ env.CACHE_PREFIX }}
- name: Check if PR is from a fork
id: check_fork
run: |
echo "is_fork=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_ENV
- name: check if PR is from a fork
if: env.is_fork == 'true'
run: echo "This PR is from a fork. skipping pyest."
- name: Skip if not from fork
if: env.is_fork != 'true'
run: echo "This PR is not from a fork. Running pytest."
- name: Restore mypy cache
if: matrix.task.name == 'Type check'
uses: actions/cache@v3
with:
path: .mypy_cache
key: mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}-${{ github.ref }}
mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}
- name: Run Python tests
if: env.is_fork != 'true' && matrix.task.name == 'Test'
run: |
. .venv/bin/activate
${{ matrix.task.run }}
env:
VITE_SERVER: ${{ secrets.VITE_SERVER }}
VITE_DB_USER: ${{ secrets.VITE_DB_USER }}
VITE_DB_PASS: ${{ secrets.VITE_DB_PASS }}
VITE_DB_PORT: ${{ secrets.VITE_DB_PORT }}
- name: ${{ matrix.task.name }}
if: matrix.task.name != 'Test'
run: |
. .venv/bin/activate
${{ matrix.task.run }}
- name: Upload package distribution files
if: matrix.task.name == 'Build'
uses: actions/upload-artifact@v3
with:
name: package
path: dist
- name: Clean up
if: always()
run: |
. .venv/bin/activate
pip uninstall -y mapepire-python
release:
name: Release
runs-on: ubuntu-latest
needs: [checks]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: |
pip install --upgrade pip setuptools wheel build
pip install -e .[dev]
- name: Prepare environment
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download package distribution files
uses: actions/download-artifact@v3
with:
name: package
path: dist
- name: Generate release notes
run: |
python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
- name: Publish package to PyPI
run: |
twine upload -u '${{ secrets.PYPI_USERNAME }}' -p '${{ secrets.PYPI_PASSWORD }}' dist/*
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
with:
body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*