-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add the CI workflows for GitHub Actions.
- Loading branch information
1 parent
00845cf
commit b165fc4
Showing
5 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <[email protected]> | ||
# SPDX-FileContributor: Yannick Dayer <[email protected]> | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
# Inspired from https://github.com/py-cov-action/python-coverage-comment-action | ||
|
||
name: Add a coverage comment to the Pull Request | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["tests"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
test: | ||
name: Send (or modify) a coverage comment | ||
runs-on: ubuntu-22.04 | ||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' | ||
permissions: | ||
# Gives the action the necessary permissions for publishing new | ||
# comments in pull requests. | ||
pull-requests: write | ||
# Gives the action the necessary permissions for editing existing | ||
# comments (to avoid publishing multiple comments in the same PR) | ||
contents: write | ||
# Gives the action the necessary permissions for looking up the | ||
# workflow that launched this workflow, and download the related | ||
# artifact that contains the comment to be published | ||
actions: read | ||
steps: | ||
# DO NOT run actions/checkout here, for security reasons | ||
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
- name: Post comment | ||
uses: py-cov-action/python-coverage-comment-action@v3 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} | ||
# Update those if you changed the default values: | ||
# COMMENT_ARTIFACT_NAME: python-coverage-comment-action | ||
# COMMENT_FILENAME: python-coverage-comment-action.txt |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <[email protected]> | ||
# SPDX-FileContributor: Yannick Dayer <[email protected]> | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
name: Publish package to Pypi | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
release-packaging: | ||
name: Package the project into a deploy-ready state | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
- name: Install python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install build dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install build | ||
- name: Package the project | ||
run: python -m build | ||
- name: Produce a GitHub actions artifact (the package) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: release-dist | ||
path: dist/ | ||
if-no-files-found: error | ||
|
||
pypi-publish: | ||
name: Upload the release package to PyPI | ||
needs: | ||
- release-packaging | ||
runs-on: ubuntu-22.04 | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/clapper | ||
permissions: | ||
id-token: write # This permission is mandatory for trusted publishing | ||
steps: | ||
- name: Retrieve the package from GitHub actions artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: release-dist | ||
path: dist | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <[email protected]> | ||
# SPDX-FileContributor: Yannick Dayer <[email protected]> | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
# Inspired from https://github.com/readthedocs/actions/tree/v1/preview | ||
|
||
name: Documentation preview on readthedocs for Pull Requests | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
[ "main" ] | ||
types: | ||
- opened | ||
paths: | ||
- "docs/**" | ||
- "src/**" # Update to the Python API pages | ||
- ".github/workflows/doc-preview.yaml" | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
documentation-links: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Modify the PR with a link to the new docs | ||
uses: readthedocs/actions/preview@v1 | ||
with: | ||
project-slug: "clapper" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <[email protected]> | ||
# SPDX-FileContributor: Yannick Dayer <[email protected]> | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
name: Check the project is up to our quality standards | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run pre commit on all modified files | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
- name: Install python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
env: | ||
SKIP: pixi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <[email protected]> | ||
# SPDX-FileContributor: Yannick Dayer <[email protected]> | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
name: Execute code tests | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, macos-14] | ||
pixi_environment: [test, test-alternative] # latest and previous python | ||
permissions: | ||
# Gives the action the necessary permissions for publishing new | ||
# comments in pull requests. | ||
pull-requests: write | ||
# Gives the action the necessary permissions for pushing data to the | ||
# python-coverage-comment-action branch, and for editing existing | ||
# comments (to avoid publishing multiple comments in the same PR) | ||
contents: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
pixi-version: v0.25.0 | ||
environments: ${{ matrix.pixi_environment }} | ||
- name: Run Tests | ||
run: pixi run test | ||
- name: Generate coverage comment # Published after job success (coverage.yaml) | ||
id: coverage_comment | ||
uses: py-cov-action/python-coverage-comment-action@v3 | ||
with: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
- name: Store Pull Request comment to be posted | ||
uses: actions/upload-artifact@v4 | ||
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | ||
with: | ||
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly | ||
name: python-coverage-comment-action | ||
# If you use a different name, update COMMENT_FILENAME accordingly | ||
path: python-coverage-comment-action.txt | ||
|
||
doc: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
pixi-version: v0.25.0 | ||
environments: doc | ||
- name: Build docs | ||
run: pixi run doc | ||
- name: Run doctests | ||
run: pixi run doctest |