Skip to content

Commit

Permalink
ci: rework CI workflows (#7)
Browse files Browse the repository at this point in the history
Changed the file names to follow the same naming as clapper;
Added features from clapper's workflows:
  try packaging the project during the test workflow;
  release on GitHub will now contain the packaged distributables;
Removed the generation of unused coverage reports (junit and xml).
  • Loading branch information
Yannick-Dayer authored Jul 22, 2024
1 parent 3e2fc62 commit e35c1c8
Show file tree
Hide file tree
Showing 9 changed files with 738 additions and 225 deletions.
98 changes: 0 additions & 98 deletions .github/workflows/codeql.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Post coverage comment

on:
workflow_run:
workflows: ["build"]
workflows: ["tests"]
types:
- completed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
with:
name: release-dists
path: dist/
if-no-files-found: error

pypi-publish:
runs-on: ubuntu-22.04
Expand All @@ -61,3 +62,22 @@ jobs:

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-publish:
name: Upload the release package to GitHub Release
needs:
- release-build
runs-on: ubuntu-22.04
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
steps:
- name: Retrieve the package from GitHub actions artifacts
uses: actions/download-artifact@v4
with:
name: release-dist
path: dist/
- name: Upload the release package to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
run: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'
File renamed without changes.
File renamed without changes.
88 changes: 69 additions & 19 deletions .github/workflows/build.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

name: build
name: tests

on:
push:
Expand All @@ -25,9 +25,9 @@ jobs:
uses: prefix-dev/[email protected]
with:
pixi-version: v0.25.0
environments: self
environments: default
- name: Run Simple Tests
shell: pixi run -e self bash -e {0}
shell: pixi run -e default bash -e {0}
run: |
gridtk --help
gridtk submit --help
Expand All @@ -38,38 +38,61 @@ jobs:
gridtk delete --help
tests:
strategy:
matrix:
pixi_environment: [test, test-py311, test-py310, test-py39]
runs-on: ubuntu-22.04
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:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pixi
uses: prefix-dev/[email protected]
with:
pixi-version: v0.25.0
environments: test
environments: ${{ matrix.pixi_environment }}
- name: Run Tests
run: pixi run test-ci
run: pixi run -e ${{ matrix.pixi_environment }} test-ci
env:
COVERAGE_FILE: ".coverage.${{ matrix.pixi_environment }}"
- name: Store coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.pixi_environment }}
path: .coverage.${{ matrix.pixi_environment }}

merge-coverage:
name: Merge the coverage reports from multiple coverages
needs: tests
runs-on: ubuntu-22.04
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
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Retrieve coverage artifacts
uses: actions/download-artifact@v4
id: download
with:
pattern: coverage-*
merge-multiple: true
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true
- 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:
Expand All @@ -84,8 +107,35 @@ jobs:
pixi-version: v0.25.0
environments: doc
- name: Clean previous docs
run: pixi run doc-clean
run: pixi run -e doc doc-clean
- name: Build docs
run: pixi run doc
run: pixi run -e doc doc
- name: Run doctests
run: pixi run doctest
run: pixi run -e doc doctest

test-packaging:
name: Package the project into a distributable file
runs-on: ubuntu-22.04
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install build dependencies
run: |
pip install --upgrade pip
pip install build
- name: Package the project to the dist dir
run: python -m build
- name: Try installing from the new dists
run: pip install dist/*.whl
- name: Produce a GitHub actions artifact (the distributable package)
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
-->

[![docs](https://img.shields.io/badge/docs-stable-orange.svg)](https://gridtk.readthedocs.io/en/stable/)
[![build](https://github.com/idiap/gridtk/actions/workflows/build.yml/badge.svg)](https://github.com/idiap/gridtk/actions/workflows/build.yml)
[![tests](https://github.com/idiap/gridtk/actions/workflows/tests.yml/badge.svg)](https://github.com/idiap/gridtk/actions/workflows/tests.yml)
[![coverage](https://raw.githubusercontent.com/idiap/gridtk/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/idiap/gridtk/blob/python-coverage-comment-action-data/htmlcov/index.html)
[![repository](https://img.shields.io/badge/github-project-0000c0.svg)](https://github.com/idiap/gridtk)

Expand Down
Loading

0 comments on commit e35c1c8

Please sign in to comment.