From 217eb1255fd39535a751ca4fcab62a83bec2e12d Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 24 Nov 2026 17:26:13 -0700 Subject: [PATCH 1/3] Switch to using install_rail script --- .../.github/actions/install-rail/action.yml | 41 ++++++++++++++++++ .../.github/workflows/linting.yml | 39 +++++++++-------- .../.github/workflows/publish-to-pypi.yml | 42 ++++++++++++------- .../.github/workflows/smoke-test.yml | 34 +++++++-------- .../workflows/testing-and-coverage.yml | 38 +++++++++++++++++ .../workflows/testing-and-coverage.yml.jinja | 39 ----------------- python-project-template/pyproject.toml.jinja | 2 +- 7 files changed, 144 insertions(+), 91 deletions(-) create mode 100644 python-project-template/.github/actions/install-rail/action.yml create mode 100644 python-project-template/.github/workflows/testing-and-coverage.yml delete mode 100644 python-project-template/.github/workflows/testing-and-coverage.yml.jinja diff --git a/python-project-template/.github/actions/install-rail/action.yml b/python-project-template/.github/actions/install-rail/action.yml new file mode 100644 index 0000000..9c80b18 --- /dev/null +++ b/python-project-template/.github/actions/install-rail/action.yml @@ -0,0 +1,41 @@ +name: 'Install rail' +description: > + Install rail_bae and it dependencies using install_rail.py from + LSSTDESC/rail_setup (rail-packages=none installs only the pz-rail base + without any algorithm packages), then installs the local checkout on top. + +runs: + using: 'composite' + steps: + - name: System dependencies + shell: bash + run: | + sudo apt-get update + + - name: Download install_rail.py + shell: bash + run: | + curl -fsSL -o install_rail.py \ + https://raw.githubusercontent.com/LSSTDESC/rail_setup/main/install_rail.py + + - name: Install base rail dependencies via install_rail.py + shell: bash + run: | + python install_rail.py \ + --install-conda mamba \ + --env-name rail_ci \ + --rail-packages None \ + --python-version {{ $inputs.python-version }} \ + --install-devtools no + + - name: Add conda environment to PATH + shell: bash + run: | + echo "${HOME}/mambaforge/envs/rail_ci/bin" >> $GITHUB_PATH + + - name: Install local rail_base and dev extras + shell: bash + run: | + pip install . + pip install .[dev] + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi diff --git a/python-project-template/.github/workflows/linting.yml b/python-project-template/.github/workflows/linting.yml index 15333ff..3f986b3 100644 --- a/python-project-template/.github/workflows/linting.yml +++ b/python-project-template/.github/workflows/linting.yml @@ -12,22 +12,25 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12'] steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Analyze code with linter - run: | - pylint -rn -sn --recursive=y ./src - pylint -rn -sn --recursive=y ./tests - # the following line allows the CI test to pass, even if pylint fails - continue-on-error: true + - uses: actions/checkout@v3 + with: + fetch-tags: true + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install rail + uses: ./.github/actions/install-rail + with: + python-version: ${{ matrix.python-version }} + - name: Analyze code with linter + run: | + pylint -rn -sn --recursive=y ./src + pylint -rn -sn --recursive=y ./tests + # the following line allows the CI test to pass, even if pylint fails + continue-on-error: true diff --git a/python-project-template/.github/workflows/publish-to-pypi.yml b/python-project-template/.github/workflows/publish-to-pypi.yml index 9bc91d3..55f92cb 100644 --- a/python-project-template/.github/workflows/publish-to-pypi.yml +++ b/python-project-template/.github/workflows/publish-to-pypi.yml @@ -17,21 +17,33 @@ permissions: jobs: deploy: - runs-on: ubuntu-latest permissions: - id-token: write + id-token: write + strategy: + matrix: + python-version: ['3.12'] steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + - uses: actions/checkout@v3 + with: + fetch-tags: true + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install rail + uses: ./.github/actions/install-rail + with: + python-version: ${{ matrix.python-version }} + - name: Run unit tests with pytest + run: | + python -m pytest tests + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/python-project-template/.github/workflows/smoke-test.yml b/python-project-template/.github/workflows/smoke-test.yml index befa500..2bedeec 100644 --- a/python-project-template/.github/workflows/smoke-test.yml +++ b/python-project-template/.github/workflows/smoke-test.yml @@ -12,25 +12,23 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.11', '3.12', '3.13'] - + python-version: ['3.12', '3.13', '3.14'] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Run unit tests with pytest - run: | - python -m pytest tests + - uses: actions/checkout@v3 + with: + fetch-tags: true + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install rail + uses: ./.github/actions/install-rail + with: + python-version: ${{ matrix.python-version }} + - name: Run unit tests with pytest + run: | + python -m pytest tests diff --git a/python-project-template/.github/workflows/testing-and-coverage.yml b/python-project-template/.github/workflows/testing-and-coverage.yml new file mode 100644 index 0000000..a3fa6f5 --- /dev/null +++ b/python-project-template/.github/workflows/testing-and-coverage.yml @@ -0,0 +1,38 @@ +# This workflow will install Python dependencies, run tests and report code coverage with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Unit test and code coverage + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12', '3.13', '3.14'] + steps: + - uses: actions/checkout@v3 + with: + fetch-tags: true + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install rail + uses: ./.github/actions/install-rail + with: + python-version: ${{ matrix.python-version }} + - name: Run unit tests with pytest + run: | + python -m pytest tests --cov=rail --cov-report=xml + - name: Upload coverage report to codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + diff --git a/python-project-template/.github/workflows/testing-and-coverage.yml.jinja b/python-project-template/.github/workflows/testing-and-coverage.yml.jinja deleted file mode 100644 index 01b543f..0000000 --- a/python-project-template/.github/workflows/testing-and-coverage.yml.jinja +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow will install Python dependencies, run tests and report code coverage with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Unit test and code coverage - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.11', '3.12', '3.13'] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v4 - with: - python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Run unit tests with pytest - run: | - python -m pytest tests --cov={{package_name}} --cov-report=xml - - name: Upload coverage report to codecov - uses: codecov/codecov-action@v4 - with: - token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} diff --git a/python-project-template/pyproject.toml.jinja b/python-project-template/pyproject.toml.jinja index 060c589..0a0e4f2 100644 --- a/python-project-template/pyproject.toml.jinja +++ b/python-project-template/pyproject.toml.jinja @@ -1,6 +1,6 @@ [project] name = "{{project_name}}" -requires-python = ">=3.11" +requires-python = ">=3.12" license = {file = "LICENSE"} readme = "README.md" authors = [ From 83abe980cad0a0632c468e8b0ea32ea0503b2ce6 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 24 Nov 2026 17:44:33 -0700 Subject: [PATCH 2/3] clean up yaml in .github/workflows and .github/actions Generated with AI Co-Authored-By: SLAC AI --- .../.github/actions/install-rail/action.yml | 3 ++- .../workflows/add-issue-to-project-tracker.yml | 7 ++++--- .../.github/workflows/linting.yml | 10 ++++------ .../.github/workflows/publish-to-pypi.yml | 15 ++++----------- .../.github/workflows/smoke-test.yml | 6 ++---- .../.github/workflows/testing-and-coverage.yml | 11 ++++------- 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/python-project-template/.github/actions/install-rail/action.yml b/python-project-template/.github/actions/install-rail/action.yml index 9c80b18..b943ff9 100644 --- a/python-project-template/.github/actions/install-rail/action.yml +++ b/python-project-template/.github/actions/install-rail/action.yml @@ -1,3 +1,4 @@ +--- name: 'Install rail' description: > Install rail_bae and it dependencies using install_rail.py from @@ -25,7 +26,7 @@ runs: --install-conda mamba \ --env-name rail_ci \ --rail-packages None \ - --python-version {{ $inputs.python-version }} \ + --python-version {{ $inputs.python-version }} \ --install-devtools no - name: Add conda environment to PATH diff --git a/python-project-template/.github/workflows/add-issue-to-project-tracker.yml b/python-project-template/.github/workflows/add-issue-to-project-tracker.yml index 37daf55..90eb7be 100644 --- a/python-project-template/.github/workflows/add-issue-to-project-tracker.yml +++ b/python-project-template/.github/workflows/add-issue-to-project-tracker.yml @@ -1,3 +1,4 @@ +--- name: Add bugs to bugs project on: @@ -5,7 +6,9 @@ on: types: - opened pull_request: - types: [opened, reopened] + types: + - opened + - reopened jobs: add-to-project: @@ -14,7 +17,5 @@ jobs: steps: - uses: actions/add-to-project@v0.4.0 with: - # You can target a repository in a different organization - # to the issue project-url: https://github.com/orgs/LSSTDESC/projects/6 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} diff --git a/python-project-template/.github/workflows/linting.yml b/python-project-template/.github/workflows/linting.yml index 3f986b3..5a67a28 100644 --- a/python-project-template/.github/workflows/linting.yml +++ b/python-project-template/.github/workflows/linting.yml @@ -1,13 +1,11 @@ -# This workflow will install Python dependencies, then perform static linting analysis. -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - +--- name: Lint on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -27,7 +25,7 @@ jobs: - name: Install rail uses: ./.github/actions/install-rail with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Analyze code with linter run: | pylint -rn -sn --recursive=y ./src diff --git a/python-project-template/.github/workflows/publish-to-pypi.yml b/python-project-template/.github/workflows/publish-to-pypi.yml index 55f92cb..fa5a538 100644 --- a/python-project-template/.github/workflows/publish-to-pypi.yml +++ b/python-project-template/.github/workflows/publish-to-pypi.yml @@ -1,11 +1,4 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://github.com/pypa/gh-action-pypi-publish#trusted-publishing - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - +--- name: Upload Python Package on: @@ -19,7 +12,7 @@ jobs: deploy: runs-on: ubuntu-latest permissions: - id-token: write + id-token: write strategy: matrix: python-version: ['3.12'] @@ -35,7 +28,7 @@ jobs: - name: Install rail uses: ./.github/actions/install-rail with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Run unit tests with pytest run: | python -m pytest tests @@ -46,4 +39,4 @@ jobs: - name: Build package run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/python-project-template/.github/workflows/smoke-test.yml b/python-project-template/.github/workflows/smoke-test.yml index 2bedeec..e09b131 100644 --- a/python-project-template/.github/workflows/smoke-test.yml +++ b/python-project-template/.github/workflows/smoke-test.yml @@ -1,6 +1,4 @@ -# This workflow will run daily at 06:45. -# It will install Python dependencies and run tests with a variety of Python versions. - +--- name: Unit test smoke test on: @@ -28,7 +26,7 @@ jobs: - name: Install rail uses: ./.github/actions/install-rail with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Run unit tests with pytest run: | python -m pytest tests diff --git a/python-project-template/.github/workflows/testing-and-coverage.yml b/python-project-template/.github/workflows/testing-and-coverage.yml index a3fa6f5..3dcdbd3 100644 --- a/python-project-template/.github/workflows/testing-and-coverage.yml +++ b/python-project-template/.github/workflows/testing-and-coverage.yml @@ -1,13 +1,11 @@ -# This workflow will install Python dependencies, run tests and report code coverage with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - +--- name: Unit test and code coverage on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -27,7 +25,7 @@ jobs: - name: Install rail uses: ./.github/actions/install-rail with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Run unit tests with pytest run: | python -m pytest tests --cov=rail --cov-report=xml @@ -35,4 +33,3 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - From 196509758bdd27f5f92bfea8a6a91f7ebe4a9288 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Fri, 27 Nov 2026 13:54:55 -0700 Subject: [PATCH 3/3] updated github action tests to match template --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d54313..49ea83b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ['3.11', '3.12', '3.13'] + python-version: ['3.12', '3.13', '3.14'] copier_config: - name: Base example package_name: example_package # The default package_name