From c6e2aa161528680087106b0d04d5ca3ff4939aac Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:14:11 +0100 Subject: [PATCH 01/11] Fix CI (use astral-sh/setup-uv) --- .github/workflows/test_on_push.yml | 48 ++++++++---------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index f0644d0..1d425f7 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -12,15 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - name: Set up uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: - uv-venv: ".venv" + version: "latest" - name: Check style run: | @@ -41,16 +36,11 @@ jobs: - name: Checkout pybamm-cookie uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - id: setup-python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Set up uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: - uv-venv: ".venv" + version: "latest" + python-version: ${{ matrix.python-version }} - name: Install nox run: uv pip install nox[uv] @@ -84,15 +74,10 @@ jobs: with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - name: Set up uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: - uv-venv: ".venv" + version: "latest" - name: Install nox run: uv pip install nox[uv] @@ -122,15 +107,11 @@ jobs: - name: Checkout pybamm-cookie uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Set up uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: - uv-venv: ".venv" + version: "latest" + python-version: ${{ matrix.python-version }} - name: Install copier and jinja2_time run: uv pip install copier jinja2-time @@ -156,15 +137,10 @@ jobs: with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - name: Set up uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: - uv-venv: ".venv" + version: "latest" - name: Install nox uses: wntrblm/nox@2024.10.09 From 06f26db71544cf571150414d081d32fd638941d8 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:25:22 +0100 Subject: [PATCH 02/11] trying uvx --- .github/workflows/test_on_push.yml | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 1d425f7..e768164 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -19,8 +19,7 @@ jobs: - name: Check style run: | - uv pip install pre-commit - pre-commit run -a + uvx pre-commit run -a template_test: needs: style @@ -43,7 +42,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install nox - run: uv pip install nox[uv] + run: uv tool install nox - name: Set up Git run: | @@ -79,16 +78,13 @@ jobs: with: version: "latest" - - name: Install nox - run: uv pip install nox[uv] - - name: Set up Git run: | git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Check if the documentation can be built - run: nox -s docs + run: uvx nox -s docs generated_project_tests: needs: [template_test] @@ -113,18 +109,14 @@ jobs: version: "latest" python-version: ${{ matrix.python-version }} - - name: Install copier and jinja2_time - run: uv pip install copier jinja2-time - - name: Generate project - run: | - copier copy . ../ --data project_name=pybamm-${{ matrix.backend }}-${{ matrix.vcs }} --data project_slug=pybamm_${{ matrix.backend }}_${{ matrix.vcs }} --data backend=${{ matrix.backend }} --data vcs=${{ matrix.vcs }} --trust --defaults + run: uvx copier copy . ../ --data project_name=pybamm-${{ matrix.backend }}-${{ matrix.vcs }} --data project_slug=pybamm_${{ matrix.backend }}_${{ matrix.vcs }} --data backend=${{ matrix.backend }} --data vcs=${{ matrix.vcs }} --trust --defaults - name: Install nox uses: wntrblm/nox@2024.10.09 - name: Test the generated project working-directory: ../pybamm-${{ matrix.backend }}-${{ matrix.vcs }} - run: nox -s generated-project-tests + run: uvx nox -s generated-project-tests run_generated_project_doctests: needs: [template_test] @@ -142,13 +134,8 @@ jobs: with: version: "latest" - - name: Install nox - uses: wntrblm/nox@2024.10.09 - - name: Install copier and jinja2_time and generate a template with default values - run: | - uv pip install copier jinja2-time - copier copy . . --trust --defaults + run: uvx copier copy . . --trust --defaults - name: Set up Git run: | @@ -160,4 +147,4 @@ jobs: run: | git add . git commit -am "initial commit" - nox -s docs + uvx nox -s docs From 26956e4e4d2a1166fd284a27a21db816726f26fa Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:39:47 +0100 Subject: [PATCH 03/11] try python-version --- .github/workflows/test_on_push.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index e768164..ebd1efb 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -109,14 +109,15 @@ jobs: version: "latest" python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: uv pip install copier jinja2_time nox[uv] + - name: Generate project - run: uvx copier copy . ../ --data project_name=pybamm-${{ matrix.backend }}-${{ matrix.vcs }} --data project_slug=pybamm_${{ matrix.backend }}_${{ matrix.vcs }} --data backend=${{ matrix.backend }} --data vcs=${{ matrix.vcs }} --trust --defaults - - name: Install nox - uses: wntrblm/nox@2024.10.09 + run: copier copy . ../ --data project_name=pybamm-${{ matrix.backend }}-${{ matrix.vcs }} --data project_slug=pybamm_${{ matrix.backend }}_${{ matrix.vcs }} --data backend=${{ matrix.backend }} --data vcs=${{ matrix.vcs }} --trust --defaults - name: Test the generated project working-directory: ../pybamm-${{ matrix.backend }}-${{ matrix.vcs }} - run: uvx nox -s generated-project-tests + run: nox -s generated-project-tests run_generated_project_doctests: needs: [template_test] @@ -128,14 +129,19 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + python-version: 3.12 - name: Set up uv uses: astral-sh/setup-uv@v5 with: version: "latest" + + + - name: Install dependencies + run: uv pip install copier jinja2_time nox[uv] - name: Install copier and jinja2_time and generate a template with default values - run: uvx copier copy . . --trust --defaults + run: copier copy . . --trust --defaults - name: Set up Git run: | @@ -147,4 +153,4 @@ jobs: run: | git add . git commit -am "initial commit" - uvx nox -s docs + nox -s docs From e5850ad70c2d472fc8df0b3deeaa8e7e4406a179 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 19:39:55 +0000 Subject: [PATCH 04/11] style: pre-commit fixes --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ebd1efb..48ddcc3 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -135,7 +135,7 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "latest" - + - name: Install dependencies run: uv pip install copier jinja2_time nox[uv] From d097089555cba78070d0159544b28478e1cb59f7 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:44:42 +0100 Subject: [PATCH 05/11] uv tool --- .github/workflows/test_on_push.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 48ddcc3..2497821 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -110,7 +110,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies - run: uv pip install copier jinja2_time nox[uv] + run: | + uv pip install copier jinja2_time + uv tool install nox - name: Generate project run: copier copy . ../ --data project_name=pybamm-${{ matrix.backend }}-${{ matrix.vcs }} --data project_slug=pybamm_${{ matrix.backend }}_${{ matrix.vcs }} --data backend=${{ matrix.backend }} --data vcs=${{ matrix.vcs }} --trust --defaults @@ -136,9 +138,10 @@ jobs: with: version: "latest" - - name: Install dependencies - run: uv pip install copier jinja2_time nox[uv] + run: | + uv pip install copier jinja2_time + uv tool install nox - name: Install copier and jinja2_time and generate a template with default values run: copier copy . . --trust --defaults From 07200fa71165997296abcc0bd021f8b2f1e724db Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:48:09 +0100 Subject: [PATCH 06/11] oops, forgot a python-version --- .github/workflows/test_on_push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 2497821..fbedc25 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -137,6 +137,7 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "latest" + python-version: 3.12 - name: Install dependencies run: | From ec5053058a5e75c3e502e441236d65f578cb599a Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:54:39 +0100 Subject: [PATCH 07/11] enable cache --- .github/workflows/test_on_push.yml | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index fbedc25..394f5dd 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -7,6 +7,17 @@ on: branches: - main +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +env: + # The "FORCE_COLOR" variable, when set to 1, + # tells Nox to colorize itself. + FORCE_COLOR: "1" + jobs: style: runs-on: ubuntu-latest @@ -16,6 +27,8 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "latest" + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" - name: Check style run: | @@ -40,6 +53,8 @@ jobs: with: version: "latest" python-version: ${{ matrix.python-version }} + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" - name: Install nox run: uv tool install nox @@ -50,11 +65,11 @@ jobs: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Test template generation - run: nox -s template-tests + run: nox -s template-tests --verbose - name: Run coverage tests if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' - run: nox -s coverage + run: nox -s coverage --verbose - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' @@ -77,6 +92,8 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "latest" + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" - name: Set up Git run: | @@ -84,7 +101,7 @@ jobs: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Check if the documentation can be built - run: uvx nox -s docs + run: uvx nox -s docs --verbose generated_project_tests: needs: [template_test] @@ -108,6 +125,8 @@ jobs: with: version: "latest" python-version: ${{ matrix.python-version }} + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" - name: Install dependencies run: | @@ -119,7 +138,7 @@ jobs: - name: Test the generated project working-directory: ../pybamm-${{ matrix.backend }}-${{ matrix.vcs }} - run: nox -s generated-project-tests + run: nox -s generated-project-tests --verbose run_generated_project_doctests: needs: [template_test] @@ -138,6 +157,8 @@ jobs: with: version: "latest" python-version: 3.12 + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" - name: Install dependencies run: | @@ -157,4 +178,4 @@ jobs: run: | git add . git commit -am "initial commit" - nox -s docs + nox -s docs --verbose From 375bb7047cf5682e92cda8af61fab08baf1f0fe6 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:56:47 +0100 Subject: [PATCH 08/11] more uvx Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- .github/workflows/test_on_push.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 394f5dd..c96dadc 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -163,7 +163,6 @@ jobs: - name: Install dependencies run: | uv pip install copier jinja2_time - uv tool install nox - name: Install copier and jinja2_time and generate a template with default values run: copier copy . . --trust --defaults @@ -178,4 +177,4 @@ jobs: run: | git add . git commit -am "initial commit" - nox -s docs --verbose + uvx nox -s docs --verbose From 6988c96946781eabba762cd1224f3d9c20dce7cc Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 24 Dec 2024 20:59:57 +0100 Subject: [PATCH 09/11] style --- .github/workflows/test_on_push.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index c96dadc..3afba27 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -161,8 +161,7 @@ jobs: cache-dependency-glob: "**/pyproject.toml" - name: Install dependencies - run: | - uv pip install copier jinja2_time + run: uv pip install copier jinja2_time - name: Install copier and jinja2_time and generate a template with default values run: copier copy . . --trust --defaults From 8517f3a85a61610b0e1df1a7cc748147e5545c12 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 25 Dec 2024 10:26:44 +0100 Subject: [PATCH 10/11] whole colour spectrum Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 3afba27..e8558a1 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -16,7 +16,7 @@ concurrency: env: # The "FORCE_COLOR" variable, when set to 1, # tells Nox to colorize itself. - FORCE_COLOR: "1" + FORCE_COLOR: "3" jobs: style: From 599e6a4927da59ce02625eaffd7a1f5985c8465b Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 25 Dec 2024 10:27:30 +0100 Subject: [PATCH 11/11] update comment --- .github/workflows/test_on_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index e8558a1..24b8940 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -14,8 +14,8 @@ concurrency: cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} env: - # The "FORCE_COLOR" variable, when set to 1, - # tells Nox to colorize itself. + # This will let tools make use of the full palette of + # 256 colours. FORCE_COLOR: "3" jobs: