Skip to content

Commit 6d96298

Browse files
committed
Merge branch 'develop' into beta
2 parents ae4103a + d4ddecf commit 6d96298

20 files changed

Lines changed: 850 additions & 78 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Discover minimum Python version
2+
description: Discover the lowest supported Python version based on pyptoject.toml file
3+
4+
inputs:
5+
working-directory:
6+
required: false
7+
default: "./"
8+
9+
outputs:
10+
pyversion:
11+
description: Lowest supported python version
12+
value: ${{ steps.pyversion.outputs.pyver }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: extract Python version
18+
id: pyversion
19+
shell: bash
20+
run: |
21+
# try to extract the 'python = "xxx"' string from TOML file
22+
CONSTRAINT=$(grep -E '^python\s*=' pyproject.toml | cut -d= -f2- | tr -d ' "')
23+
24+
if [[ $CONSTRAINT =~ (>=|\^|~)([0-9]+\.[0-9]+) ]]; then
25+
# echo "Operator: ${BASH_REMATCH[1]}"
26+
echo "pyver=${BASH_REMATCH[2]}" >> $GITHUB_OUTPUT
27+
else
28+
echo "No valid Python version found."
29+
return 1
30+
fi
31+
working-directory: ${{ inputs.working-directory }}

.github/do-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
ansible-galaxy collection build
44
ansible-galaxy collection publish paloaltonetworks-panos-* --server release_galaxy
5-
ansible-galaxy collection publish paloaltonetworks-panos-* --server automation_hub
5+
ansible-galaxy collection publish paloaltonetworks-panos-* --server automation_hub

.github/update-requirements.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This script updates the requirements file to match with version constraints in pyproject.yml
2+
# and also removes subdependencies keeping only the main dependencies
3+
4+
import toml
5+
import re
6+
7+
# Load pyproject.toml
8+
with open("pyproject.toml", "r") as f:
9+
pyproject = toml.load(f)
10+
11+
# Extract dependencies with their correct version constraints
12+
main_deps = pyproject["tool"]["poetry"]["dependencies"]
13+
main_deps.pop("python", None) # Remove Python entry
14+
15+
# Read exported requirements.txt
16+
with open("requirements.txt", "r") as f:
17+
exported_reqs = f.readlines()
18+
19+
main_reqs = [
20+
line
21+
for line in exported_reqs
22+
if any(line.split("=")[0] == dep for dep in main_deps.keys())
23+
]
24+
25+
26+
# Function to replace package version while keeping extras/markers
27+
def replace_version(line):
28+
match = re.match(r"^([a-zA-Z0-9\-_]+)(\[.*\])?([=><~!]+[^\s;]+)(.*)", line)
29+
if match:
30+
pkg_name, extras, constraint, rest = match.groups()
31+
pkg_name_lower = pkg_name.lower()
32+
33+
if pkg_name_lower in main_deps:
34+
return f"{pkg_name}{extras or ''}{main_deps[pkg_name_lower]}{rest}\n"
35+
36+
return line
37+
38+
39+
# Process and replace package versions
40+
updated_reqs = [replace_version(line) for line in main_reqs]
41+
42+
# Write cleaned requirements.txt
43+
with open("requirements.txt", "w") as f:
44+
f.writelines(updated_reqs)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: (sub) Discover Python version
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
permissions:
8+
contents: read
9+
10+
on:
11+
workflow_call:
12+
outputs:
13+
pyversion:
14+
description: A discovered Python version
15+
value: ${{ jobs.pyversion.outputs.pyversion }}
16+
17+
jobs:
18+
pyversion:
19+
name: Discover minimum Python version
20+
runs-on: ubuntu-latest
21+
outputs:
22+
pyversion: ${{ steps.pyversion.outputs.pyversion }}
23+
steps:
24+
- name: checkout code
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
26+
- name: discover Python version
27+
id: pyversion
28+
uses: ./.github/actions/discover_python_version
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Check Requirements
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
type: string
8+
required: true
9+
10+
env:
11+
NAMESPACE: paloaltonetworks
12+
COLLECTION_NAME: panos
13+
14+
jobs:
15+
needs-update:
16+
name: Need Requirements Update
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
21+
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
24+
with:
25+
path: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
26+
27+
- name: Install Python
28+
uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4
29+
with:
30+
python-version: ${{ inputs.python-version }}
31+
32+
- name: Install Poetry
33+
uses: Gr1N/setup-poetry@15821dc8a61bc630db542ae4baf6a7c19a994844 # v8
34+
with:
35+
poetry-version: "1.8.5"
36+
37+
- name: Install dependencies
38+
run: poetry install
39+
40+
- name: Install temp dependencies
41+
run: poetry run pip install toml
42+
43+
- name: Make requirements.txt
44+
run: poetry run make reqs
45+
46+
- name: Check for changes in requirements.txt
47+
run: |
48+
if git diff --exit-code requirements.txt; then
49+
echo "✅ No changes in requirements.txt"
50+
else
51+
echo "❌ requirements.txt is outdated. Please update it with "make reqs" and commit the changes."
52+
exit 1
53+
fi

0 commit comments

Comments
 (0)