Bump actions/upload-artifact from 3 to 4 #27
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: CICD | |
on: | |
push: | |
branches: [main, 'develop/*'] | |
tags: [v*] | |
pull_request: | |
branches: [main, develop] | |
concurrency: | |
group: check-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
analyze: | |
# Run only if pushing on main | |
if: github.ref_name == 'main' && github.event_name == 'push' | |
name: Analyze | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [ 'python' ] | |
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] | |
# Learn more: | |
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Initializes the CodeQL tools for scanning. | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: ${{ matrix.language }} | |
# If you wish to specify custom queries, you can do so here or in a config file. | |
# By default, queries listed here will override any specified in a config file. | |
# Prefix the list here with "+" to use these queries and those in the config file. | |
# queries: ./path/to/local/query, your-org/your-repo/queries@main | |
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | |
# If this step fails, then you should remove it and run the build manually (see below) | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v2 | |
# ℹ️ Command-line programs to run using the OS shell. | |
# 📚 https://git.io/JvXDl | |
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | |
# and modify them (or add more) to build your code if your project | |
# uses a compiled language | |
#- run: | | |
# make bootstrap | |
# make release | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
test: | |
name: test ${{ matrix.py }} - ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
py: | |
- "3.11" | |
- "3.10" | |
- "3.9" | |
os: | |
- ubuntu-20.04 | |
- ubuntu-22.04 | |
# - macos-12 | |
# - windows-2022 | |
steps: | |
- name: Setup Vim for some tests | |
uses: rhysd/action-setup-vim@v1 | |
- name: Setup python for github-ssh-auth | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install tox | |
run: python -m pip install tox | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup python for test ${{ matrix.py }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Pick environment to run | |
run: | | |
import codecs; import os; import platform; import sys | |
env = 'TOXENV=py{}{}{}'.format("" if platform.python_implementation() == "CPython" else "py", sys.version_info.major, sys.version_info.minor) | |
print("Picked: {} for {} based of {}".format(env, sys.version, sys.executable)) | |
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler: | |
file_handler.write(env) | |
shell: python | |
- name: Setup test suite | |
run: tox -vv --notest | |
- name: Run test suite | |
run: tox --skip-pkg-install | |
env: | |
PYTEST_ADDOPTS: "-vv --durations=20" | |
DIFF_AGAINST: HEAD | |
- name: Rename coverage report file | |
run: import os; import sys; os.rename(".tox/.coverage.{}".format(os.environ['TOXENV']), ".tox/.coverage.{}-{}.format(os.environ['TOXENV'], sys.platform)") | |
shell: python | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data | |
path: ".tox/.coverage.*" | |
coverage: | |
name: Combine coverage | |
runs-on: ubuntu-22.04 | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install tox | |
run: python -m pip install tox | |
- name: Setup coverage tool | |
run: tox -e coverage --notest | |
- name: Install package builder | |
run: python -m pip install build | |
- name: Build package | |
run: pyproject-build --wheel . | |
- name: Download coverage data | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-data | |
path: .tox | |
- name: Combine and report coverage | |
run: tox -e coverage | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report | |
path: .tox/htmlcov | |
check: | |
name: ${{ matrix.tox_env }} - ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- windows-2022 | |
tox_env: | |
- dev | |
# - docs | |
- readme | |
exclude: | |
- { os: windows-2022, tox_env: readme } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python "3.10" | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install tox | |
run: python -m pip install tox | |
- name: Setup test suite | |
run: tox -vv --notest -e ${{ matrix.tox_env }} | |
- name: Run test suite | |
run: tox --skip-pkg-install -e ${{ matrix.tox_env }} | |
publish: | |
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI | |
needs: [ check, coverage, analyze ] | |
runs-on: ubuntu-22.04 | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
steps: | |
- name: Setup python to build package | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install build | |
run: python -m pip install build | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build sdist and wheel | |
run: python -m build -s -w . -o dist | |
- name: Publish distribution 📦 to Test PyPI | |
if: ${{ contains(fromJson('["develop", "main"]'), github.event.pull_request.base.ref) }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish distribution 📦 to PyPI | |
if: startsWith(github.ref, 'refs/tags') && !endsWith(github.ref, 'dev') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |