Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 5, 2023
2 parents 58597a2 + 9a120c2 commit 3a5a9b5
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 105 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/merge-after-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,19 @@ jobs:
with:
fetch-depth: 0

- name: Generate tag name from release branch name
- name: Generate tag name >> GITHUB_ENV
run: |
echo "release_tag_name=$(echo "$RELEASE_BRANCH" \
| sed --regexp-extended \
's/.*release.*([0-9].[0-9].[0-9])/v\1/g')" >> $GITHUB_ENV
- name: Configure repo for autobot merge commit
run: |
echo "set git user.name and email"
git config user.name gha-bot
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config --list
git checkout "$RELEASE_BRANCH"
git branch --list
echo "git log this stuff"
git log --graph -n10 --pretty=format:'%h %as %cn %x09%s %d'
- name: Merge the latest release commit
Expand All @@ -63,10 +61,8 @@ jobs:
git checkout main
git branch --list
git merge --no-ff "$RELEASE_BRANCH"
git status
git tag --annotate "$release_tag_name" -m "release $release_tag_name"
git log --graph -n20 --pretty=format:'%h %as %cn %x09%s %d'
echo 'running: git push origin $release_tag_name'
git log --graph -n10 --pretty=format:'%h %as %cn %x09%s %d'
git push origin "$release_tag_name"
git push origin main
Expand All @@ -76,7 +72,8 @@ jobs:
git merge --no-ff main
git push origin "$release_tag_name"
git push origin dev
echo "you can delete your release branch now"
echo "RELEASE AND DEV MERGED"
ehco "YOU CAN DELETE RELEASE BRANCH: $RELEASE_BRANCH"
on-failure:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/poetry.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'

- run: python --version

Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.1'
__version__ = '0.3.0'
7 changes: 0 additions & 7 deletions bump_version.sh

This file was deleted.

55 changes: 55 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
YW := '\033[0;33m'
RD := '\033[0;31m'
LC := '\033[0;36m'
LB := '\033[0;34m'
LG := '\033[0;32m'
NC := '\033[0m'

# just --list
default:
@just --list --unsorted

# poetry pass thru command
po *args:
poetry run {{args}}

# pass thru
blank *args:
{{args}}

# INFO: develop, build, deploy
info:
@echo
@echo " {{LC}}Workflow to develop python scripts and deploy to homebrew.{{LG}}"
@echo
@echo " {{LG}}1.{{NC}} Develop/commit on dev"
@echo " {{LG}}2.{{NC}} just test"
@echo " {{LG}}3.{{NC}} just bump"
@echo " {{LG}}4.{{NC}} git checkout -b release/0.3.1"
@echo " * final TESTS and debug"
@echo " * git push --set-upstream origin release/0.3.1"
@echo " * PR 'release/0.3.1' for CI/CD tests (click link to open PR)"
@echo " * merge to main"
@echo " * tag"
@echo " {{LG}}5.{{NC}} release to homebrew repo on merge to main"


# ptpython REPL in poetry shell
repl:
@poetry run ptpython

# instructions to bump version number
bump:
@echo
@echo " {{LC}}REMINDER:{{NC}} You need to manually bump the version numbers in these locations."
@echo " ./desertislandutils/"
@echo " {{YW}}__init__.py"
@echo " pyproject.toml"
@echo " tests/test_desertislandutils.py"
code __init__.py pyproject.toml tests/test_desertislandutils.py

# pytest
test *args:
@echo
@echo " ✙✙✙✙✙✙✙✙ TESTING ✙✙✙✙✙✙✙✙"
poetry run pytest --disable-warnings --verbose {{args}}
98 changes: 98 additions & 0 deletions notes/weeknumber/weeknumber.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# WN: Week Number
I need to know the ISO reporting week for the current date all the time. And I like to be able to get the week number for any arbitrary date, usually this is in SQL but a CLI script also good.

This has been working fine in bash for years, but time to thaw out my python package development.
Also, its time to incorporate `justfile` into my package development workflow, so much easier to document commands that way.

Typer is pretty sweet, waaay beyond Argparse.

## REQUIREMENTS
Options:
input date, default current date
Week ending day, default saturday (ISO minus 1)

Dependencies:
[Typer CLI package instead of ArgParse](https://typer.tiangolo.com/tutorial/first-steps/)
Pendulum date package
Just -- yes tis time

## CHEWS PLACE
```sh
poetry env use 3.11
poetry add "typer[all]"
poetry add pendulum="~2.0"
# note pendulum 2.1.2 kept failing build, I went through this before
poetry install

# add script name to pyproject:
[tool.poetry.scripts]
wn = "src.weeknumber.wn:app"
```

At this point I can try the app:
```sh
poetry shell
(desertislandutils-py3.11) $> wn --help
```
actually its expecting a command, gotta figure single command app.

## TEARS IN RAIN
**It works great!**

```sh
wn --help

Usage: wn [OPTIONS] [DATE]

ISO year week number of a date as YYYY-WDD. Default weekend day is Sat.
Example:
$> wn 'Jul 22'
2023-W29

╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ date [DATE] A text expression of date, ex: 'November 27', or 2112-07-29 [default: (dynamic)] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --sunday Weekend is Saturday by default, this flag sets Sunday weekend day. │
│ --last Give week number of most recently completed week (overrides DATE argument). │
│ --verbose --no-verbose [default: no-verbose] │
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

wn 2112-07-24 --sunday --verbose
# Input date string: 2112-07-24
# Timezone: US/Pacific
# Parsed date: 2112-07-24
# ISO week number:
# 2112-W29

wn 2112-07-24 --verbose
# Input date string: 2112-07-24
# Timezone: US/Pacific
# Parsed date: 2112-07-24
# ISO week number:
# 2112-W30

wn 2112-07-24
# 2112-W30

wn --last
# 2023-W48
```

## TEST
* its a cli service that echoes to stdout
* use `capsys` fixture as in `test_wn` to compare outputs to expected

```sh
just test tests/wn

✙✙✙✙✙✙✙✙ TESTING ✙✙✙✙✙✙✙✙
poetry run pytest --disable-warnings --verbose tests/wn
========================================================= test session starts ==========================================================
rootdir: /Users/merlinr/repo/the-others/desertislandutils
collected 1 item
tests/wn/test_wn.py::test_wn_options PASSED [100%]
```
Loading

0 comments on commit 3a5a9b5

Please sign in to comment.