Skip to content

Commit

Permalink
👷 hatch build tool
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Apr 22, 2023
1 parent 18a6747 commit 610f3a9
Show file tree
Hide file tree
Showing 27 changed files with 1,688 additions and 3,223 deletions.
882 changes: 24 additions & 858 deletions .github/semantic_release/package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .github/semantic_release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"semantic-release": "^21.0.1",
"semantic-release-gitmoji": "^1.6.4",
"@google/semantic-release-replace-plugin": "^1.2.0"
"semantic-release-gitmoji": "^1.6.4"
}
}
18 changes: 10 additions & 8 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
- name: Install Hatch
run: |
pip install --upgrade pip
pip install packaging poetry
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Declare Version Variable
run: |
PROJECT_VERSION=$(poetry version --short)
PROJECT_NAME=$(poetry version | awk '{ print $1 }')
echo PROJECT_VERSION=${PROJECT_VERSION} >> $GITHUB_ENV
echo PROJECT_NAME=${PROJECT_NAME} >> $GITHUB_ENV
PACKAGE_VERSION=$(hatch version)
PACKAGE_NAME=$(hatch project metadata | jq -r .name)
echo PACKAGE_VERSION=${PACKAGE_VERSION} >> $GITHUB_ENV
echo PACKAGE_NAME=${PACKAGE_NAME} >> $GITHUB_ENV
- name: Docker Image Building and Publishing
id: docker_build
uses: docker/build-push-action@v3
with:
push: false
tags: juftin/${{ env.PROJECT_NAME }}:latest
tags: juftin/${{ env.PACKAGE_NAME }}:latest
18 changes: 10 additions & 8 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python Dependencies
- name: Install Hatch
run: |
python -m pip install --upgrade pip wheel
python -m pip install tox
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Lint
id: lint
continue-on-error: true
run: |
echo "::add-matcher::.github/matchers/flake8.json"
tox -e lint
hatch run lint
echo "::remove-matcher owner=flake8::"
- name: Lint with MyPy
id: mypy
- name: Code Checker
id: check
continue-on-error: true
run: |
echo "::add-matcher::.github/matchers/mypy.json"
tox -e mypy
hatch run check
echo "::remove-matcher owner=mypy::"
- name: Raise Errors For Linting Failures
if: |
steps.lint.outcome != 'success'
run: |
echo "Lint: ${{ steps.lint.outcome }}"
echo "MyPy: ${{ steps.mypy.outcome }}"
echo "Check: ${{ steps.check.outcome }}"
echo "I Should Really Be Enforcing MyPy Errors"
exit 1
30 changes: 13 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Upgrade pip
- name: Install Hatch
run: |
pip install --upgrade pip
pip --version
- name: Install Poetry
run: |
pip install poetry
poetry --version
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Build package
run: |
poetry build --ansi
hatch build
- name: Publish package on PyPI
uses: pypa/[email protected]
with:
Expand All @@ -49,14 +47,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Upgrade pip
run: |
pip install --upgrade pip
pip --version
- name: Install Poetry
- name: Install Hatch
run: |
pip install poetry
poetry --version
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand All @@ -68,8 +64,8 @@ jobs:
password: ${{ secrets.DOCKER_TOKEN }}
- name: Declare Version Variable
run: |
PACKAGE_VERSION=$(poetry version --short)
PACKAGE_NAME=$(poetry version | awk '{ print $1 }')
PACKAGE_VERSION=$(hatch version)
PACKAGE_NAME=$(hatch project metadata | jq -r .name)
echo PACKAGE_VERSION=${PACKAGE_VERSION} >> $GITHUB_ENV
echo PACKAGE_NAME=${PACKAGE_NAME} >> $GITHUB_ENV
- name: Docker Image Building and Publishing
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
- name: Install Hatch
run: |
python -m pip install -q poetry
poetry --version
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Release
run: npx --prefix .github/semantic_release/ semantic-release
run: hatch run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
Expand All @@ -45,17 +47,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
- name: Install Hatch
run: |
pip install --upgrade pip wheel setuptools
pip install poetry
poetry --version
- name: Install Environment
run: |
poetry install --extras all
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Set Up GitHub Actions User
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy Documentation Changes
run: poetry run mkdocs gh-deploy --force
run: hatch run docs-deploy --force
20 changes: 11 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
fail-fast: true
matrix:
include:
- { name: Python 3.11, python: "3.11", tox: py311 }
- { name: Python 3.10, python: "3.10", tox: py310 }
- { name: Python 3.9, python: "3.9", tox: py39 }
- { name: Python 3.8, python: "3.8", tox: py38 }
- { name: Python 3.11, python: "3.11" }
- { name: Python 3.10, python: "3.10" }
- { name: Python 3.9, python: "3.9" }
- { name: Python 3.8, python: "3.8" }
env:
CAMPLY_LOG_HANDLER: PYTHON
steps:
Expand All @@ -38,12 +38,14 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Test Dependencies
- name: Install Hatch
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install tox
- name: Tox Test Suite
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch env create
hatch --version
- name: Test Suite
run: |
echo "::add-matcher::.github/matchers/python.json"
tox -e ${{ matrix.tox }}
hatch run test
echo "::remove-matcher owner=python::"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ node_modules/

# Camply Data Files
camply/providers/reserve_california/*.json

# Camply Requirements Files
requirements/*.bak
54 changes: 16 additions & 38 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,14 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending

- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black-jupyter

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.7.0
rev: v2.8.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
hooks:
- id: autoflake
args:
[
--in-place,
--expand-star-imports,
--remove-all-unused-imports,
--remove-duplicate-keys,
--remove-unused-variables,
--ignore-pass-after-docstring,
]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: v3.0.0-alpha.6
hooks:
- id: prettier
args: [--print-width=88, --tab-width=4]
Expand All @@ -60,13 +33,18 @@ repos:
additional_dependencies:
- prettier

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.252
- repo: local
hooks:
- id: ruff

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
- id: format
name: format
description: Runs Code Auto-Formatters
entry: hatch run format
language: system
pass_filenames: false
- id: lint
name: lint
description: Runs Code Linters
entry: hatch run format
language: system
pass_filenames: false
require_serial: false
15 changes: 1 addition & 14 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@ module.exports = {
[
"@semantic-release/exec",
{
prepareCmd: "poetry version ${nextRelease.version} && poetry build",
},
],
[
"@google/semantic-release-replace-plugin",
{
replacements: [
{
files: ["*/_version.py"],
ignore: ["tests/*"],
from: '__version__ = ".*"',
to: '__version__ = "${nextRelease.version}"',
},
],
prepareCmd: "hatch version ${nextRelease.version} && hatch build",
},
],
[
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY camply/ /tmp/camply/camply/
MAINTAINER Justin Flannery <[email protected]>
LABEL description="camply, the campsite finder"

COPY requirements/prod.txt /tmp/camply/requirements.txt
COPY requirements/requirements-prod.txt /tmp/camply/requirements.txt

RUN python -m pip install -r /tmp/camply/requirements.txt && \
python -m pip install /tmp/camply --no-dependencies && \
Expand All @@ -20,7 +20,7 @@ ENV CAMPLY_LOG_HANDLER="PYTHON"

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN _CAMPLY_COMPLETE=bash_source camply > /root/.camply-complete.bash && \
echo "[[ ! -f /root/.camply-complete.bash ]] || source /root/.camply-complete.bash" >> /root/.bashrc
RUN _CAMPLY_COMPLETE=bash_source camply > ${HOME}/.camply-complete.bash && \
echo "[[ ! -f ${HOME}/.camply-complete.bash ]] || source ${HOME}/.camply-complete.bash" >> ${HOME}/.bashrc

CMD ["camply", "--help"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ Head over to the [camply documentation](https://juftin.com/camply/) to see what
│ campsites Find Available Campsites with Custom Search Criteria │
│ configure Set up camply configuration file with an interactive console │
│ equipment-types Get a list of supported equipment │
│ list-campsites List campsite IDs for a given campground or recreation area │
│ providers List the different camply providers │
│ recreation-areas Search for Recreation Areas and list them │
│ test-notifications Test your notification provider setup │
│ test-notifications Test your notification provider setup │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
```
Expand Down
2 changes: 1 addition & 1 deletion camply/providers/reserve_california/reserve_california.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _search_camply_model(cls, query: str, model: CamplyModel) -> bool:
bool
"""
return any(
[query.lower() in str(value).lower() for value in model.dict().values()]
query.lower() in str(value).lower() for value in model.dict().values()
)

def get_campsites_per_facility(
Expand Down
2 changes: 1 addition & 1 deletion camply/search/base_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def _consecutive_subseq(cls, iterable: Iterable, length: int) -> Generator:
k_wise = tee(map(itemgetter(1), consec_run), length)
for n, it in enumerate(k_wise):
next(islice(it, n, n), None)
yield from zip(*k_wise) # noqa: B905
yield from zip(*k_wise)

@classmethod
def _find_consecutive_nights(cls, dataframe: DataFrame, nights: int) -> DataFrame:
Expand Down
3 changes: 2 additions & 1 deletion docs/command_line_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ tool accepts one of six sub-arguments: `campsites`, `recreation-areas`, `campgro
│ campsites Find Available Campsites with Custom Search Criteria │
│ configure Set up camply configuration file with an interactive console │
│ equipment-types Get a list of supported equipment │
│ list-campsites List campsite IDs for a given campground or recreation area │
│ providers List the different camply providers │
│ recreation-areas Search for Recreation Areas and list them │
│ test-notifications Test your notification provider setup │
│ test-notifications Test your notification provider setup │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
```
Expand Down
Loading

0 comments on commit 610f3a9

Please sign in to comment.