-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- automate testing - virtual environment setup
- Loading branch information
1 parent
5a83ed4
commit 6557d5e
Showing
12 changed files
with
519 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: version auto-incrementing & package publishing | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: ["master"] | ||
|
||
jobs: | ||
build: | ||
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checking out v3 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Python and dependencies | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m | ||
pip install wheel pyyaml sortedcontainers requests semver | ||
- name: Increment version | ||
run: python ./.github/workflows/version.py --increment | ||
|
||
- name: Commit and push changes | ||
run: | | ||
git add . | ||
git commit -m "increment to v$(python ./.github/workflows/version.py --get)" | ||
git push --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: version auto-incrementing & package publishing | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checking out v3 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Python and dependencies | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m | ||
pip install sortedcontainers | ||
- name: Run tests | ||
run: | | ||
coverage run test/test.py | ||
coverage report -m sigfig/sigfig.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pathlib import Path | ||
from datetime import datetime | ||
from sys import path | ||
from yaml import safe_load, safe_dump | ||
import toml | ||
from requests import get | ||
from semver import Version | ||
|
||
path.insert(0, str(Path(__file__).parent / "../..")) | ||
from setup import version as local_version | ||
local_version = Version.parse(local_version) | ||
|
||
def apply_citation_version(version): | ||
citation_path = Path(__file__).parent / "../../CITATION.cff" | ||
with open(citation_path, "r") as f: | ||
citation = safe_load(f) | ||
citation["version"] = str(version) | ||
citation["date-released"] = datetime.now().strftime("%Y-%m-%d") | ||
with open(citation_path, "w") as f: | ||
f.write(safe_dump(citation, sort_keys=False)) | ||
|
||
def apply_pyproject_version(version): | ||
pyproject_path = Path(__file__).parent / "../../pyproject.toml" | ||
with open(pyproject_path, "r") as f: | ||
pyproject = toml.load(f) | ||
pyproject["tool"]["poetry"]["version"] = str(version) | ||
with open(pyproject_path, "w") as f: | ||
f.write(toml.dumps(pyproject)) | ||
|
||
def get_version(): | ||
print(local_version) | ||
|
||
def increment(): | ||
published_version = Version.parse(get('https://pypi.org/pypi/sigfig/json').json()['info']['version']) | ||
if local_version > published_version: | ||
return | ||
new_version = published_version.bump_patch() | ||
# apply_citation_version(new_version) | ||
apply_pyproject_version(new_version) | ||
|
||
increment() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.