Skip to content

Commit 97cd1ad

Browse files
Merge branch 'main' into dependabot/pip/jsonpickle-approx-eq-4.0.2
2 parents cb9052e + 8a761c7 commit 97cd1ad

75 files changed

Lines changed: 5485 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Dependabot Notifications
2+
3+
on:
4+
workflow_run:
5+
workflows: ["*"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
notify-checks:
11+
runs-on: ubuntu-latest
12+
if: github.actor == 'dependabot[bot]'
13+
steps:
14+
- name: Get PR Information
15+
if: github.actor == 'dependabot[bot]'
16+
id: get-pr-info
17+
uses: actions/github-script@v6
18+
with:
19+
script: |
20+
const { owner, repo } = context.repo;
21+
const run = context.payload.workflow_run;
22+
23+
// Get PR directly from the workflow run's head SHA
24+
const response = await github.rest.repos.listPullRequestsAssociatedWithCommit({
25+
owner,
26+
repo,
27+
commit_sha: run.head_sha
28+
});
29+
30+
const pr = response.data[0]; // Get the first associated PR
31+
32+
if (pr) {
33+
core.exportVariable('PR_TITLE', pr.title);
34+
core.exportVariable('PR_AUTHOR', pr.user.login);
35+
core.exportVariable('PR_LINK', pr.html_url);
36+
core.exportVariable('PR_NUMBER', pr.number.toString());
37+
} else {
38+
core.exportVariable('PR_TITLE', 'Unknown');
39+
core.exportVariable('PR_AUTHOR', context.actor);
40+
core.exportVariable('PR_LINK', `https://github.com/${owner}/${repo}/pulls`);
41+
core.exportVariable('PR_NUMBER', '');
42+
}
43+
44+
// Get check runs for this commit
45+
const checkRuns = await github.rest.checks.listForRef({
46+
owner,
47+
repo,
48+
ref: run.head_sha
49+
});
50+
51+
// Count different check conclusions
52+
const stats = checkRuns.data.check_runs.reduce((acc, check) => {
53+
acc[check.conclusion] = (acc[check.conclusion] || 0) + 1;
54+
return acc;
55+
}, {});
56+
57+
// Create status summary
58+
const summary = Object.entries(stats)
59+
.map(([status, count]) => `${count} ${status}`)
60+
.join(', ');
61+
62+
core.exportVariable('CHECKS_SUMMARY', summary);
63+
64+
// Determine overall status
65+
const hasFailures = stats.failure > 0;
66+
const hasSuccess = stats.success > 0;
67+
const hasCancelled = stats.cancelled > 0;
68+
69+
let overallStatus;
70+
if (hasFailures) {
71+
overallStatus = 'failure';
72+
} else if (hasCancelled && !hasSuccess) {
73+
overallStatus = 'cancelled';
74+
} else if (hasSuccess) {
75+
overallStatus = 'success';
76+
} else {
77+
overallStatus = 'unknown';
78+
}
79+
80+
// Only set status if this is the last workflow to complete
81+
const incompleteRuns = await github.rest.actions.listWorkflowRunsForRepo({
82+
owner,
83+
repo,
84+
head_sha: run.head_sha,
85+
status: 'in_progress'
86+
});
87+
88+
if (incompleteRuns.data.total_count === 0) {
89+
core.exportVariable('ALL_CHECKS_STATUS', overallStatus);
90+
core.exportVariable('SHOULD_NOTIFY', 'true');
91+
92+
// If checks failed and PR exists, close it
93+
if ((overallStatus === 'failure' || overallStatus === 'cancelled') && pr) {
94+
await github.rest.pulls.update({
95+
owner,
96+
repo,
97+
pull_number: pr.number,
98+
state: 'closed'
99+
});
100+
101+
// Add comment explaining why PR was closed
102+
await github.rest.issues.createComment({
103+
owner,
104+
repo,
105+
issue_number: pr.number,
106+
body: `This PR was automatically closed because some checks failed.\nStatus Summary: ${summary}`
107+
});
108+
}
109+
} else {
110+
core.exportVariable('SHOULD_NOTIFY', 'false');
111+
}
112+
113+
- name: Send Slack Notification for Success
114+
if: env.SHOULD_NOTIFY == 'true' && env.ALL_CHECKS_STATUS == 'success' && github.actor == 'dependabot[bot]'
115+
id: slack
116+
uses: slackapi/slack-github-action@v1.25.0
117+
with:
118+
channel-id: 'C08TLGVQ6V8'
119+
slack-message: |
120+
Repository: ${{ github.repository }}
121+
Title: ${{ env.PR_TITLE }}
122+
Author: ${{ env.PR_AUTHOR }}
123+
Link: ${{ env.PR_LINK }}
124+
Status Summary: ${{ env.CHECKS_SUMMARY }}
125+
env:
126+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
3131
- name: Publish distribution to PyPI
3232
id: release
33-
uses: pypa/gh-action-pypi-publish@v1.5.1
33+
uses: pypa/gh-action-pypi-publish@v1.13.0
3434
with:
3535
password: ${{ secrets.PYPI_TOKEN }}
3636

.github/workflows/test-runner.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-22.04]
19-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
19+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2020
steps:
2121
- uses: actions/checkout@v3
2222
- name: Setup Python
@@ -32,11 +32,10 @@ jobs:
3232
run: coverage run -m pytest
3333
- name: Generate coverage report
3434
run: coverage xml
35-
- name: Upload coverage report
36-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python == '3.13' && github.actor != 'dependabot[bot]' }}
37-
uses: paambaati/codeclimate-action@v3.0.0
35+
36+
- name: SonarQube Scan
37+
if: ${{ matrix.python == '3.13' && github.actor != 'dependabot[bot]' }}
38+
uses: SonarSource/sonarqube-scan-action@v6.0.0
3839
env:
39-
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_TEST_REPORTER_ID }}
40-
with:
41-
coverageLocations: |
42-
${{github.workspace}}/coverage.xml:coverage.py
40+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,6 @@ cython_debug/
160160
.idea/
161161

162162
# Visual Studio Code
163-
.vscode/
163+
.vscode/
164+
.qodo
165+
*~

0 commit comments

Comments
 (0)