From 80313920c1acaac3dd1faf1fbddd622ddd11aed9 Mon Sep 17 00:00:00 2001 From: Malik Irain Date: Thu, 27 Nov 2025 14:43:50 +0100 Subject: [PATCH 1/2] tests with badges showing in README --- .github/workflows/tests-utils.yml | 118 -------------------- .github/workflows/tests.yml | 175 ++++++++++++++++++++++++++++++ README.rst | 44 ++++++++ 3 files changed, 219 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/tests-utils.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests-utils.yml b/.github/workflows/tests-utils.yml deleted file mode 100644 index ce9eb72..0000000 --- a/.github/workflows/tests-utils.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: Test for pymodaq_utils - -on: - workflow_dispatch: - workflow_call: - - pull_request: - paths: - - 'src/serializall/**' - push: - paths: - - 'src/serializall/**' - branches: - - '*' - -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", "3.13"] - runs-on: ${{ matrix.os }} - - steps: - - # As we work on packages/ checkout needs to be first - # to ensure folder existence - - name: Checkout the repo - uses: actions/checkout@v5.0.0 - with: - fetch-depth: 0 - - # 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: Create badge destination directory - run: | - mkdir -p "${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}" - echo ${{ github.workspace }} - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6.0.0 - 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 . - - - 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 ${{ github.workspace }}/coverage - pytest --cov=pymodaq_utils --ignore-glob='*legacy*' - mv .coverage ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }} - - - - name: Upload coverage artifact - uses: actions/upload-artifact@v4.6.2 - with: - name: coverage-${{ matrix.os }}-${{ matrix.python-version }} - path: ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }} - - outputs: - branch: ${{ steps.extract_branch.outputs.branch }} - - coverage-update: - runs-on: ubuntu-latest - needs: tests # Ensure this job runs after all matrix jobs complete - - steps: - - name: Checkout the repo - uses: actions/checkout@v5.0.0 - - - name: Download all coverage artifacts - uses: actions/download-artifact@v5.0.0 - 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 .. - - 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/codecov-action@v5.5.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.xml \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..9dc12d0 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,175 @@ +name: Test for serializall + +on: + workflow_dispatch: + workflow_call: + pull_request: + push: + +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", "3.13"] + runs-on: ${{ matrix.os }} + + steps: + + # As we work on packages/ checkout needs to be first + # to ensure folder existence + - name: Checkout the repo + uses: actions/checkout@v5.0.0 + with: + fetch-depth: 0 + + # 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: Create badge destination directory + run: | + mkdir -p "${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}" + echo ${{ github.workspace }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6.0.0 + 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 . + + - 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 ${{ github.workspace }}/coverage + pytest --cov=serializall + mv .coverage ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }} + + + # - name: Upload coverage artifact + # uses: actions/upload-artifact@v4.6.2 + # with: + # name: coverage-${{ matrix.os }}-${{ matrix.python-version }} + # path: ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }} + + - name: generate badge (success) + if: ${{ success() }} + uses: emibcn/badge-action@v2.0.3 + with: + label: '' + status: 'passing' + color: 'green' + path: '${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg' + + - name: generate badge (fail) + if: ${{ failure() }} + uses: emibcn/badge-action@v2.0.3 + with: + label: '' + status: 'failing' + color: 'red' + path: '${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg' + + + - name: Upload badge artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4.6.2 + with: + name: tests_${{runner.os}}_${{matrix.python-version}} + path: '${{ github.workspace }}/${{ 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: + if: github.repository == 'PyMoDAQ/serializall' && !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) + 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@v5.0.0 + with: + ref: badges + + - name: Download badges + uses: actions/download-artifact@v6.0.0 + + - 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 "action@github.com" + 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@v1.0.0 + 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/checkout@v5.0.0 + + # - name: Download all coverage artifacts + # uses: actions/download-artifact@v5.0.0 + # 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 .. + # - 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/codecov-action@v5.5.1 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # files: coverage.xml \ No newline at end of file diff --git a/README.rst b/README.rst index 1eb8160..22ec84a 100644 --- a/README.rst +++ b/README.rst @@ -12,6 +12,50 @@ serialization using builtins (see example). It is currently used in projects such as PyMoDAQ and pyqtgraph. + +Compatibility ++++++++++++++ + ++-------------+-------------+---------------+ +| | 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| | ++-------------+-------------+---------------+ + + + + + +.. |39-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.9.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.10.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.11.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.12.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |39-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.9.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.10.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.11.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + +.. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.12.svg + :target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml + Usage +++++ From 897985d9d931da4788c81a154a94c79053d75e5e Mon Sep 17 00:00:00 2001 From: Malik Irain Date: Thu, 27 Nov 2025 16:48:32 +0100 Subject: [PATCH 2/2] Update badge upload --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9dc12d0..e149c27 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,10 +1,12 @@ name: Test for serializall on: - workflow_dispatch: 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 @@ -105,7 +107,7 @@ jobs: branch: ${{ steps.extract_branch.outputs.branch }} badge-update: - if: github.repository == 'PyMoDAQ/serializall' && !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) + if: github.repository == 'PyMoDAQ/serializall' && !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) && startsWith(github.ref, 'refs/heads/') runs-on: ubuntu-latest needs: tests # Ensure this job runs after all matrix jobs complete steps: