Skip to content

Commit

Permalink
Remove poetry; add hatch (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
moble authored Sep 7, 2023
1 parent 0c364fd commit 0335a4b
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1,574 deletions.
10 changes: 0 additions & 10 deletions .github/scripts/parse_version.py

This file was deleted.

87 changes: 28 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ on:
tags: '*'
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:

build:
name: ${{ matrix.os }} python ${{ matrix.python-version }}
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}

runs-on: ${{ matrix.os }}

Expand All @@ -31,45 +39,28 @@ jobs:
shell: bash
run: |
echo "skipping_build_and_test_replicate=${skip_replicates}" >> $GITHUB_ENV
# echo "skipping_build_and_test_replicate='false'" >> $GITHUB_ENV
- name: Check out code
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: actions/checkout@v2

- name: Set up python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
- name: Install Hatch
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Build and install with poetry
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
poetry run python -m pip install --upgrade pip
poetry env info
rm poetry.lock
poetry update
poetry build
poetry install --no-interaction
run: pip install --upgrade hatch

- name: Run tests
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
poetry run pytest -s --cov=scri --cov-branch --cov-report=xml --durations=0
run: hatch run test

- name: Upload coverage
if: "matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'"
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3


release:
Expand All @@ -83,36 +74,15 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: 3.11

- name: Install toml
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
python -m pip install --upgrade pip toml
- name: Install poetry
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Build and install with poetry
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
shell: bash
run: |
poetry run python -m pip install --upgrade pip
poetry env info
rm poetry.lock
poetry update
poetry build
poetry install --no-interaction --no-dev
- name: Install Hatch
run: pip install --upgrade hatch

- name: Bump version
shell: bash
Expand All @@ -124,11 +94,11 @@ jobs:
# in the commit message, it bumps the corresponding version number. Those can also be
# prepended as `#premajor`, etc., to add/bump the prerelease modifier. If none of those
# are present, `#patch` is assumed — that is, the lowest-significance number is
# incremented. See the documentation of the `poetry version` command for details.
# incremented. See the documentation of the `hatch version` command for details.
export version_bump_rule=$(python .github/scripts/parse_bump_rule.py)
echo "version_bump_rule: '${version_bump_rule}'"
poetry version "${version_bump_rule}"
export new_version=$(python .github/scripts/parse_version.py pyproject.toml)
hatch version "${version_bump_rule}"
export new_version=$(TERM="unknown" hatch version)
echo "new_version: '${new_version}'"
echo "new_version=${new_version}" >> $GITHUB_ENV # Save env variable for later steps
Expand All @@ -147,7 +117,7 @@ jobs:
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add pyproject.toml CITATION.cff
git add CITATION.cff scri/__version__.py
git commit -m "Bump version to v${new_version}"
git tag -a "v${new_version}" -m "Version ${new_version}"
git status
Expand All @@ -170,10 +140,9 @@ jobs:
env:
# 1) Get key from https://pypi.org/manage/account/token/
# 2) Copy it to Github > repo > Settings > Secrets
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
shell: bash
run: |
# Do these first two steps again to ensure the version is right
poetry build
poetry install --no-interaction --no-dev
poetry publish
hatch build
hatch publish
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Mike Boyle
Copyright (c) 2023 Mike Boyle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 0335a4b

Please sign in to comment.