-
Notifications
You must be signed in to change notification settings - Fork 562
feat: Add action to run toxgen periodically #4805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
79f5692
feat: Add action to run toxgen periodically
sentrivana 995066c
improvements
sentrivana 31428f9
.
sentrivana 97ea092
.
sentrivana 740d9b7
Merge branch 'master' into ivana/toxgen/auto-pr
sentrivana 04be05d
.
sentrivana f922f37
.
sentrivana 297a85b
idk
sentrivana 0b84d0c
.
sentrivana 56b0c27
.
sentrivana f1733d4
Apply suggestions from code review
sentrivana 09a611f
also link to tox.ini
sentrivana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: Update test matrix | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# early Monday morning | ||
- cron: '23 3 * * 1' | ||
|
||
jobs: | ||
update-tox: | ||
name: Update test matrix | ||
runs-on: ubuntu-latest | ||
szokeasaurusrex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
timeout-minutes: 10 | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.13 | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v5.0.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.name 'github-actions[bot]' | ||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
|
||
- name: Run generate-test-files.sh | ||
run: | | ||
set -e | ||
sh scripts/generate-test-files.sh | ||
|
||
- name: Create branch | ||
id: create-branch | ||
run: | | ||
COMMIT_TITLE="ci: 🤖 Update test matrix with new releases" | ||
DATE=`date +%m/%d` | ||
BRANCH_NAME="toxgen/update" | ||
|
||
git checkout -B "$BRANCH_NAME" | ||
git add --all | ||
git commit -m "$COMMIT_TITLE" | ||
git push origin "$BRANCH_NAME" --force | ||
sentrivana marked this conversation as resolved.
Show resolved
Hide resolved
sentrivana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
echo "commit_title=$COMMIT_TITLE" >> $GITHUB_OUTPUT | ||
echo "date=$DATE" >> $GITHUB_OUTPUT | ||
|
||
- name: Create pull request | ||
uses: actions/github-script@v8.0.0 | ||
with: | ||
script: | | ||
const branchName = '${{ steps.create-branch.outputs.branch_name }}'; | ||
const commitTitle = '${{ steps.create-branch.outputs.commit_title }}'; | ||
const date = '${{ steps.create-branch.outputs.date }}'; | ||
const prBody = `Update our test matrix with new releases of integrated frameworks and libraries. | ||
|
||
## How it works | ||
- Scan PyPI for all supported releases of all frameworks we have a dedicated test suite for. | ||
- Pick a representative sample of releases to run our test suite against. We always test the latest and oldest supported version. | ||
- Update [tox.ini](tox.ini) with the new releases. | ||
|
||
## Action required | ||
- If CI passes on this PR, it's safe to approve and merge. It means our integrations can handle new versions of frameworks that got pulled in. | ||
- If CI doesn't pass on this PR, this points to an incompatibility of either our integration or our test setup with a new version of a framework. | ||
- Check what the failures look like and either fix them, or update the [test config](scripts/populate_tox/config.py) and rerun [scripts/generate-test-files.sh](scripts/generate-test-files.sh). See [README.md](scripts/populate_tox/README.md) for what configuration options are available. | ||
|
||
_____________________ | ||
|
||
_🤖 This PR was automatically created using [a GitHub action](.github/workflows/update-tox.yml)._`.replace(/^ {16}/gm, '') | ||
|
||
// Close existing toxgen PRs as they're now obsolete | ||
|
||
const { data: existingPRs } = await github.rest.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
head: `${context.repo.owner}:${branchName}`, | ||
state: 'open' | ||
}); | ||
|
||
for (const pr of existingPRs) { | ||
await github.rest.pulls.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pr.number, | ||
state: 'closed' | ||
}) | ||
}; | ||
sentrivana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { data: pr } = await github.rest.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: commitTitle + ' (' + date + ')', | ||
head: branchName, | ||
base: '${{ github.ref_name }}', | ||
body: prBody, | ||
}); | ||
|
||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: pr.number, | ||
labels: ['Component: CI', 'Component: Tests'] | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exactly at 03:23 UTC? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason for this specific time, the important part is just that it's not at :00 -- usually it's good practice to set crons to run at a different time than the start of the hour since that's when most cron jobs are running and yours might be delayed or even dropped. See also here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh – perhaps I should change the time I am using in Sentry CLI then