Python package #950
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: [ master, development ] | |
pull_request: | |
branches: [ master, development ] | |
release: | |
branches: [ master, development ] | |
# release types see : https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release | |
# he prereleased type will not trigger for pre-releases published from draft releases, but the published type will trigger. | |
# If you want a workflow to run when stable and pre-releases publish, subscribe to published instead of released and prereleased. | |
types: [published] | |
schedule: | |
# * is a special character in YAML, so you have to quote this string | |
# | minute | hour (UTC) | day of month (1-31) | month (1-2) | day of week (0-6 or SUN-SAT) | |
# every day at 05:40 am UTC - avoid 05:00 because of high load at the beginning of every hour | |
- cron: '40 5 * * *' | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
env: | |
# prefix before commands - used for wine, there the prefix is "wine" | |
cPREFIX: "" | |
# command to launch python interpreter (it's different on macOS, there we need python3) | |
cPYTHON: "python" | |
# command to launch pip (it's different on macOS, there we need pip3) | |
cPIP: "python -m pip" | |
# switch off wine fix me messages | |
WINEDEBUG: fixme-all | |
# PYTEST | |
PYTEST_DO_TESTS: "True" | |
# FLAKE8 tests | |
DO_FLAKE8_TESTS: "True" | |
# MYPY tests | |
MYPY_DO_TESTS: "True" | |
MYPY_OPTIONS: "--follow-imports=normal --ignore-missing-imports --implicit-reexport --install-types --no-warn-unused-ignores --non-interactive --strict" | |
MYPYPATH: "./.3rd_party_stubs" | |
# coverage | |
DO_COVERAGE: "True" | |
DO_COVERAGE_UPLOAD_CODECOV: "True" | |
DO_COVERAGE_UPLOAD_CODE_CLIMATE: "True" | |
# package name | |
PACKAGE_NAME: "rst_include" | |
# the registered CLI Command | |
CLI_COMMAND: "rst_include" | |
# the source file for rst_include (rebuild rst file includes) | |
RST_INCLUDE_SOURCE: "./.docs/README_template.rst" | |
# the target file for rst_include (rebuild rst file includes) | |
RST_INCLUDE_TARGET: "./README.rst" | |
# make Code Coverage Secret available in Environment | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
# make PyPi Password available in Environment | |
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
strategy: | |
matrix: | |
include: | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software | |
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#available-versions-of-python-and-pypy | |
- os: windows-latest | |
python-version: "3.11" | |
env: | |
cEXPORT: "SET" | |
BUILD_DOCS: "False" | |
BUILD: "False" | |
BUILD_TEST: "False" | |
MYPY_DO_TESTS: "True" | |
# Setup tests | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
# Test registered CLI Command | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "3.8" | |
env: | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "3.9" | |
env: | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "3.10" | |
env: | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "3.11" | |
env: | |
BUILD_DOCS: "True" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "3.12-dev" | |
env: | |
BUILD_DOCS: "True" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "pypy-3.9" | |
env: | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: ubuntu-latest | |
python-version: "pypy-3.10" | |
env: | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
DO_CLI_TEST: "True" | |
- os: macos-latest | |
python-version: "3.11" | |
env: | |
cPREFIX: "" # prefix before commands - used for wine, there the prefix is "wine" | |
cPYTHON: "python3" # command to launch python interpreter (it's different on macOS, there we need python3) | |
cPIP: "python3 -m pip" # command to launch pip (it's different on macOS, there we need pip3) | |
BUILD_DOCS: "False" | |
BUILD: "True" | |
BUILD_TEST: "True" | |
MYPY_DO_TESTS: "True" | |
# Setup tests | |
DO_SETUP_INSTALL: "True" | |
DO_SETUP_INSTALL_TEST: "True" | |
# Test registered CLI Command | |
DO_CLI_TEST: "True" | |
name: "${{ matrix.os }} Python ${{ matrix.python-version }}" | |
steps: | |
# see : https://github.com/actions/checkout | |
- uses: actions/checkout@v3 | |
- name: Setting up Python ${{ matrix.python-version }} | |
# see: https://github.com/actions/setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
# see: https://github.community/t/github-actions-new-bug-unable-to-create-environment-variables-based-matrix/16104/3 | |
env: ${{ matrix.env }} # make matrix env variables accessible | |
# lib_cicd_github install: upgrades pip, setuptools, wheel and pytest-pycodestyle | |
run: | | |
${{ env.cPIP }} install git+https://github.com/bitranox/lib_cicd_github.git | |
lib_cicd_github install | |
- name: Debug - printenv and colortest | |
env: | |
# make matrix env variables accessible | |
${{ matrix.env }} | |
shell: bash | |
run: | | |
# export for current step | |
export "BRANCH=$(lib_cicd_github get_branch)" | |
# export for subsequent steps | |
echo "BRANCH=$BRANCH" >> $GITHUB_ENV | |
log_util --level=SPAM "working on branch $BRANCH" | |
log_util --level=SPAM "GITHUB_REF $GITHUB_REF" | |
log_util --level=VERBOSE "github.base_ref: ${{ github.base_ref }}" | |
log_util --level=VERBOSE "github.event: ${{ github.event }}" | |
log_util --level=VERBOSE "github.event_name: ${{ github.event_name }}" | |
log_util --level=VERBOSE "github.head_ref: ${{ github.head_ref }}" | |
log_util --level=VERBOSE "github.job: ${{ github.job }}" | |
log_util --level=VERBOSE "github.ref: ${{ github.ref }}" | |
log_util --level=VERBOSE "github.repository: ${{ github.repository }}" | |
log_util --level=VERBOSE "github.repository_owner: ${{ github.repository_owner }}" | |
log_util --level=VERBOSE "runner.os: ${{ runner.os }}" | |
log_util --level=VERBOSE "matrix.python-version: ${{ matrix.python-version }}" | |
printenv | |
log_util --colortest | |
- name: Run Tests | |
env: | |
# make matrix env variables accessible | |
${{ matrix.env }} | |
shell: bash | |
run: | | |
# export for current step | |
export "BRANCH=$(lib_cicd_github get_branch)" | |
# export for subsequent steps | |
echo "BRANCH=$BRANCH" >> $GITHUB_ENV | |
# run the tests | |
lib_cicd_github script | |
- name: After Success | |
env: | |
${{matrix.env }} | |
shell: bash | |
continue-on-error: true | |
run: | | |
lib_cicd_github after_success | |
- name: Deploy | |
env: | |
# see: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context | |
# see : https://github.com/rlespinasse/github-slug-action | |
# make matrix env variables accessible | |
${{matrix.env }} | |
shell: bash | |
run: | | |
lib_cicd_github deploy |