Skip to content

Commit

Permalink
Merge pull request #24 from malik-irain/github-actions-simplification
Browse files Browse the repository at this point in the history
GitHub actions simplification
  • Loading branch information
seb5g authored Dec 6, 2024
2 parents 8063640 + e0c57c1 commit 17c7456
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 155 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/Testbase.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/Testbase_win.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp310.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp311.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp311_win.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp312.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp38.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/Testp39.yml

This file was deleted.

177 changes: 177 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: tests

on:
workflow_call:

pull_request:

push:
branches:
- '*'
- '!badges' # to exclude execution if someone pushes on this branch (shouldn't happen)

concurrency:
# github.workflow: name of the workflow
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true

jobs:
tests:
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
# Get the branch name for the badge generation
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
id: extract_branch


- name: Checkout the repo
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-xdist wheel numpy h5py
pip install -e .
# Create folder and set permissions on Ubuntu
- name: Create local pymodaq folder (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo mkdir -p /etc/.pymodaq
sudo chmod uo+rw /etc/.pymodaq
- name: Linting with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
- name: Tests with ${{ matrix.os }} ${{ matrix.python-version }}
id: tests
run: |
mkdir coverage
pytest --cov=pymodaq_data -n 1
mv .coverage coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}



- name: Create destination directory
if: ${{ always() }}
run: |
mkdir -p "${{ steps.extract_branch.outputs.branch }}"
- name: generate badge (success)
if: ${{ success() }}
uses: emibcn/[email protected]
with:
label: ''
status: 'passing'
color: 'green'
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'
- name: generate badge (fail)
if: ${{ failure() }}
uses: emibcn/[email protected]
with:
label: ''
status: 'failing'
color: 'red'
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'


- name: Upload badge artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: tests_${{runner.os}}_${{matrix.python-version}}
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'
if-no-files-found: error

outputs:
branch: ${{ steps.extract_branch.outputs.branch }}

badge-update:
runs-on: ubuntu-latest
needs: tests # Ensure this job runs after all matrix jobs complete
steps:
# switch to badges branches to commit
- uses: actions/checkout@v4
with:
ref: badges

- name: Download badges
uses: actions/download-artifact@v4

- name: Reorganize badges
run: |
rm -rf coverage* || true
rm -rf $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
git rm $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
mkdir -p '${{ needs.tests.outputs.branch }}'
mv tests_*/*.svg '${{ needs.tests.outputs.branch }}'
- name: Commit badges
continue-on-error: true
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ${{ needs.tests.outputs.branch }}
git commit --allow-empty -m "Add/Update badge"
- name: Push badges
uses: ad-m/github-push-action@master
if: ${{ success() }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges
coverage-update:
runs-on: ubuntu-latest
needs: tests # Ensure this job runs after all matrix jobs complete

steps:
- name: Checkout the repo
uses: actions/[email protected]

- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
path: ./coverage-reports

- name: Reorganize reports
run: |
cd coverage-reports
rm -rf tests_*
for folder in *; do
mv "${folder}"/* .;
done;
rmdir --ignore-fail-on-non-empty * || true
cd ..
# We only combine linux reports otherwise the tool complains about windows directories ...
- name: Combine coverage reports
run: |
python -m pip install coverage
coverage combine ./coverage-reports/coverage_*
coverage xml -i
- name: Upload combined coverage report to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
57 changes: 33 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,47 @@ PyMoDAQ Data
:target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
:alt: Documentation Status

.. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_data/branch/0.0.x/graph/badge.svg?token=IQNJRCQDM2
:target: https://codecov.io/gh/PyMoDAQ/pymodaq_data
.. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_data/graph/badge.svg?token=H32JflMEYR
:target: https://codecov.io/gh/PyMoDAQ/pymodaq_data

====== ======= ======
Python OS Passed
====== ======= ======
3.8 Linux |38|
3.9 Linux |39|
3.10 Linux |310|
3.11 Linux |311|
3.12 Linux |312|
3.11 Windows |311win|
====== ======= ======
+-------------+-------------+---------------+
| | Linux | Windows |
+=============+=============+===============+
| Python 3.9 | |39-linux| | |39-windows| |
+-------------+-------------+---------------+
| Python 3.10 | |310-linux| | |310-windows| |
+-------------+-------------+---------------+
| Python 3.11 | |311-linux| | |311-windows| |
+-------------+-------------+---------------+
| Python 3.12 | |312-linux| | |312-windows| |
+-------------+-------------+---------------+


.. |38| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp38.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp385.yml

.. |39| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp39.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp39.yml

.. |310| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp310.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp310.yml
.. |39-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Linux_3.9.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |311| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp311.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp311.yml
.. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Linux_3.10.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |312| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp312.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp312.yml
.. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Linux_3.11.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |311win| image:: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp311_win.yml/badge.svg?branch=0.0.x_dev
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/Testp311_win.yml
.. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Linux_3.12.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |39-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Windows_3.9.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Windows_3.10.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Windows_3.11.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml

.. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/pymodaq_data/badges/5.0.x_dev/tests_Windows_3.12.svg
:target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests.yml



Expand Down
Loading

0 comments on commit 17c7456

Please sign in to comment.