diff --git a/.github/actions/init-environment/action.yml b/.github/actions/init-environment/action.yml new file mode 100644 index 0000000..3337a38 --- /dev/null +++ b/.github/actions/init-environment/action.yml @@ -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 diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml new file mode 100644 index 0000000..e3468c3 --- /dev/null +++ b/.github/workflows/code-checks.yml @@ -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 diff --git a/.github/workflows/preview-links.yml b/.github/workflows/preview-links.yml new file mode 100644 index 0000000..763aa6c --- /dev/null +++ b/.github/workflows/preview-links.yml @@ -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' diff --git a/Makefile b/Makefile index 167e94b..ec15073 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/docs/courses/compare-movies-workflow/assets/code_reviews/06/app.py b/docs/courses/compare-movies-workflow/assets/code_reviews/06/app.py index c9f0272..b1db824 100644 --- a/docs/courses/compare-movies-workflow/assets/code_reviews/06/app.py +++ b/docs/courses/compare-movies-workflow/assets/code_reviews/06/app.py @@ -52,4 +52,4 @@ workflow.run() # View the output -print(workflow.output_task.output.value) +print(workflow.output) diff --git a/docs/courses/image-query/assets/code_reviews/02/app.py b/docs/courses/image-query/assets/code_reviews/02/app.py index 377889a..9fe9b5f 100644 --- a/docs/courses/image-query/assets/code_reviews/02/app.py +++ b/docs/courses/image-query/assets/code_reviews/02/app.py @@ -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) diff --git a/docs/courses/shotgrid-tool/assets/code_reviews/05/shotgrid_tool/tool.py b/docs/courses/shotgrid-tool/assets/code_reviews/05/shotgrid_tool/tool.py index 7332208..26cd52a 100644 --- a/docs/courses/shotgrid-tool/assets/code_reviews/05/shotgrid_tool/tool.py +++ b/docs/courses/shotgrid-tool/assets/code_reviews/05/shotgrid_tool/tool.py @@ -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( diff --git a/docs/courses/shotgrid-tool/assets/code_reviews/06/shotgrid_tool/tool.py b/docs/courses/shotgrid-tool/assets/code_reviews/06/shotgrid_tool/tool.py index 208e758..e8ea5b6 100644 --- a/docs/courses/shotgrid-tool/assets/code_reviews/06/shotgrid_tool/tool.py +++ b/docs/courses/shotgrid-tool/assets/code_reviews/06/shotgrid_tool/tool.py @@ -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": diff --git a/docs/courses/shotgrid-tool/assets/code_reviews/07/shotgrid_tool/tool.py b/docs/courses/shotgrid-tool/assets/code_reviews/07/shotgrid_tool/tool.py index 2d5e6b8..96b0679 100644 --- a/docs/courses/shotgrid-tool/assets/code_reviews/07/shotgrid_tool/tool.py +++ b/docs/courses/shotgrid-tool/assets/code_reviews/07/shotgrid_tool/tool.py @@ -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": diff --git a/docs/courses/shotgrid-tool/assets/code_reviews/08/shotgrid_tool/tool.py b/docs/courses/shotgrid-tool/assets/code_reviews/08/shotgrid_tool/tool.py index 2d5e6b8..96b0679 100644 --- a/docs/courses/shotgrid-tool/assets/code_reviews/08/shotgrid_tool/tool.py +++ b/docs/courses/shotgrid-tool/assets/code_reviews/08/shotgrid_tool/tool.py @@ -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": diff --git a/docs/courses/shotgrid-tool/assets/code_reviews/09/shotgrid_tool/tool.py b/docs/courses/shotgrid-tool/assets/code_reviews/09/shotgrid_tool/tool.py index 2d5e6b8..96b0679 100644 --- a/docs/courses/shotgrid-tool/assets/code_reviews/09/shotgrid_tool/tool.py +++ b/docs/courses/shotgrid-tool/assets/code_reviews/09/shotgrid_tool/tool.py @@ -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":