Skip to content

Commit

Permalink
ci: Update Github workflows
Browse files Browse the repository at this point in the history
- Unify formatting of YAML files
- Use updated default / third-party actions
- Set up PyPI trusted publisher
  • Loading branch information
Wuestengecko committed Jun 7, 2024
1 parent d5a7478 commit be35d16
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 102 deletions.
139 changes: 74 additions & 65 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,80 @@
name: Build

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

jobs:
test:
name: Test with Python ${{matrix.python_version}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python_version:
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python_version}}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{runner.os}}-pip-${{hashFiles('pyproject.toml')}}
restore-keys: |
${{runner.os}}-pip-
${{runner.os}}-
- name: Upgrade Pip
run: |-
python -m pip install -U pip
- name: Install test dependencies
run: |-
python -m pip install '.[test]'
- name: Run unit tests
run: |-
python -m pytest --cov-report=term --cov=capella_ros_tools --rootdir=.
test:
name: Test with Python ${{matrix.python_version}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python_version:
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: ${{matrix.python_version}}
- name: Upgrade Pip
run: python -m pip install -U pip
- name: Install test dependencies
run: python -m pip install '.[test]'
- name: Run unit tests
run: python -m pytest --cov-report=term --cov=capella_ros_tools --rootdir=.

publish:
name: Publish artifacts
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |-
python -m pip install -U pip
python -m pip install build twine
- name: Build packages
run: |-
python -m build
- name: Verify packages
run: |-
python -m twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v2
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/*
build:
name: Build wheel
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: "3.10"
- name: Install dependencies
run: python -m pip install -U pip build twine
- name: Build packages
run: python -m build
- name: Verify packages
run: python -m twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: error
pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master'
environment:
name: pypi
url: https://pypi.org/c/capella-ros-tools
permissions:
id-token: write
steps:
- name: Download built wheel
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
8 changes: 4 additions & 4 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
conventional-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install commitlint
run: npm install -g @commitlint/cli
run: npm install -g @commitlint/cli @commitlint/config-conventional
- name: Validate commit messages
id: conventional-commits
env:
Expand All @@ -30,11 +30,11 @@ jobs:
exit $r
- name: Post comment if validation failed
if: always() && steps.conventional-commits.outcome == 'failure'
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
TEXT: |-
The pull request does not conform to the conventional commit specification. Please ensure that your commit messages follow the spec: <https://www.conventionalcommits.org/>.
We also strongly recommend that you set up your development environment with pre-commit, as described in our [CONTRIBUTING guidelines](https://github.com/DSD-DBS/capella-ros-tools/blob/master/CONTRIBUTING.md). This will run all the important checks right before you commit your changes, and avoids lengthy CI wait time and round trips.
We also strongly recommend that you set up your development environment with pre-commit, as described in our [Contributing guidelines](https://github.com/DSD-DBS/capella-ros-tools/blob/master/CONTRIBUTING.md). This will run all the important checks right before you commit your changes, and avoids lengthy CI wait time and round trips.
This is the commit validation log:
```
Expand Down
74 changes: 41 additions & 33 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,46 @@
name: Docs

on:
workflow_dispatch:
push:
branches: [master]
workflow_dispatch:
push:
branches: [master]
pull_request:

jobs:
sphinx:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: "3.12"
- name: Upgrade pip
run: python -m pip install -U pip
- name: Install dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install '.[docs]'
- name: Auto-generate APIDOC sources
run: make -C docs apidoc
- name: Create docs
run: make -C docs html
- name: Deploy
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
force_orphan: true
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html
sphinx:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- 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 dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install '.[docs]'
- name: Auto-generate APIDOC sources
run: make -C docs apidoc
- name: Create docs
run: make -C docs html
- name: Upload built docs as artifact
uses: actions/upload-artifact@v4
with:
name: Documentation
path: docs/build/html
if-no-files-found: error
retention-days: 5
- name: Deploy
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
force_orphan: true
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html

0 comments on commit be35d16

Please sign in to comment.