Skip to content

Commit

Permalink
Add code checks to PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Dec 10, 2024
1 parent 986224a commit e385c81
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 7 deletions.
37 changes: 37 additions & 0 deletions .github/actions/init-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Init Environment"
description: "Initialize environment for tests"
runs:
using: "composite"
steps:
- name: Checkout actions
uses: actions/checkout@v4

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

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
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 --with test
shell: bash
- name: Activate venv
run: |
source $VENV
echo PATH=$PATH >> $GITHUB_ENV
shell: bash
65 changes: 65 additions & 0 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Code Checks

on:
push:
branches: [ "main"]
pull_request:
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.11"]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run formatter
run: make check/format
type-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
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.11" ]
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.11" ]
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run linter
run: make check/spell
23 changes: 23 additions & 0 deletions .github/workflows/preview-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Read the Docs Preview
on: push
# pull_request_target:
# types:
# - opened
# paths:
# - "docs/**"

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

permissions:
pull-requests: write

jobs:
pull-request-links:
runs-on: ubuntu-latest
steps:
- uses: readthedocs/actions/preview@v1
with:
project-slug: ${{ secrets.READTHEDOCS_PROJECT_SLUG }}
single-version: 'false'
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ check/spell:
.PHONY: check/lint
check/lint:
@poetry run ruff check

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

.PHONY: docs
docs: ## Build documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
workflow.run()

# View the output
print(workflow.output_task.output.value)
print(workflow.output)
1 change: 0 additions & 1 deletion docs/courses/image-query/assets/code_reviews/02/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
agent = Agent(stream=True)



# Modify the Agent's response to have some color.
def formatted_response(response: str) -> None:
print(f"[dark_cyan]{response}", end="", flush=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ShotGridTool(BaseTool):
}
)
def get_session_token(self, _: dict) -> TextArtifact | ErrorArtifact:
import shotgun_api3
import shotgun_api3 # pyright: ignore[reportMissingImports]

try:
sg = shotgun_api3.Shotgun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ShotGridTool(BaseTool):
}
)
def get_session_token(self, _: dict) -> TextArtifact | ErrorArtifact:
import shotgun_api3
import shotgun_api3 # pyright: ignore[reportMissingImports]

try:
if self.login_method == "api_key":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ShotGridTool(BaseTool):
}
)
def meta_method(self, sg_method_name: str, sg_params: list[str]) -> TextArtifact | ErrorArtifact:
import shotgun_api3
import shotgun_api3 # pyright: ignore[reportMissingImports]

try:
if self.login_method == "api_key":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ShotGridTool(BaseTool):
}
)
def meta_method(self, sg_method_name: str, sg_params: list[str]) -> TextArtifact | ErrorArtifact:
import shotgun_api3
import shotgun_api3 # pyright: ignore[reportMissingImports]

try:
if self.login_method == "api_key":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ShotGridTool(BaseTool):
}
)
def meta_method(self, sg_method_name: str, sg_params: list[str]) -> TextArtifact | ErrorArtifact:
import shotgun_api3
import shotgun_api3 # pyright: ignore[reportMissingImports]

try:
if self.login_method == "api_key":
Expand Down

0 comments on commit e385c81

Please sign in to comment.