From f511ee0530577a5c44cc44ce5de4d7c068655a07 Mon Sep 17 00:00:00 2001 From: dynobo Date: Mon, 24 Jun 2024 13:18:08 +0200 Subject: [PATCH] cicd: add actions --- .github/workflows/python.yml | 64 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 3 ++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..c2ef4cb --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,64 @@ +name: Test +on: [push, pull_request] + +concurrency: + group: cicd-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: pip install '.[dev]' + - name: Format + run: ruff format --check . + - name: Lint + run: ruff check . + - name: Type + run: mypy + - name: Test + run: pytest + - name: Upload test charts + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-charts + path: tests/*.jpg + if-no-files-found: warn + retention-days: 14 + publish: + name: Build & Publish + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + # Used to authenticate to PyPI via OIDC. + # Used to sign the release's artifacts with sigstore-python. + id-token: write + # Used to attach signing artifacts to the published release. + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.9" + - name: Install build deps + run: pip install --upgrade build + - name: Build Python package + run: python -m build + - name: Publish to PyPi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + print-hash: true diff --git a/pyproject.toml b/pyproject.toml index 9937aea..13d8f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ ] dependencies = ["matplotlib", "numpy", "scipy", "statsmodels"] optional-dependencies = { dev = [ + "build", "linearmodels", "mypy", "notebook", @@ -48,6 +49,8 @@ files = ["lmdiag/**/*.py", "tests/**/*.py"] exclude = ["build/"] follow_imports = "skip" ignore_missing_imports = true +# ONHOLD: Remove cache_dir once https://github.com/python/mypy/issues/17396 is fixed +cache_dir = "/dev/null" [tool.ruff] target-version = "py39"