Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update ci #115

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 65 additions & 30 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
name: Build

on:
pull_request:
push:
branches: ["*"]
pull_request: [master]
branches: [main]
tags: ["v*.*.*"]
workflow_dispatch:

jobs:
test:
Expand All @@ -17,17 +18,22 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python_version: ["3.10", "3.11", "3.12"]
python_version:
- "3.10"
- "3.11"
- "3.12"
include:
- os: windows-latest
python_version: "3.11"
env:
PYTHONUTF8: 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: ${{matrix.python_version}}
- uses: actions/setup-node@v4
with:
Expand All @@ -41,40 +47,69 @@ jobs:
${{runner.os}}-pip-
${{runner.os}}-
- name: Upgrade Pip
run: |-
python -m pip install -U pip
run: python -m pip install -U pip
- name: Install test dependencies
run: |-
python -m pip install '.[test]'
run: python -m pip install '.[test]'
- name: Run unit tests
run: |-
python -m pytest --cov-report=term --cov=capellambse_context_diagrams --rootdir=.
run: python -m pytest --cov-report=term --cov=capellambse_context_diagrams --rootdir=.

publish:
name: Publish artifacts
build:
name: Build wheel
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
python-version: "3.12"
- name: Install dependencies
run: |-
python -m pip install -U pip
python -m pip install build twine
run: python -m pip install -U pip build twine
- name: Build packages
run: |-
python -m build
run: python -m build
- name: Verify packages
run: |-
python -m twine check dist/*
run: python -m twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: "3.12"
- name: Upgrade pip
run: python -m pip install -U pip
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run Pre-Commit
run: pre-commit run --all-files

pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build, test]
if: startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/project/capella-polarion
permissions:
id-token: write
steps:
- name: Download built wheel
uses: actions/download-artifact@v4
with:
name: Artifacts
path: "dist/*"
- name: Publish to PyPI (release only)
if: startsWith(github.ref, 'refs/tags/v')
run: python -m twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} --non-interactive dist/*
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Loading