Skip to content

Commit e7f0e11

Browse files
authored
Merge pull request #182 from KenMwaura1/dev
Update dependabot configuration for pip ecosystem to target /src dire…
2 parents b42d437 + bbfb7b6 commit e7f0e11

File tree

4 files changed

+226
-3
lines changed

4 files changed

+226
-3
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
version: 2
22
updates:
33
- package-ecosystem: "pip"
4-
directory: "/"
4+
directory: "/src"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
# Focus on security updates and minor version updates
9+
ignore:
10+
- dependency-name: "*"
11+
update-types: ["version-update:semver-major"]
712

813
- package-ecosystem: "npm"
914
directory: "/vue-client"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Check Python Versions
2+
3+
on:
4+
schedule:
5+
# Run on the 1st of every month at 9 AM UTC
6+
- cron: '0 9 1 * *'
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
check-python-versions:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
needs-update: ${{ steps.check.outputs.needs-update }}
14+
new-versions: ${{ steps.check.outputs.new-versions }}
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Check Python versions
20+
id: check
21+
run: |
22+
# Define LTS and latest stable Python versions
23+
LATEST_VERSIONS=("3.10" "3.11" "3.12" "3.13")
24+
25+
echo "Latest Python versions: ${LATEST_VERSIONS[*]}"
26+
27+
# Extract current versions from workflow
28+
CURRENT_VERSIONS=$(grep -o '"3\.[0-9]\+"\|3\.[0-9]\+' .github/workflows/pythonapp.yml | grep -o '3\.[0-9]\+' | sort -u | tr '\n' ' ')
29+
echo "Current versions in workflow: $CURRENT_VERSIONS"
30+
31+
# Check if update is needed by comparing arrays
32+
NEEDS_UPDATE=false
33+
for version in "${LATEST_VERSIONS[@]}"; do
34+
if ! echo "$CURRENT_VERSIONS" | grep -q "$version"; then
35+
NEEDS_UPDATE=true
36+
break
37+
fi
38+
done
39+
40+
# Also check if we have extra old versions
41+
for version in $CURRENT_VERSIONS; do
42+
if [[ ! " ${LATEST_VERSIONS[*]} " =~ " $version " ]]; then
43+
NEEDS_UPDATE=true
44+
break
45+
fi
46+
done
47+
48+
if [ "$NEEDS_UPDATE" = "true" ]; then
49+
echo "needs-update=true" >> $GITHUB_OUTPUT
50+
echo "new-versions=[\"${LATEST_VERSIONS[0]}\", \"${LATEST_VERSIONS[1]}\", \"${LATEST_VERSIONS[2]}\", \"${LATEST_VERSIONS[3]}\"]" >> $GITHUB_OUTPUT
51+
echo "Update needed!"
52+
else
53+
echo "needs-update=false" >> $GITHUB_OUTPUT
54+
echo "Versions are up to date"
55+
fi
56+
57+
create-issue:
58+
needs: check-python-versions
59+
if: needs.check-python-versions.outputs.needs-update == 'true'
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Create issue for Python version update
63+
uses: actions/github-script@v7
64+
with:
65+
script: |
66+
const newVersions = ${{ needs.check-python-versions.outputs.new-versions }};
67+
68+
github.rest.issues.create({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
title: 'Python versions in CI workflow should be updated',
72+
body: `The Python versions in the CI workflow should be updated to the latest 3 stable versions:
73+
74+
**Recommended versions:** ${newVersions.join(', ')}
75+
76+
Please update the \`python-version\` matrix in \`.github/workflows/pythonapp.yml\`:
77+
78+
\`\`\`yaml
79+
strategy:
80+
matrix:
81+
python-version: ${JSON.stringify(newVersions)}
82+
\`\`\`
83+
84+
This issue was automatically created by the Check Python Versions workflow.`,
85+
labels: ['dependencies', 'python', 'ci']
86+
});

.github/workflows/pythonapp.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.9, "3.10", "3.11", "3.12"]
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
# Including Python 3.10 (LTS until 2026) and latest stable versions
18+
# GitHub Actions automatically gets the latest patch versions
1719

1820
steps:
1921
- uses: actions/checkout@v5
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Check Python Versions
2+
3+
on:
4+
schedule:
5+
# Run on the 1st of every month at 9 AM UTC
6+
- cron: '0 9 1 * *'
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
check-python-versions:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Get latest Python versions
22+
id: get-versions
23+
run: |
24+
# Get available Python versions from GitHub Actions
25+
# This fetches the latest 3 stable versions
26+
python -c "
27+
import requests
28+
import json
29+
import os
30+
31+
# Get available versions from the setup-python action
32+
# We'll simulate getting the latest 3 versions
33+
# In practice, you'd want to check the actual available versions
34+
35+
# Current stable versions as of 2025
36+
versions = ['3.11', '3.12', '3.13']
37+
38+
print('Available Python versions:', versions)
39+
40+
# Check current versions in workflow
41+
with open('.github/workflows/pythonapp.yml', 'r') as f:
42+
content = f.read()
43+
44+
current_versions = []
45+
for line in content.split('\n'):
46+
if 'python-version:' in line and '[' in line:
47+
# Extract versions from the matrix
48+
import re
49+
matches = re.findall(r'\"?(3\.\d+)\"?', line)
50+
current_versions = matches
51+
break
52+
53+
print('Current versions in workflow:', current_versions)
54+
print('Latest versions should be:', versions)
55+
56+
# Check if update is needed
57+
needs_update = set(current_versions) != set(versions)
58+
print('Needs update:', needs_update)
59+
60+
if needs_update:
61+
with open(os.environ['GITHUB_ENV'], 'a') as f:
62+
f.write(f'NEEDS_UPDATE=true\n')
63+
f.write(f'NEW_VERSIONS={json.dumps(versions)}\n')
64+
else:
65+
with open(os.environ['GITHUB_ENV'], 'a') as f:
66+
f.write(f'NEEDS_UPDATE=false\n')
67+
"
68+
69+
- name: Create issue for Python version update
70+
if: env.NEEDS_UPDATE == 'true'
71+
uses: actions/github-script@v7
72+
with:
73+
script: |
74+
const newVersions = JSON.parse(process.env.NEW_VERSIONS);
75+
76+
github.rest.issues.create({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
title: 'Python versions in CI workflow should be updated',
80+
body: `The Python versions in the CI workflow should be updated to the latest 3 stable versions:
81+
82+
**Recommended versions:** ${newVersions.join(', ')}
83+
84+
Please update the \`python-version\` matrix in \`.github/workflows/pythonapp.yml\`:
85+
86+
\`\`\`yaml
87+
strategy:
88+
matrix:
89+
python-version: [${newVersions.map(v => `"${v}"`).join(', ')}]
90+
\`\`\`
91+
92+
This issue was automatically created by the Update Python Versions workflow.`,
93+
labels: ['dependencies', 'python', 'ci']
94+
});
95+
96+
- name: Auto-update workflow (optional)
97+
if: env.NEEDS_UPDATE == 'true'
98+
run: |
99+
echo "Python versions need updating. Consider enabling auto-PR creation here."
100+
# Uncomment below to enable automatic PR creation
101+
# You would need to set up a personal access token with repo permissions
102+
103+
# git config --local user.email "action@github.com"
104+
# git config --local user.name "GitHub Action"
105+
# git checkout -b update-python-versions-$(date +%Y%m%d)
106+
#
107+
# # Update the workflow file
108+
# NEW_VERSIONS='${{ env.NEW_VERSIONS }}'
109+
# python -c "
110+
# import json
111+
# import re
112+
#
113+
# versions = json.loads('$NEW_VERSIONS')
114+
# version_str = '[' + ', '.join([f'\"${v}\"' for v in versions]) + ']'
115+
#
116+
# with open('.github/workflows/pythonapp.yml', 'r') as f:
117+
# content = f.read()
118+
#
119+
# # Replace the python-version matrix
120+
# pattern = r'python-version: \[.*?\]'
121+
# replacement = f'python-version: {version_str}'
122+
# content = re.sub(pattern, replacement, content)
123+
#
124+
# with open('.github/workflows/pythonapp.yml', 'w') as f:
125+
# f.write(content)
126+
# "
127+
#
128+
# git add .github/workflows/pythonapp.yml
129+
# git commit -m "Update Python versions to latest 3 stable versions"
130+
# git push origin update-python-versions-$(date +%Y%m%d)

0 commit comments

Comments
 (0)