Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Mar 13, 2024
1 parent 5b46d3e commit b242a59
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 46 deletions.
18 changes: 2 additions & 16 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ jobs:
- uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0
with:
python-version: "${{ matrix.python_version }}"
- run: ". .tools/sync.ps1"
shell: "pwsh"
- run: "SETUP"
shell: "pwsh"
- run: "CI_ONLY_SETUP"
shell: "pwsh"
- run: "LOCK"
shell: "pwsh"
- run: "TEST"
- run: ".tools/tools.ps1 LOCK"
shell: "pwsh"
- uses: "actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3" #v4.3.1
with:
Expand All @@ -58,13 +50,7 @@ jobs:
- uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0
with:
python-version: "3.11"
- run: ". .tools/sync.ps1"
shell: "pwsh"
- run: "SETUP"
shell: "pwsh"
- run: "CI_ONLY_SETUP"
shell: "pwsh"
- run: "COMBINE"
- run: ".tools/tools.ps1 LOCK"
shell: "pwsh"
- uses: "stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d" # v5.0.0
with:
Expand Down
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ci:
skip:
# * ---------------------------------------------------------------------------- * #
- "local-pyrightconfig"
- "sync"
- "synchronize-params"
- "hide-docs-nb-inputs"
- "dvc-post-checkout"
Expand Down Expand Up @@ -32,12 +31,6 @@ repos:
pyproject\.toml
|\.tools/scripts/local_dev_configs.py
)$
- id: "sync"
name: "sync"
language: "system"
entry: "pwsh .tools/sync.ps1"
pass_filenames: false
always_run: true
- id: "synchronize-params"
name: "synchronize-params"
language: "system"
Expand Down
2 changes: 1 addition & 1 deletion .tools/boilercv_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def combine_locks():
indent=2,
obj={
lockfile.stem: lockfile.read_text(encoding="utf-8")
for lockfile in PLATFORM_LOCKS.iterdir()
for lockfile in PLATFORM_LOCKS.rglob("requirements_*.txt")
},
)
+ "\n",
Expand Down
59 changes: 37 additions & 22 deletions .tools/sync.ps1 → .tools/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ Synchronize the Python environment with this project's locked dependencies.
#>

Param(
# Python version to install or expect.
[string]$Version = (Get-Content '.copier-answers.yml' |
Select-String -Pattern '^python_version:\s?["'']([^"'']*)["'']$').Matches.Groups[1].value
# Job to run
[Parameter(Mandatory, ValueFromPipeline)][string]$Job
)

$Version = (Get-Content '.copier-answers.yml' |
Select-String -Pattern '^python_version:\s?["'']([^"'']*)["'']$').Matches.Groups[1].value

$PSNativeCommandUseErrorActionPreference = $true
$PSNativeCommandUseErrorActionPreference | Out-Null

Expand Down Expand Up @@ -88,7 +90,7 @@ function inst {
function sync {
Param([Parameter(Mandatory, ValueFromPipeline)][string]$String)
if ($Env:CI) {
run "uv pip sync --system --break-system-packages $String"
run "uv pip sync --system --break-system-packages $String"
}
else {
run "uv pip sync $String"
Expand All @@ -100,36 +102,49 @@ function tools {
run "boilercv_tools $String"
}

function SETUP {

function Initialize-Job {
run 'pip install uv'
inst '-e .tools/.'
run "$tools find-lock"
}

$lock = tools 'get-lockfile'


function Initialize-LocalJob {
Initialize-Job
tools find-lock
sync $lock
}

function CI_ONLY_SETUP {
run "copier update --defaults --vcs-ref $(git rev-parse HEAD:submodules/template)"
run "$tools sync"
function Initialize-CiJob {
Initialize-Job
# run "copier update --defaults --vcs-ref $(git rev-parse HEAD:submodules/template)"
tools sync
}

function LOCK {
$lock = tools 'get-lockfile'
run "$tools lock"
function Invoke-Lock {
Initialize-CiJob
tools 'lock'
sync $lock
run "$tools lock --highest"
elseif ($Env:TEST) {
run 'pytest'
}
tools 'lock --highest'
}

function TEST {
run 'pytest'
function Invoke-Combine {
Initialize-CiJob
tools 'lock'
sync $lock
tools 'lock --highest'
}

# * -------------------------------------------------------------------------------- * #
# function TEST {
# run 'pytest'
# }

function COMBINE {
if ($Job -eq 'LOCK') {
Invoke-Lock
}
elseif ($Job -eq 'COMBINE') {
Invoke-Combine
tools 'combine-locks'
run "$tools sync"
run "$tools combine-locks"
}

0 comments on commit b242a59

Please sign in to comment.