Repository navigation
124 lines (114 loc) · 5.3 KB
/
Copy pathVersionCheck.yml
File metadata and controls
124 lines (114 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: "VersionCheck"
on:
workflow_call:
inputs:
julia-version:
description: "Julia version"
default: "1"
required: false
type: string
localregistry:
description: "Unused. Kept for backward compatibility with existing callers."
default: ""
required: false
type: string
subdir:
description: "Subdirectory containing the package's Project.toml. When set, VersionCheck reads `<subdir>/Project.toml` for the version-bump check. Empty (default) reads root Project.toml."
default: ""
required: false
type: string
paths:
description: "Newline-separated list of path prefixes / files defining positive scope for the substantive-PR check. A file triggers VersionCheck iff it equals one of these paths or starts with `<path>/`. Empty means no positive-scope filter; the check falls back to `exclude-paths`. Mutually exclusive with `exclude-paths`."
default: ""
required: false
type: string
exclude-paths:
description: "Newline-separated list of path prefixes / files defining negative scope for the substantive-PR check. A file does NOT trigger VersionCheck if it matches one of these. Default ignores `.gitignore`, `.pre-commit-config.yaml`, `.github`, and `jenkins` (workflow / config metadata changes don't require a version bump). Setting this replaces the default; use `additional-exclude-paths` to extend the default instead."
default: |
.gitignore
.pre-commit-config.yaml
.github
jenkins
required: false
type: string
additional-exclude-paths:
description: "Newline-separated list of path prefixes / files appended to `exclude-paths`. Use this to extend the defaults (e.g. `NDTensors` for the ITensors.jl monorepo) without re-declaring the standard ignores."
default: ""
required: false
type: string
jobs:
version-check:
name: "VersionCheck"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v7
# `[sources]` entries that must never reach `main`: an absolute `path` is a
# machine-specific `Pkg.develop` leak (it resolves the dep from a path that
# exists only on the author's machine, staying green on CI where it is
# absent), and a `url` is a cross-repo branch pin that is fine mid-review but
# resolves the dep from an unregistered branch once merged. A relative `path`
# (e.g. a subproject pointing at "..") is legitimate and allowed. Failing in
# draft PRs is intended: the point is to block these from reaching `main`.
- name: "Reject non-portable [sources] entries in Project.toml"
run: |
python3 - <<'PY'
import os, subprocess, sys, tomllib
files = subprocess.check_output(
["git", "ls-files", "*Project.toml"], text=True
).split()
bad = []
for f in files:
with open(f, "rb") as fh:
data = tomllib.load(fh)
for name, spec in data.get("sources", {}).items():
if not isinstance(spec, dict):
continue
path = spec.get("path")
if path is not None and os.path.isabs(path):
bad.append(f'{f}: [sources.{name}] has an absolute path = "{path}"')
if "url" in spec:
bad.append(f'{f}: [sources.{name}] has a url = "{spec["url"]}"')
if bad:
print(
"::error::These [sources] entries must not be merged to main: an "
"absolute path is machine-specific, and a url is a cross-repo "
'branch pin. Use a relative path (e.g. "..") or drop the source.'
)
for b in bad:
print(b)
sys.exit(1)
print(f"Checked {len(files)} Project.toml file(s); no non-portable [sources] entries.")
PY
- uses: ITensor/ITensorActions/.github/actions/classify-pr@main
id: classify
with:
# `subdir` (the in-tree package whose Project.toml is checked) is
# auto-appended to the positive scope so callers don't have to
# repeat it.
paths: |
${{ inputs.subdir }}
${{ inputs.paths }}
exclude-paths: |
${{ inputs.exclude-paths }}
${{ inputs.additional-exclude-paths }}
- name: "Skip version check on out-of-scope PR"
if: steps.classify.outputs.triggers != 'true'
run: |
echo "PR has no changes in this caller's scope; no version bump required. Reporting success."
- name: "Fetch base branch"
if: steps.classify.outputs.triggers == 'true'
run: git fetch --depth=1 origin "${{ github.base_ref }}"
- uses: julia-actions/setup-julia@v3
if: steps.classify.outputs.triggers == 'true'
with:
version: ${{ inputs.julia-version }}
- name: "Check version was bumped"
if: steps.classify.outputs.triggers == 'true'
uses: ITensor/ITensorActions/.github/actions/version-helpers@main
with:
mode: version-check
subdir: ${{ inputs.subdir }}
base-ref: origin/${{ github.base_ref }}