Upgrades proposal #366
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
name: Python package | ||
on: | ||
push: | ||
branches: | ||
tags: | ||
# pull_request: | ||
# branches: [ main ] | ||
release: | ||
types: [ published ] #, created, edited | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
project: ['target-s3-jsonl'] | ||
os: [ubuntu-latest] #, macos-latest, windows-latest | ||
python-version: [3.9, '3.10', 3.11, 3.12] | ||
# exclude: | ||
# - os: macos-latest | ||
# python-version: 3.9 | ||
# - os: macos-latest | ||
# python-version: 3.10 | ||
# - os: macos-latest | ||
# python-version: 3.12 | ||
# - os: windows-latest | ||
# python-version: 3.9 | ||
# - os: windows-latest | ||
# python-version: 3.10 | ||
# - os: windows-latest | ||
# python-version: 3.12 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache pip Linux | ||
uses: actions/cache@v4 | ||
id: cache-${{ runner.os }}-pip | ||
Check failure on line 47 in .github/workflows/python-package.yml GitHub Actions / Python packageInvalid workflow file
|
||
if: startsWith(runner.os, 'Linux') | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache pip macOS | ||
uses: actions/cache@v4 | ||
id: cache-${{ runner.os }}-pip | ||
if: startsWith(runner.os, 'macOS') | ||
with: | ||
path: ~/Library/Caches/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache pip Windows | ||
uses: actions/cache@v4 | ||
id: cache-${{ runner.os }}-pip | ||
if: startsWith(runner.os, 'Windows') | ||
with: | ||
path: ~\AppData\Local\pip\Cache | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
if: steps.cache-${{ runner.os }}-pip.outputs.cache-hit != 'true' | ||
run: | | ||
python -m venv venv || virtualenv venv | ||
. venv/bin/activate | ||
pip install --upgrade pip # setuptools | ||
# pip install .[test,lint,static,dist] | ||
pip install tox | ||
# - name: Get pip cache dir | ||
# id: pip-cache | ||
# run: | | ||
# echo "::set-output name=dir::$(pip cache dir)" | ||
# - name: Lint with flake8 | ||
# run: | | ||
# . venv/bin/activate | ||
# # stop the build if there are Python syntax errors or undefined names | ||
# # exit-zero treats all errors as warnings. The GitHub editor is 255 chars wide | ||
# flake8 | ||
# - name: Static typing with mypy | ||
# run: | | ||
# . venv/bin/activate | ||
# mypy | ||
- name: Lint with flake8 & Static typing with mypy | ||
run: | | ||
. venv/bin/activate | ||
TOX_PARALLEL_NO_SPINNER=1 tox --parallel -e lint,static | ||
- name: pip cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Test | ||
run: | | ||
. venv/bin/activate | ||
# pytest | ||
# tox --parallel | ||
tox -e py | ||
- name: Upload coverage test results to Codecov | ||
uses: codecov/codecov-action@v2 | ||
if: | | ||
${{ matrix.python-version }} == '3.9' \ | ||
&& ${{ matrix.os-version }} == 'ubuntu-latest' | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | ||
file: coverage.xml # optional | ||
flags: unittests # optional | ||
name: codecov-${{ matrix.project }} # optional | ||
env_vars: OS,PYTHON | ||
fail_ci_if_error: true # optional (default = false) | ||
verbose: false # optional (default = false) | ||
- name: Build distribution package | ||
run: | | ||
. venv/bin/activate | ||
# python setup.py sdist bdist_wheel | ||
pip install build | ||
python -m build | ||
ls -l dist | ||
- name: Publish distribution package to TestPyPI | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verify_metadata: true | ||
skip_existing: true | ||
user: __token__ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
- name: Publish distribution package | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verify_metadata: true | ||
skip_existing: true | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
- name: Uninstall Dependencies | ||
run: | | ||
. venv/bin/activate | ||
if [ -f requirements.txt ]; then pip uninstall -y -r requirements.txt; fi |