Skip to content

Commit

Permalink
build: copier update
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Sep 12, 2023
1 parent 48ad030 commit df76f43
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Answer file maintained by Copier for: https://github.com/KyleKing/calcipy_template
# DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions
# Check into version control.
_commit: 1.7.13
_commit: 1.8.2
_src_path: gh:KyleKing/calcipy_template
author_email: [email protected]
author_name: Kyle King
Expand Down
6 changes: 3 additions & 3 deletions .github/ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
- [actions/cache](https://github.com/marketplace/actions/cache)
- [actions/checkout](https://github.com/actions/checkout)
- [actions/setup-python](https://github.com/actions/setup-python)
- [Github Action Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
- [GitHub Action Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
- [pre-commit/action](https://github.com/pre-commit/action) (Now deprecated)
- [ts-graphviz/setup-graphviz](https://github.com/ts-graphviz/setup-graphviz)

The Github Workflows and Action were influenced by these excellent examples:
The GitHub Workflows and Action were influenced by these excellent examples:

- [Re-engineering the SciPy Pipelines](https://labs.quansight.org/blog/2021/10/re-engineering-cicd-pipelines-for-scipy/) and [Example](https://github.com/scipy/scipy/blob/c4829bddb859ffe5716a88f6abd5e0d2dc1d9045/.github/workflows/linux_meson.yml)
- SciPy also has good examples of building Docker image with layer caching, [docker.yml](https://github.com/scipy/scipy/blob/c4829bddb859ffe5716a88f6abd5e0d2dc1d9045/.github/workflows/docker.yml) and [gitpod.yml](https://github.com/scipy/scipy/blob/c4829bddb859ffe5716a88f6abd5e0d2dc1d9045/.github/workflows/gitpod.yml)
- [PostHog Guide on GHA](https://posthog.com/blog/automating-a-software-company-with-github-actions). Includes information on Cypress, working with Amazon ECS, version bumping, etc.
- ["Awesome" GHA](https://github.com/sdras/awesome-actions)
- ["services" Can create PG or other services in workflows!](https://github.com/Nike-Inc/knockoff-factory/blob/1567a46e5eaa3fe1bdf989ef5253f9ee0dbd69b3/.github/workflows/python-test.yaml)
- ["artifact" optionally upload the report.zip from successful builds](https://github.com/marketplace/actions/upload-a-build-artifact)
- [General Tips](https://www.datree.io/resources/github-actions-best-practices). Keep workflows short and fast (view [usage here](https://github.com/settings/billing)), cache, [user Github's secret management](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets), and environment variables can be [scoped to an individual step](https://docs.github.com/en/actions/learn-github-actions/environment-variables)
- [General Tips](https://www.datree.io/resources/github-actions-best-practices). Keep workflows short and fast (view [usage here](https://github.com/settings/billing)), cache, [user GitHub's secret management](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets), and environment variables can be [scoped to an individual step](https://docs.github.com/en/actions/learn-github-actions/environment-variables)
- There are many ways to run a workflow beyond only commit events, such as [workflow_dispatch, schedule, release, comment, review, etc.](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows). Once `workflow_dispatch` is set, [workflows can be run from the CLI](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow)
- [Inspiration for caching](https://github.com/MrThearMan/savestate/blob/fb299e220ef366727857b1df0631300a027840fc/.github/workflows/main.yml)
- [mdformat pipeline](https://github.com/executablebooks/mdformat/blob/4752321bb444b51f120d8a6933583129a6ecaabb/.github/workflows/tests.yaml)
Expand Down
57 changes: 43 additions & 14 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
name: Setup Action
description: Run "poetry install"
description: Install requested pipx dependencies, configure the system python, and install poetry and the package dependencies

inputs:
os:
default: ubuntu-22.04
pipx-packages:
default: ""
poetry-version:
default: 1.5.1
default: 1.6.1
python-version:
required: true

Expand All @@ -17,8 +19,42 @@ env:
runs:
using: composite
steps:
- name: Install Poetry ${{ inputs.poetry-version }}
run: pipx install poetry==${{ inputs.poetry-version }}
- name: Setup Local Variables
id: variable-setup
run: |
echo "pipx-home=$PIPX_HOME" >> $GITHUB_OUTPUT
echo "pipx-bin-dir=$PIPX_BIN_DIR" >> $GITHUB_OUTPUT
export BASE64_PIPX_ID=$(echo -n 'poetry==${{ inputs.poetry-version }} ${{ inputs.pipx-packages }}' | base64)
echo "cache-key-pipx=pipx-${{ inputs.os }}-${{ inputs.python-version }}-$BASE64_PIPX_ID" >> $GITHUB_OUTPUT
shell: bash

- name: Cache pipx
id: cache-pipx
# cache doesn't have permission to extract to "opt/"
if: ${{ inputs.os != 'macos-latest' }}
uses: actions/cache@v3
with:
# https://pypa.github.io/pipx/how-pipx-works
path: |
${{ steps.variable-setup.outputs.pipx-home }}
${{ steps.variable-setup.outputs.pipx-bin-dir }}
key: ${{ steps.variable-setup.outputs.cache-key-pipx }}

- name: Install Poetry ${{ inputs.poetry-version }} and '${{ inputs.pipx-packages }}'
if: ${{ steps.cache-pipx.outputs.cache-hit != 'true' }}
run: |
for tool in "poetry==${{ inputs.poetry-version }}" ${{ inputs.pipx-packages }}; do
pipx install $tool
done
# Resolves https://github.com/python-poetry/poetry/issues/7611
poetry self add setuptools==68.1.2
shell: bash

- name: Debug pipx
run: |
pipx ensurepath
pipx list
shell: bash

- name: Setup Python ${{ inputs.python-version }}
Expand All @@ -27,20 +63,13 @@ runs:
python-version: ${{ inputs.python-version }}
cache: poetry

- name: Cache Nox
uses: actions/cache@v3
id: cache
with:
path: .nox
key: ${{ inputs.os }}-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Poetry Debug Info
run: |-
run: |
poetry debug info
poetry config --list
shell: bash

- name: Install Project and Dependencies
run: |-
- name: Install Project and Minimum Subset of Dependencies
run: |
poetry install
shell: bash
12 changes: 6 additions & 6 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
os: [ubuntu-22.04]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

- name: Run static linters
run: ./run lint.check
run: poetry run calcipy-lint lint.check

test:
runs-on: ${{ matrix.os }}
Expand All @@ -40,14 +40,14 @@ jobs:
os: [macos-latest, windows-latest]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

- name: Run test
run: poetry run calcipy test.pytest
run: poetry run calcipy-test test.pytest

typecheck:
runs-on: ${{ matrix.os }}
Expand All @@ -56,14 +56,14 @@ jobs:
os: [ubuntu-22.04]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

- name: Run typecheck
run: ./run types.mypy
run: poetry run calcipy-types types.mypy

# Based on: https://github.com/jakebailey/pyright-action/issues/10#issuecomment-1455220629
- name: Add Poetry Python to Path
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Based on the Github-recommended CodeQL Action
# Based on the GitHub-recommended CodeQL Action
name: CodeQL

"on":
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
os: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
labeler:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Labeler
if: success()
uses: crazy-max/ghaction-github-labeler@v4
uses: crazy-max/ghaction-github-labeler@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
os: [ubuntu-22.04]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # For git-revision-date-localized-plugin
- uses: ./.github/actions/setup
Expand All @@ -41,4 +41,4 @@ jobs:
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Build and deploy documentation
run: ./run cl.write doc.build doc.deploy
run: poetry run calcipy-docs cl.write doc.build doc.deploy
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ repos:
- id: shellcheck
args: [--severity=warning]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.1"
rev: "v3.0.3"
hooks:
- id: prettier
additional_dependencies:
# Note: this version must be the same as the hook revision
- "[email protected].0"
- "[email protected].3"
- "prettier-plugin-sh"
exclude: \.copier-answers\.yml|tests/.*/cassettes/.*\.yaml
types_or: [html, javascript, json, shell, yaml]
Expand Down Expand Up @@ -92,7 +92,7 @@ repos:
args: [--never]
files: tail_jsonl/.*\.py
- repo: https://github.com/KyleKing/calcipy
rev: 1.6.2
rev: 2.0.0
hooks:
- id: copier-forbidden-files
- id: lint-fix
Expand Down
10 changes: 8 additions & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Docs: https://github.com/charliermarsh/ruff
# Tip: poetry run python -m ruff --explain RUF100

external = [
'CAC001', # <func> is too complex (8 > 7)
'ECE001', # Expression is too complex (8 > 7)
]
ignore = [
'ANN002', # Missing type annotation for `*args`
'ANN003', # Missing type annotation for `**kwargs`
Expand All @@ -18,7 +22,6 @@ ignore = [
'FIX004', # Line contains HACK
'N999', # Invalid module name: '_noxfile'
'RUF013', # PEP 484 prohibits implicit `Optional`
'RUF100', # Unused noqa directive (remove once flake8 is fully replaced)
'TCH001', # Move application import `{}` into a type-checking block
'TCH002', # Move third-party import `{}` into a type-checking block
'TCH003', # Move standard library import `pathlib.Path` into a type-checking block
Expand Down Expand Up @@ -52,7 +55,10 @@ inline-quotes = 'single'
known-first-party = ['tail_jsonl']

[per-file-ignores]
'*/__init__.py' = [
'./tail_jsonl/../*.py' = [
'INP001', # File `/<>.py` is part of an implicit namespace package. Add an `__init__.py`.
]
'__init__.py' = [
'D104', # Missing docstring in public package
'F401', # imported but unused; consider adding to __all__ or using a redundant alias
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

Pretty Print Tailed JSONL Logs

Documentation can be found on [Github (./docs)](./docs), [PyPi](https://pypi.org/project/tail_jsonl/), or [Hosted](https://tail-jsonl.kyleking.me/)!
Documentation can be found on [GitHub (./docs)](./docs), [PyPi](https://pypi.org/project/tail_jsonl/), or [Hosted](https://tail-jsonl.kyleking.me/)!
5 changes: 3 additions & 2 deletions docs/docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Personal Guide
<details>
<summary>Research</summary>
<ul>
<li>[Sane Github Labels](https://medium.com/@dave_lunny/sane-github-labels-c5d2e6004b63) and see [sensible-github-labels](https://github.com/Relequestual/sensible-github-labels) for full descriptions of each</li>
<li>[Sane GitHub Labels](https://medium.com/@dave_lunny/sane-github-labels-c5d2e6004b63) and see [sensible-github-labels](https://github.com/Relequestual/sensible-github-labels) for full descriptions of each</li>
<ul>
<li>“it is much more helpful to see the status and type of all issues at a glance.”</li>
<li>One of each:</li>
Expand Down Expand Up @@ -129,7 +129,7 @@ Personal Guide

- [Git: The Simple Guide][simple_git]
- [Commit Messages][gcmsg] and [why use the present tense](https://news.ycombinator.com/item?id=8874177)
- [Github's Advice on Github](https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
- [GitHub's Advice on GitHub](https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
- [Most Comprehensive Guide](https://chris.beams.io/posts/git-commit/)
- [Git Pro Book (free)](https://git-scm.com/book/en/v2)
- [Bash Tab-Completion Snippet](https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash)
Expand Down Expand Up @@ -164,6 +164,7 @@ Personal Guide
- [https://github.com/ethereum/EIPs/blob/confluenceuser/EIPS/eip-1010.md](https://github.com/ethereum/EIPs/blob/confluenceuser/EIPS/eip-1010.md)
- [https://docs-v1.prefect.io/core/pins/pin-01-introduce-pins.html](https://docs-v1.prefect.io/core/pins/pin-01-introduce-pins.html)
- [https://peps.python.org/pep-0387/](https://peps.python.org/pep-0387)
- <https://github.com/AICoE/aicoe-ci/blob/39de02af86a0d1f9dcd395fa88b858f1c6880411/docs/adr/0000-use-markdown-architectural-decision-records.md>
- And many others!

<-- Links -->
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""nox-poetry configuration file.""" # noqa: INP001
"""nox-poetry configuration file."""

from calcipy.noxfile import build_check, build_dist, tests # noqa: F401
2 changes: 1 addition & 1 deletion tail_jsonl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from beartype import BeartypeConf
from beartype.claw import beartype_this_package
from beartype.roar import BeartypeDecorHintPep585DeprecationWarning
from typing_extensions import Self # noqa: UP035
from typing_extensions import Self

__version__ = '1.2.5'
__pkg_name__ = 'tail_jsonl'
Expand Down

0 comments on commit df76f43

Please sign in to comment.