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 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..b943ff9 --- /dev/null +++ b/python-project-template/.github/actions/install-rail/action.yml @@ -0,0 +1,42 @@ +--- +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/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 15333ff..5a67a28 100644 --- a/python-project-template/.github/workflows/linting.yml +++ b/python-project-template/.github/workflows/linting.yml @@ -1,33 +1,34 @@ -# 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: 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..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: @@ -17,21 +10,33 @@ permissions: jobs: deploy: - runs-on: ubuntu-latest permissions: 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 diff --git a/python-project-template/.github/workflows/smoke-test.yml b/python-project-template/.github/workflows/smoke-test.yml index befa500..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: @@ -12,25 +10,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..3dcdbd3 --- /dev/null +++ b/python-project-template/.github/workflows/testing-and-coverage.yml @@ -0,0 +1,35 @@ +--- +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 = [