Skip to content

Commit

Permalink
Merge extensions changes
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Nov 18, 2024
1 parent d64b449 commit 102cf46
Show file tree
Hide file tree
Showing 20 changed files with 817 additions and 1,266 deletions.
25 changes: 25 additions & 0 deletions .github/.dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
versioning-strategy: increase-if-necessary
groups:
dependencies:
dependency-type: "production"
update-types:
- "minor"
- "patch"
group-dependencies:
dependency-type: "development"
update-types:
- "minor"
- "patch"
allow:
- dependency-type: production
- dependency-type: development
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
16 changes: 8 additions & 8 deletions .github/actions/init-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ runs:
using: "composite"
steps:
- name: Checkout actions
uses: actions/checkout@v3
uses: actions/checkout@v4

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

Expand All @@ -20,18 +21,17 @@ runs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with test --with dev --all-extras
run: poetry install --no-interaction --with test --with dev --all-extras
shell: bash

- name: Activate venv
- name: Activate venv
run: |
source .venv/bin/activate
source $VENV
echo PATH=$PATH >> $GITHUB_ENV
shell: bash
54 changes: 49 additions & 5 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,65 @@ name: Code Checks

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
format:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
python-version: ["3.12"]
steps:
- name: Checkout actions
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run formatter
run: black --check .
run: make check/format
type-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run type checker
run: make check/types
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run linter
run: make check/lint
spell-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run linter
run: make check/spell

38 changes: 31 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,45 @@ name: Unit Tests

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
test-ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run unit tests
run: make test/unit
test-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
defaults:
run:
shell: bash
steps:
- name: Checkout actions
uses: actions/checkout@v3
- name: Init environment
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run unit tests
run: pytest tests
# TODO: make test/unit fails with the following error:
# process_begin: CreateProcess(NULL, poetry run pytest -n auto tests/unit, ...) failed.
# make (e=2): The system cannot find the file specified.
# make: *** [Makefile:24: test/unit] Error 2
run: poetry run pytest tests/unit
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
- repo: local
hooks:
- id: ruff-lint
name: Ruff
entry: make lint
language: system
types: [python]
- repo: local
hooks:
- id: ruff-format
name: Ruff
entry: make format
language: system
types: [python]
- repo: local
hooks:
- id: pyright
name: Pyright
entry: make check/types
language: system
types: [python]
- repo: local
hooks:
- id: typos
name: Typos
entry: make check/spell
language: system
types: [python]
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.PHONY: install
install: ## Install all dependencies.
@make install/all

.PHONY: install/core
install/core: ## Install core dependencies.
@poetry install

.PHONY: install/all
install/all: ## Install all dependencies.
@poetry install --with dev --with test
@poetry run pre-commit install

.PHONY: install/dev
install/dev: ## Install dev dependencies.
@poetry install --with dev

.PHONY: install/test
install/test: ## Install test dependencies.
@poetry install --with test

.PHONY: test ## Run all tests.
test: test/unit

.PHONY: test/unit
test/unit: ## Run unit tests.
@poetry run pytest tests/unit

.PHONY: test/unit/%
test/unit/%: ## Run specific unit tests.
@poetry run pytest tests/unit -k $*

.PHONY: lint
lint: ## Lint project.
@poetry run ruff check --fix

.PHONY: format
format: ## Format project.
@poetry run ruff format

.PHONY: check
check: check/format check/lint check/types check/spell ## Run all checks.

.PHONY: check/format
check/format:
@poetry run ruff format --check

.PHONY: check/lint
check/lint:
@poetry run ruff check

.PHONY: check/types
check/types:
@poetry run pyright griptape

.PHONY: check/spell
check/spell:
@poetry run typos

.DEFAULT_GOAL := help
.PHONY: help
help: ## Print Makefile help text.
@# Matches targets with a comment in the format <target>: ## <comment>
@# then formats help output using these values.
@grep -E '^[a-zA-Z_\/-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-12s\033[0m%s\n", $$1, $$2}'
Loading

0 comments on commit 102cf46

Please sign in to comment.