From e63ed124152497273d8fba90c1e7e059156862fb Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:13:18 +0100 Subject: [PATCH 01/12] chain jobs --- .github/workflows/build_doc.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- .github/workflows/test.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 13ad9d9b..2dd12292 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -4,7 +4,7 @@ on: [push] jobs: doc_ubuntu: - name: Build documentation on Ubuntu + name: Build documentation runs-on: ubuntu-latest steps: - name: Checkout sources @@ -20,6 +20,6 @@ jobs: python -m pip install --upgrade pip pip3 install .[docs] - - name: Build doc + - name: Build documentation run: | sphinx-build -a docs ./build-docs \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0ccc8186..134510e7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,7 @@ jobs: with: python-version: 3.8 - - name: install dependencies [pip] + - name: Install dependencies [pip] run: | python -m pip install --upgrade pip pip install black isort @@ -41,6 +41,6 @@ jobs: run: | black . --check - - name : Check isort + - name : Check Isort run: | isort --profile black --check . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 278dfbf8..56de47b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ on: - opened - synchronize workflow_run: - workflows: ["lint"] + workflows: ["Lint"] types: - completed workflow_dispatch: From bd172073d174dabb4d73e3b411cee0d260df99a2 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:18:49 +0100 Subject: [PATCH 02/12] trigger tests only if linter worked --- .github/workflows/test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 56de47b6..1154e731 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,15 +1,6 @@ name: "Testing" on: - push: - branches: - - main - pull_request: - branches: - - main - types: - - opened - - synchronize workflow_run: workflows: ["Lint"] types: From ddfbb18921a78127787966e5919bcb98fa147947 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:21:35 +0100 Subject: [PATCH 03/12] remove dispatch --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1154e731..950509e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,6 @@ on: workflows: ["Lint"] types: - completed - workflow_dispatch: jobs: test: From 3103077f77d2cfc05874c1abc9dd3494c3193fac Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:25:09 +0100 Subject: [PATCH 04/12] remove braces in workflows names --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 134510e7..88687dbf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: "Lint" +name: Lint on: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 950509e5..5f17e577 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: "Testing" +name: Testing on: workflow_run: From 28cd5d0fd2022c39b2b60a7bfb79b3457a18eebc Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:39:52 +0100 Subject: [PATCH 05/12] test coverage chain --- .github/workflows/test.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f17e577..e20b2d42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,17 +34,36 @@ jobs: coverage run -m pytest - name: Coverage + if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} run: | coverage report coverage json + - name: Upload coverage artifact + if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.json + - name: Metadata check if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} run: | python .github/scripts/metadata_checker + upload-coverage: + runs-on: ubuntu-latest + needs: test + + steps: + - name: Download coverage artifact + uses: actions/download-artifact@v4 + with: + name: coverage-report + - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + + From 99e220c2359794a00a620cd6786101764a3b1cd3 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:45:19 +0100 Subject: [PATCH 06/12] no chain --- .github/workflows/test.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e20b2d42..4f839ba3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,23 @@ name: Testing on: - workflow_run: - workflows: ["Lint"] + push: + branches: + - main + - github-actions-test + paths: + - '**.py' + - '.github/workflows/lint.yml' + pull_request: + branches: + - main + paths: + - '**.py' + - '.github/workflows/lint.yml' types: - - completed + - opened + - synchronize + workflow_dispatch: jobs: test: @@ -54,16 +67,16 @@ jobs: upload-coverage: runs-on: ubuntu-latest needs: test - steps: - - name: Download coverage artifact + - name: Download coverage report uses: actions/download-artifact@v4 with: name: coverage-report - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + + - name: Upload to Codecov + uses: codecov/codecov-action@v4 with: + files: coverage.xml token: ${{ secrets.CODECOV_TOKEN }} From b78d9055c68908f6b41070f1df285f25e028ceed Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 17:52:20 +0100 Subject: [PATCH 07/12] group all jobs in one file --- .github/workflows/{test.yml => ci-cd.yml} | 29 +++++++++++++- .github/workflows/lint.yml | 46 ----------------------- 2 files changed, 28 insertions(+), 47 deletions(-) rename .github/workflows/{test.yml => ci-cd.yml} (76%) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/test.yml b/.github/workflows/ci-cd.yml similarity index 76% rename from .github/workflows/test.yml rename to .github/workflows/ci-cd.yml index 4f839ba3..48d9ded1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/ci-cd.yml @@ -1,4 +1,4 @@ -name: Testing +name: CI-CD on: push: @@ -20,7 +20,33 @@ on: workflow_dispatch: jobs: + lint: + runs-on: ubuntu-latest + name: Lint check + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies [pip] + run: | + python -m pip install --upgrade pip + pip install black isort + + - name : Check Black + run: | + black . --check + + - name : Check Isort + run: | + isort --profile black --check . + test: + needs: lint strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] @@ -67,6 +93,7 @@ jobs: upload-coverage: runs-on: ubuntu-latest needs: test + name: Upload coverage report to Codecov steps: - name: Download coverage report uses: actions/download-artifact@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 88687dbf..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - - github-actions-test - paths: - - '**.py' - - '.github/workflows/lint.yml' - pull_request: - branches: - - main - paths: - - '**.py' - - '.github/workflows/lint.yml' - types: - - opened - - synchronize - workflow_dispatch: - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies [pip] - run: | - python -m pip install --upgrade pip - pip install black isort - - - name : Check Black - run: | - black . --check - - - name : Check Isort - run: | - isort --profile black --check . From bc9cb0ddb86ed601d8c24bedf2499a9536cc9ea3 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 18:00:52 +0100 Subject: [PATCH 08/12] separate install and tests --- .github/workflows/ci-cd.yml | 43 +++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 48d9ded1..d05458c9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,4 +1,4 @@ -name: CI-CD +name: CI/CD on: push: @@ -22,7 +22,7 @@ on: jobs: lint: runs-on: ubuntu-latest - name: Lint check + name: Code Style Check ๐ŸŽจ steps: - name: Checkout repository uses: actions/checkout@v3 @@ -45,15 +45,14 @@ jobs: run: | isort --profile black --check . - test: + install: needs: lint + runs-on: ${{ matrix.os }} strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, windows-latest, macos-latest] - - name: Install and test package on ${{ matrix.os }} for Python ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} + name: Build package on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: - name: Checkout repository uses: actions/checkout@v3 @@ -63,11 +62,43 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + - name: Install package [pip] run: | python -m pip install --upgrade pip pip install .[test] + test: + needs: install + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + os: [ubuntu-latest, windows-latest, macos-latest] + + name: Run tests on ${{ matrix.os }} for Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Restore dependencies from cache + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} + - name: Run tests with Pytest run: | coverage run -m pytest From 5438430dbbb15c6436acb82284c2a4a379b7047f Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 18:06:37 +0100 Subject: [PATCH 09/12] fix --- .github/workflows/ci-cd.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index d05458c9..8056e304 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -52,7 +52,7 @@ jobs: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, windows-latest, macos-latest] - name: Build package on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Build package on ${{ matrix.os }} with Python ${{ matrix.python-version }} โš™๏ธ steps: - name: Checkout repository uses: actions/checkout@v3 @@ -75,6 +75,11 @@ jobs: python -m pip install --upgrade pip pip install .[test] + - name: Metadata check + if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} + run: | + python .github/scripts/metadata_checker + test: needs: install strategy: @@ -82,7 +87,7 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, windows-latest, macos-latest] - name: Run tests on ${{ matrix.os }} for Python ${{ matrix.python-version }} + name: Run tests on ${{ matrix.os }} for Python ${{ matrix.python-version }} ๐Ÿงช runs-on: ${{ matrix.os }} steps: - name: Checkout repo @@ -101,13 +106,13 @@ jobs: - name: Run tests with Pytest run: | - coverage run -m pytest + python -m coverage run -m pytest - name: Coverage if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} run: | - coverage report - coverage json + python -m coverage report + python -m coverage json - name: Upload coverage artifact if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} @@ -116,15 +121,10 @@ jobs: name: coverage-report path: coverage.json - - name: Metadata check - if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} - run: | - python .github/scripts/metadata_checker - upload-coverage: runs-on: ubuntu-latest needs: test - name: Upload coverage report to Codecov + name: Upload coverage report to Codecov ๐Ÿ“Š steps: - name: Download coverage report uses: actions/download-artifact@v4 From 7182f211050518814fa58731993f88ba31b6fc18 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Wed, 26 Feb 2025 18:13:05 +0100 Subject: [PATCH 10/12] cache after build --- .github/workflows/ci-cd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8056e304..8800fe6a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -62,6 +62,11 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install package [pip] + run: | + python -m pip install --upgrade pip + pip install .[test] + - name: Cache dependencies uses: actions/cache@v4 with: @@ -70,11 +75,6 @@ jobs: restore-keys: | ${{ runner.os }}-pip-${{ matrix.python-version }}- - - name: Install package [pip] - run: | - python -m pip install --upgrade pip - pip install .[test] - - name: Metadata check if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} run: | From e9916d4293094515fd2ce6f4054542317db01965 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet <63302082+bqth29@users.noreply.github.com> Date: Thu, 27 Mar 2025 11:57:26 +0100 Subject: [PATCH 11/12] simplify requirements --- requirements.txt | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/requirements.txt b/requirements.txt index ee072cea..bb2d8682 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,39 +1,13 @@ black==24.3.0 -click==8.1.6 -colorama==0.4.6 coverage==7.2.7 -exceptiongroup==1.1.2 -filelock==3.12.2 flake8==6.1.0 -iniconfig==2.0.0 +furo isort==5.12.0 -Jinja2==3.1.6 -MarkupSafe==2.1.3 -mccabe==0.7.0 -mpmath==1.3.0 -mypy-extensions==1.0.0 -networkx==3.1 -numpy==1.25.2 +myst-parser +numpy==1.26.4 numpydoc==1.6.0 -packaging==23.1 -pathspec==0.11.2 -platformdirs==3.10.0 -pluggy==1.2.0 -pycodestyle==2.11.0 -pyflakes==3.1.0 pytest==7.4.0 -readthedocs-sphinx-search==0.3.2 sphinx==7.1.2 -sphinx-rtd-theme==1.3.0 -sphinxcontrib-applehelp==1.0.4 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==2.0.1 -sphinxcontrib-jquery==4.1 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.5 sympy==1.12 -tomli==2.0.1 torch==2.2.0 -tqdm==4.66.3 -typing_extensions==4.7.1 \ No newline at end of file +tqdm==4.66.3 \ No newline at end of file From d9b27d0378f0ccb3939beac4ed4239fc85109dad Mon Sep 17 00:00:00 2001 From: Thomas Bouquet <63302082+bqth29@users.noreply.github.com> Date: Thu, 27 Mar 2025 12:04:28 +0100 Subject: [PATCH 12/12] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 51 ++++++++----------------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8800fe6a..e8284eda 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -45,43 +45,8 @@ jobs: run: | isort --profile black --check . - install: - needs: lint - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - os: [ubuntu-latest, windows-latest, macos-latest] - name: Build package on ${{ matrix.os }} with Python ${{ matrix.python-version }} โš™๏ธ - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package [pip] - run: | - python -m pip install --upgrade pip - pip install .[test] - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - - - name: Metadata check - if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} - run: | - python .github/scripts/metadata_checker - test: - needs: install + needs: lint strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] @@ -98,11 +63,10 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Restore dependencies from cache - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} + - name: Install package [pip] + run: | + python -m pip install --upgrade pip + pip install .[test] - name: Run tests with Pytest run: | @@ -121,6 +85,11 @@ jobs: name: coverage-report path: coverage.json + - name: Metadata check + if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }} + run: | + python .github/scripts/metadata_checker + upload-coverage: runs-on: ubuntu-latest needs: test