Skip to content

Commit

Permalink
Sync with template
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Jul 18, 2024
1 parent 8a1f512 commit 288655f
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2024.1.1-91-g2217ca3
_commit: 2024.1.1-166-g3a37de1
_src_path: gh:blakeNaccarato/copier-python
actions_runner: ubuntu-22.04
active: true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/changerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
strategy:
matrix:
runner: ["ubuntu-22.04"]
python: ["3.11"]
permissions:
contents: "write"
runs-on: "${{ matrix.runner }}"
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defaults:
run:
shell: "pwsh"
env:
UV_CACHE_DIR: ".cache/uv-cache"
UV_CACHE_DIR: "../uv-cache"
UV_SYSTEM_PYTHON: "true"
jobs:
sync:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; sphinx-build -EaT docs _site"
- run: "sphinx-build -EaT docs _site"
- uses: "actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa" # v3.0.1
deploy-docs:
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; ruff check --no-fix --output-format github ."
- run: "ruff check --no-fix --output-format github ."
fawltydeps:
needs: "sync"
strategy:
Expand All @@ -123,7 +123,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; fawltydeps"
- run: "fawltydeps"
pyright:
needs: "sync"
strategy:
Expand All @@ -146,9 +146,9 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v4.1.7
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v2.3.1
with:
pylance-version: "2024.6.1"
pylance-version: "${{ env.PYRIGHT_PYTHON_PYLANCE_VERSION }}"
test:
needs: "sync"
strategy:
Expand Down Expand Up @@ -176,8 +176,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1 -Version '${{ matrix.python }}'"
# ! https://github.com/pytest-dev/pytest-cov/issues/479#issuecomment-1247444988
- run: ". scripts/Initialize-Shell.ps1; pytest --cov --cov-config pyproject.toml"
- run: "pytest"
- if: startsWith(matrix.runner, 'ubuntu') && matrix.python == '3.11'
uses: "codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673" # v4.5.0
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:
run:
shell: "pwsh"
env:
UV_CACHE_DIR: ".cache/uv-cache"
UV_CACHE_DIR: "../uv-cache"
SYNC_PY_DISABLE_CI: True
jobs:
no-spaces-in-path:
Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
- uses: "actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9" # v4.0.2
with:
path: "${{ env.UV_CACHE_DIR }}"
key: "uv-${{ matrix.runner }}-${{ matrix.python }}-${{ hashFiles('lock.json') }}"
- uses: "actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f" # v5.1.1
key: "uv-${{ matrix.runner }}-${{ matrix.python }}-${{ hashFiles('repo path with spaces/lock.json') }}"
- uses: "actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d" # v5.1.0
with:
python-version: "${{ matrix.python }}"
- working-directory: "repo path with spaces"
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/high.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defaults:
run:
shell: "pwsh"
env:
UV_CACHE_DIR: ".cache/uv-cache"
UV_CACHE_DIR: "../uv-cache"
UV_SYSTEM_PYTHON: "true"
SYNC_PY_HIGH: "true"
jobs:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; sphinx-build -EaT docs _site"
- run: "sphinx-build -EaT docs _site"
- uses: "actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa" # v3.0.1
ruff:
needs: "sync"
Expand All @@ -68,7 +68,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; ruff check --no-fix --output-format github ."
- run: "ruff check --no-fix --output-format github ."
fawltydeps:
needs: "sync"
strategy:
Expand All @@ -87,7 +87,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; fawltydeps"
- run: "fawltydeps"
pyright:
needs: "sync"
strategy:
Expand All @@ -106,9 +106,9 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v4.1.7
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v2.3.1
with:
pylance-version: "2024.6.1"
pylance-version: "${{ env.PYRIGHT_PYTHON_PYLANCE_VERSION }}"
test:
needs: "sync"
strategy:
Expand All @@ -132,7 +132,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1 -Version '${{ matrix.python }}'"
- run: ". scripts/Initialize-Shell.ps1; pytest"
- run: "pytest"
lock:
needs:
- "ruff"
Expand All @@ -148,7 +148,9 @@ jobs:
runs-on: "${{ matrix.runner }}"
steps:
- uses: "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" # v4.1.7
- uses: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16" # v4.1.8
with:
submodules: True
- uses: "actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e" # v4.1.7
with:
name: "lock"
- uses: "stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842" # v5.0.1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
url: "https://pypi.org/p/boilerdata"
steps:
- uses: "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" # v4.1.7
- uses: "actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f" # v5.1.1
- uses: "actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d" # v5.1.0
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1 -Release"
- run: ". scripts/Initialize-Shell.ps1; python -m build --installer uv"
- uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1.3.3
- run: "python -m build --installer uv"
- uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
with:
subject-path: "dist/**"
- run: "gh release upload '${{ github.event.release.tag_name }}' dist/**"
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ci:
- "fawltydeps-docs"
- "fawltydeps-scripts"
- "fawltydeps-tests"
- "pyright"
- "pytest-fast-only"
- "synchronize-params"
autoupdate_schedule: "quarterly"
Expand Down Expand Up @@ -67,13 +66,6 @@ repos:
files: "^tests/.*$"
entry: |
pwsh -Command ". scripts/Initialize-Shell.ps1; fawltydeps --config-file tests/pyproject.toml"
- id: "pyright"
name: "pyright"
pass_filenames: false
language: "system"
entry: |
pwsh -Command ". scripts/Initialize-Shell.ps1; pyright"
types_or: ["python", "pyi"]
- id: "pytest-fast-only"
name: "pytest-fast-only"
pass_filenames: false
Expand Down
17 changes: 17 additions & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,30 @@
"enabled": true
},
"enabledManagers": [
"custom.regex",
"devcontainer",
"git-submodules",
"github-actions",
"pep621",
"pip_requirements",
"pre-commit"
],
"customManagers": [
{
"description": "Pylance",
"customType": "regex",
"fileMatch": [
"^scripts/Initialize-Shell\\.ps1$",
"^\\.devcontainer/devcontainer\\.json$"
],
"matchStrings": [
"PYRIGHT_PYTHON_PYLANCE_VERSION = '(?<currentValue>.+)'",
"ms-python\\.vscode-pylance@(?<currentValue>[^\"]+)"
],
"datasourceTemplate": "github-releases",
"depNameTemplate": "microsoft/pylance-release"
}
],
"pip_requirements": {
"description": "Additionally monitor these files",
"fileMatch": ["(^|/)requirements/.+$"]
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"aaron-bond.better-comments",
"bierner.markdown-preview-github-styles",
"charliermarsh.ruff",
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"eamodio.gitlens",
Expand All @@ -12,12 +13,16 @@
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ms-azuretools.vscode-docker",
"ms-python.debugpy",
"ms-python.python",
"ms-toolsai.jupyter",
"ms-vscode.powershell",
"ms-vscode-remote.remote-containers",
"njpwerner.autodocstring",
"njpwerner.autodocstring",
"redhat.vscode-yaml",
"rodolphebarbanneau.python-docstring-highlighter",
"rodolphebarbanneau.python-docstring-highlighter",
"ryanluker.vscode-coverage-gutters",
"sourcery.sourcery",
"stkb.rewrap",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@
{
"label": "task: pre-commit",
"type": "shell",
"command": ". scripts/Initialize-Shell.ps1; pre-commit",
"command": ". scripts/Initialize-Shell.ps1; pre-commit run --verbose",
"icon": { "id": "git-commit" },
"problemMatcher": []
},
{
"label": "task: pre-commit (all)",
"type": "shell",
"command": ". scripts/Initialize-Shell.ps1; pre-commit run --all-files",
"command": ". scripts/Initialize-Shell.ps1; pre-commit run --all-files --verbose",
"icon": { "id": "git-commit" },
"problemMatcher": []
},
Expand Down
18 changes: 3 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,8 @@ name = "Changes"
showcontent = true

[tool.pyright]
exclude = [
"**/node_modules",
"**/__pycache__",
"**/.*",
"**/.*/**",
"**/.venv",
"**/.vscode/extensions",
"**/AppData",
"bin",
"submodules/template",
"submodules/**/docs",
"submodules/**/scripts",
"submodules/**/tests",
]
stubPath = "submodules/stubs/stubs"
ignore = ["bin", "submodules", "scripts/install.py"]
typeCheckingMode = "strict"
# Default "true" in strict
analyzeUnannotatedFunctions = true
Expand Down Expand Up @@ -212,7 +200,7 @@ reportUnusedCallResult = "none"

[tool.ruff]
cache-dir = ".cache/.ruff_cache"
extend-exclude = ["bin", "submodules", "**/axes_enum.py"]
extend-exclude = ["bin", "submodules", "scripts/install.py", "**/axes_enum.py"]
extend-include = ["*.ipynb"]
src = ["src", "docs", "scripts", "tests"]
output-format = "grouped"
Expand Down
3 changes: 2 additions & 1 deletion scripts/Initialize-Repo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ catch [System.Management.Automation.NativeCommandExitException] { $fresh = $true

git add .
git commit --no-verify -m 'Prepare template using blakeNaccarato/copier-python'
git submodule add --force --name template 'https://github.com/blakeNaccarato/copier-python.git' submodules/template
git submodule add --force --name 'template' 'https://github.com/blakeNaccarato/copier-python.git' 'submodules/template'
git submodule add --force --name 'stubs' 'https://github.com/microsoft/python-type-stubs.git' 'submodules/stubs'
git add .
git commit --no-verify -m 'Add template and type stub submodules'
scripts/Sync-Py.ps1
Expand Down
40 changes: 25 additions & 15 deletions scripts/Initialize-Shell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Initialization commands for PowerShell shells in pre-commit and tasks.#>

# ? Error-handling
$ErrorActionPreference = 'Stop'
($PSNativeCommandUseErrorActionPreference = $true) | Out-Null
($ErrorView = 'NormalView') | Out-Null
$PSNativeCommandUseErrorActionPreference = $true
$ErrorView = 'NormalView'

# ? Fix leaky UTF-8 encoding settings on Windows
if ($IsWindows) {
Expand All @@ -15,25 +15,35 @@ if ($IsWindows) {
[console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
}

# ? Environment variables
$Env:PYRIGHT_PYTHON_PYLANCE_VERSION = '2024.6.1'
$Env:PYDEVD_DISABLE_FILE_VALIDATION = 1
$Env:PYTHONIOENCODING = 'utf-8:strict'
$Env:PYTHONUTF8 = 1
$Env:PYTHONWARNDEFAULTENCODING = 1
# Ignore warnings until explicitly re-enabled in tests
$Env:PYTHONWARNINGS = 'ignore'

# ? Environment setup
function Set-Env {
<#.SYNOPSIS
Load `.env`, activate a virtual environment found here or in parent directories.#>
Activate virtual environment and set environment variables.#>

# ? Set environment variables
$LocalBin = (Test-Path 'bin') ? (Get-Item 'bin') : (New-Item -ItemType Directory 'bin')
$Vars = $Env:GITHUB_ENV ? $(Get-Content $Env:GITHUB_ENV |
Select-String -Pattern '^(.+)=.+$' |
ForEach-Object { $_.Matches.Groups[1].value }) : @{}
foreach ($i in @{
PATH = "$LocalBin$($IsWindows ? ';' : ':')$Env:PATH"
PYRIGHT_PYTHON_PYLANCE_VERSION = '2024.6.1'
PYDEVD_DISABLE_FILE_VALIDATION = '1'
PYTHONIOENCODING = 'utf-8:strict'
PYTHONWARNDEFAULTENCODING = '1'
PYTHONWARNINGS = 'ignore'
COVERAGE_CORE = 'sysmon'
}.GetEnumerator() ) {
Set-Item "Env:$($i.Key)" $($i.Value)
if ($Env:GITHUB_ENV -and ($i.Key -notin $Vars)) {
"$($i.Key)=$($i.Value)" >> $Env:GITHUB_ENV
}
}

# ? Activate virtual environment if one exists
if (Test-Path '.venv') {
if ($IsWindows) { .venv/scripts/activate.ps1 } else { .venv/bin/activate.ps1 }
}
# ? Prepend local `bin` to PATH
$sep = $IsWindows ? ';' : ':'
$Env:PATH = "bin$sep$Env:PATH"

}
Set-Env
Loading

0 comments on commit 288655f

Please sign in to comment.