fix: clean up workflow duplication and syntax
This commit is contained in:
parent
e635e73e2b
commit
02f74ce659
|
|
@ -10,40 +10,27 @@ jobs:
|
||||||
validate:
|
validate:
|
||||||
runs-on: k8s
|
runs-on: k8s
|
||||||
container: node:18-bullseye
|
container: node:18-bullseye
|
||||||
container:
|
|
||||||
image: node:18-bullseye
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.sha }}
|
ref: ${{ gitea.sha }}
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.sha }}
|
|
||||||
- name: Validate repository
|
- name: Validate repository
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
./jeannie validate
|
./jeannie validate
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: k8s
|
runs-on: k8s
|
||||||
container: node:18-bullseye
|
container: node:18-bullseye
|
||||||
container:
|
|
||||||
image: node:18-bullseye
|
|
||||||
needs:
|
needs:
|
||||||
- validate
|
- validate
|
||||||
if: ${{ gitea.ref == 'refs/heads/main' }}
|
if: ${{ gitea.ref == 'refs/heads/main' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.sha }}
|
ref: ${{ gitea.sha }}
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.sha }}
|
|
||||||
- name: Block automatic deploy for external Gitea changes
|
- name: Block automatic deploy for external Gitea changes
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
@ -80,15 +67,15 @@ jobs:
|
||||||
def function_ranges(content):
|
def function_ranges(content):
|
||||||
starts = []
|
starts = []
|
||||||
for index, line in enumerate(content.splitlines(), 1):
|
for index, line in enumerate(content.splitlines(), 1):
|
||||||
match = re.match(r"^([A-Za-z_][A-Za-z0-9_]*)\(\) \{", line)
|
match = re.match(r"^([A-Za-z_][A-Za-z0-9_]*)\(\) \{", line)
|
||||||
if match:
|
if match:
|
||||||
starts.append((index, match.group(1)))
|
starts.append((index, match.group(1)))
|
||||||
|
|
||||||
ranges = []
|
ranges = []
|
||||||
for offset, (start, name) in enumerate(starts):
|
for offset, (start, name) in enumerate(starts):
|
||||||
end = starts[offset + 1][0] - 1 if offset + 1 < len(starts) else len(content.splitlines())
|
end = starts[offset + 1][0] - 1 if offset + 1 < len(starts) else len(content.splitlines())
|
||||||
if name in target_functions:
|
if name in target_functions:
|
||||||
ranges.append((start, end))
|
ranges.append((start, end))
|
||||||
return ranges
|
return ranges
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,22 +99,22 @@ jobs:
|
||||||
|
|
||||||
def overlaps(start, length, ranges):
|
def overlaps(start, length, ranges):
|
||||||
if length == 0:
|
if length == 0:
|
||||||
end = start
|
end = start
|
||||||
else:
|
else:
|
||||||
end = start + length - 1
|
end = start + length - 1
|
||||||
return any(start <= range_end and end >= range_start for range_start, range_end in ranges)
|
return any(start <= range_end and end >= range_start for range_start, range_end in ranges)
|
||||||
|
|
||||||
|
|
||||||
for line in diff.splitlines():
|
for line in diff.splitlines():
|
||||||
match = re.match(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", line)
|
match = re.match(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", line)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
old_start = int(match.group(1))
|
old_start = int(match.group(1))
|
||||||
old_length = int(match.group(2) or "1")
|
old_length = int(match.group(2) or "1")
|
||||||
new_start = int(match.group(3))
|
new_start = int(match.group(3))
|
||||||
new_length = int(match.group(4) or "1")
|
new_length = int(match.group(4) or "1")
|
||||||
if overlaps(old_start, old_length, base_ranges) or overlaps(new_start, new_length, current_ranges):
|
if overlaps(old_start, old_length, base_ranges) or overlaps(new_start, new_length, current_ranges):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
PY
|
PY
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue