Skip to content

Commit d11ffb4

Browse files
committed
Merge remote-tracking branch 'origin/main' into users/jdixon/analyze-project-tests
2 parents 386d79c + 12f988e commit d11ffb4

File tree

8 files changed

+681
-14
lines changed

8 files changed

+681
-14
lines changed

.github/test_projects/repo_root/README.md

Whitespace-only changes.

.github/test_projects/repo_root/poetry.lock

Lines changed: 597 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[project]
2+
name = "test-project"
3+
version = "0.1.0"
4+
description = ""
5+
authors = [
6+
{name = "Joel Dixon",email = "[email protected]"}
7+
]
8+
readme = "README.md"
9+
requires-python = ">=3.9,<4.0"
10+
dynamic = ["dependencies"]
11+
12+
[tool.poetry]
13+
packages = [{include = "test_project", from = "src"}]
14+
15+
[tool.poetry.group.lint.dependencies]
16+
ni-python-styleguide = ">=0.4.1"
17+
mypy = ">=1.0"
18+
pyright = { version = ">=1.1.400", extras = ["nodejs"] }
19+
20+
[tool.ni-python-styleguide]
21+
extend_exclude = "update-project-version"
22+
23+
[tool.mypy]
24+
mypy_path = "."
25+
files = "."
26+
namespace_packages = true
27+
strict = true
28+
explicit_package_bases = true
29+
exclude = "update-project-version"
30+
31+
[tool.pyright]
32+
include = ["src/", "tests/"]
33+
exclude = ["update-project-version"]
34+
35+
[build-system]
36+
requires = ["poetry-core>=2.0.0,<3.0.0"]
37+
build-backend = "poetry.core.masonry.api"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Docstring required."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Module docstring."""

.github/workflows/test_actions.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,28 @@ jobs:
270270
with:
271271
project-directory: ${{ github.workspace }}/.github/test_projects/only-ni-python-styleguide
272272

273+
test_analyze_project_repo_root:
274+
name: Test analyze-project (repo root)
275+
runs-on: ${{ matrix.os }}
276+
strategy:
277+
matrix:
278+
os: [windows-latest, ubuntu-latest, macos-latest]
279+
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11]
280+
steps:
281+
- name: Check out repo
282+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
283+
- name: Set up Python
284+
uses: ./setup-python
285+
with:
286+
python-version: ${{ matrix.python-version }}
287+
- name: Set up Poetry
288+
uses: ./setup-poetry
289+
- name: Copy Python project to root
290+
run: cp -av "${{ github.workspace }}/.github/test_projects/repo_root"/* "${{ github.workspace }}"
291+
shell: bash
292+
- name: Analyze Python project
293+
uses: ./analyze-project
294+
273295
# This job is intended to combine the test results so we don't have to list
274296
# each matrix combination in the required status check settings. There are a
275297
# lot of corner cases that make this harder than it should be; see See
@@ -285,6 +307,7 @@ jobs:
285307
test_check_project_version,
286308
test_update_project_version,
287309
test_analyze_project,
310+
test_analyze_project_repo_root,
288311
]
289312
if: ${{ !cancelled() }}
290313
steps:

analyze-project/action.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ runs:
5959
- name: Check for mypy and pyright installation
6060
id: check_tools
6161
run: |
62-
poetry run python - <<EOF
6362
import os
6463
from importlib.metadata import version, PackageNotFoundError
6564
@@ -73,9 +72,8 @@ runs:
7372
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
7473
print(f"mypy={is_installed('mypy')}", file=output)
7574
print(f"pyright={is_installed('pyright')}", file=output)
76-
EOF
7775
working-directory: ${{ inputs.project-directory }}
78-
shell: bash
76+
shell: poetry run python {0}
7977
- name: Echo check_tools outputs
8078
run: |
8179
echo "mypy installed: ${{ steps.check_tools.outputs.mypy }}"
@@ -94,7 +92,7 @@ runs:
9492
working-directory: ${{ inputs.project-directory }}
9593
- name: Pyright static analysis
9694
if: steps.check_tools.outputs.pyright == 'true'
97-
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
95+
uses: jakebailey/pyright-action@6cabc0f01c4994be48fd45cd9dbacdd6e1ee6e5e # v2.3.3
9896
with:
9997
version: PATH
10098
working-directory: ${{ inputs.project-directory }}

setup-poetry/action.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,30 @@ runs:
2727
- name: Set paths (Linux/Mac)
2828
if: runner.os != 'Windows'
2929
run: |
30-
echo "POETRY_BIN_DIR=$GITHUB_WORKSPACE/.cache/poetry/bin" >> "$GITHUB_ENV"
31-
echo "POETRY_CONFIG_DIR=$GITHUB_WORKSPACE/.cache/poetry/config" >> "$GITHUB_ENV"
32-
echo "POETRY_HOME=$GITHUB_WORKSPACE/.cache/poetry/home" >> "$GITHUB_ENV"
33-
echo "POETRY_HOME_BIN=$GITHUB_WORKSPACE/.cache/poetry/home/bin" >> "$GITHUB_ENV"
34-
echo "$GITHUB_WORKSPACE/.cache/poetry/bin" >> "$GITHUB_PATH"
30+
# Use the "pipeline directory" so that tools that search the workspace
31+
# directory for Python files will not find the Poetry cache. Use
32+
# realpath to normalize the "../".
33+
PIPELINE_DIR="$(realpath $GITHUB_WORKSPACE/..)"
34+
POETRY_ROOT="$PIPELINE_DIR/.cache/poetry"
35+
echo "POETRY_BIN_DIR=$POETRY_ROOT/bin" >> "$GITHUB_ENV"
36+
echo "POETRY_CONFIG_DIR=$POETRY_ROOT/config" >> "$GITHUB_ENV"
37+
echo "POETRY_HOME=$POETRY_ROOT/home" >> "$GITHUB_ENV"
38+
echo "POETRY_HOME_BIN=$POETRY_ROOT/home/bin" >> "$GITHUB_ENV"
39+
echo "$POETRY_ROOT/bin" >> "$GITHUB_PATH"
3540
shell: bash
3641
- name: Set paths (Windows)
3742
if: runner.os == 'Windows'
3843
run: |
39-
Add-Content $env:GITHUB_ENV "POETRY_BIN_DIR=$env:GITHUB_WORKSPACE\.cache\poetry\bin"
40-
Add-Content $env:GITHUB_ENV "POETRY_CONFIG_DIR=$env:GITHUB_WORKSPACE\.cache\poetry\config"
41-
Add-Content $env:GITHUB_ENV "POETRY_HOME=$env:GITHUB_WORKSPACE\.cache\poetry\home"
42-
Add-Content $env:GITHUB_ENV "POETRY_HOME_BIN=$env:GITHUB_WORKSPACE\.cache\poetry\home\Scripts"
43-
Add-Content $env:GITHUB_PATH "$env:GITHUB_WORKSPACE\.cache\poetry\bin"
44+
# Use the "pipeline directory" so that tools that search the workspace
45+
# directory for Python files will not find the Poetry cache. Use
46+
# Resolve-Path to normalize the "../".
47+
$PIPELINE_DIR = (Resolve-Path -Path "$env:GITHUB_WORKSPACE\..").Path
48+
$POETRY_ROOT = "$PIPELINE_DIR\.cache\poetry"
49+
Add-Content $env:GITHUB_ENV "POETRY_BIN_DIR=$POETRY_ROOT\bin"
50+
Add-Content $env:GITHUB_ENV "POETRY_CONFIG_DIR=$POETRY_ROOT\config"
51+
Add-Content $env:GITHUB_ENV "POETRY_HOME=$POETRY_ROOT\home"
52+
Add-Content $env:GITHUB_ENV "POETRY_HOME_BIN=$POETRY_ROOT\home\Scripts"
53+
Add-Content $env:GITHUB_PATH "$POETRY_ROOT\bin"
4454
shell: pwsh
4555
- name: Copy paths from $GITHUB_ENV to $GITHUB_OUTPUT
4656
id: copy-paths

0 commit comments

Comments
 (0)