Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up dependency/install issues #39

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v0.6.1
_src_path: ../../repos/copier-core-python-repository
email: [email protected]
initial_setup: true
name: Zebedee Nicholls
notebook_dependencies: true
pandas_doctests: false
plot_dependencies: false
project_description_short: Implementations of the two layer radiative forcing driven
models by [Held et al.](https://journals.ametsoc.org/doi/full/10.1175/2009JCLI3466.1)
and [Geoffroy et al.](https://journals.ametsoc.org/doi/pdf/10.1175/JCLI-D-12-00195.1)
project_name_human: OpenSCM Two Layer Model
project_name_pip: openscm-twolayermodel
project_name_python: openscm_twolayermodel
project_url: https://github.com/openscm/openscm-twolayermodel
track_lock_file: true
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Bug report
about: Report a bug
title: ''
labels: bug
assignees: ''

---

## Describe the bug
<!--- A clear and concise description of what the bug is. -->

## Failing Test
<!---
Please put the code (ideally in the form of a unit test) which fails below.

e.g.

```python
def test_bug_12():
# Python code here which fails because of the bug
# This is best if other developers can simply copy and paste this test in
# order to run it
```
-->

## Expected behavior
<!--- A clear and concise description of what you expected to happen. -->

## Screenshots
<!--- If applicable, add screenshots to help explain your problem. -->

## System
<!--- Please complete the following information. -->

- OS: [e.g. Windows, Linux, macOS]
- Python version [e.g. Python 3.11]
- Please also upload your `poetry.lock` file (first run `poetry lock` to make sure the lock file is up-to-date)

## Additional context
<!--- Add any other context about the problem here. -->
30 changes: 0 additions & 30 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Default
about: Report an issue or problem
title: ''
labels: triage
assignees: ''

---

## The problem
<!--- Useful to breakdown to "As a [persona], I [want to do], so that [reason] -->

## Definition of "done"
<!---
What are the things that must be true in order to close this issue

We find that describing these as dot points works well.
-->

## Additional context
<!--- Add any additional context can go here -->
29 changes: 20 additions & 9 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
---
name: Feature Request
about: Suggest an idea for this project
about: Request a feature or suggest an idea for this project
title: ''
labels: feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
## The motivation

A clear and concise description of what the problem is. E.g. It's annoying that I always have to [...]
<!--- Useful to breakdown to "As a [persona], I [want to do], so that [reason] -->

**Describe the solution you'd like**
## The proposed solution

A clear and concise description of the solution you would like to see.
<!---
If you'd like, please provide a description of the solution you would like to see

**Describe alternatives you've considered**
If you don't have any ideas for the solution, simply leave this blank
-->

A clear and concise description of any alternative solutions or features you've considered.
## Alternatives

**Additional context**
<!---
If you've considered any alternatives, please describe them here

Add any other context or screenshots about the feature request here.
If you don't have any alternatives, simply leave this blank
-->

## Additional context

<!--- Add any additional context can go here -->
63 changes: 63 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Setup Python and Poetry"
description: "setup Python and Poetry with caches"

inputs:
os:
description: "Operating system to use"
required: false
default: "ubuntu-latest"
python-version:
description: "Python version to use"
required: true
venv-id:
description: "ID to identify cached environment (should be unique from other steps)"
required: true
poetry-dependency-install-flags:
description: "Flags to pass to poetry when running `poetry install --no-interaction --no-root`"
required: true
run-poetry-install:
description: "Should we run the poetry install steps"
required: false
default: true


runs:
using: "composite"
steps:
- name: Install poetry
shell: bash
run: |
pipx install poetry
which poetry
poetry --version # Check poetry installation

- name: Set up Python ${{ inputs.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry
- name: Set Poetry environment
shell: bash
run: |
# This line used to be needed, but seems to have been
# sorted with newer poetry versions. We can still check whether
# the right version of python is used by looking at the output of
# `poetry run which python` below and whether the right version
# of python is used in the tests (or whatever step is being done)
# poetry env use "python${{ inputs.python-version }}"
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies
if: ${{ (inputs.run-poetry-install == 'true') && (steps.setup-python.outputs.cache-hit != 'true') }}
shell: bash
run: |
poetry install --no-interaction --no-root ${{ inputs.poetry-dependency-install-flags }}
# Now run same command but let the package install too
- name: Install package
# To ensure that the package is always installed, this step is run even if the cache was hit
if: ${{ inputs.run-poetry-install == 'true' }}
shell: bash
run: |
poetry install --no-interaction ${{ inputs.poetry-dependency-install-flags }}
poetry run python --version # Check python version just in case
11 changes: 7 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Please replace this paragraph by a description of what this PR does and alter the TODO-list below to what applies here. Please make a 'draft PR' to begin and then only mark it as ready for review once all the relevant points are done.>
## Description

## Checklist

Please confirm that this pull request has done the following:

- [ ] Tests added
- [ ] Documentation added
- [ ] Example added (in the documentation, to an existing notebook, or in a new notebook)
- [ ] Description in ``CHANGELOG.rst`` added (single line such as: ``(`#XX <https://github.com/openscm/openscm-twolayermodel/pull/XX>`_) Added feature which does something``)
- [ ] Documentation added (where applicable)
- [ ] Changelog item added to `changelog/`
7 changes: 7 additions & 0 deletions .github/release_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Announcements

* Announcement 1

## Changes

* Change 1
67 changes: 67 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Bump version

on:
workflow_dispatch:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see https://python-poetry.org/docs/cli/#version)
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
required: true

jobs:
bump_version:
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
env:
CI_COMMIT_EMAIL: "[email protected]"
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"

# towncrier imports the package as part of building so we have to
# install the pacakage (to keep things slim, we only install the main
# dependencies, which also means that we get a test that we can import
# the package with only the compulsory dependencies installed for free)
- uses: ./.github/actions/setup
with:
python-version: "3.11"
venv-id: "bump"
poetry-dependency-install-flags: "--only main"

- name: Install towncrier
run: |
poetry run pip install towncrier

- name: Create bump and changelog

run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$CI_COMMIT_EMAIL"

# Bump
BASE_VERSION=`poetry version -s`
NEW_VERSION=`poetry version -s ${{ github.event.inputs.bump_rule }}`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"
poetry run towncrier build --yes --version v$NEW_VERSION
git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION"
git tag v$NEW_VERSION

# Bump to alpha (so that future commits do not have the same
# version as the tagged commit)
BASE_VERSION=`poetry version -s`
NEW_VERSION=`poetry version -s prerelease`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"
git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
git push && git push --tags
Loading
Loading