8000 fix: Updated GitHub Action to relay only on GitHub native approvals t… · awsarron/sdk-python@43aad3c · GitHub
[go: up one dir, main page]

Skip to content

Commit 43aad3c

Browse files
authored
fix: Updated GitHub Action to relay only on GitHub native approvals to run workflows (strands-agents#67)
1 parent 5572438 commit 43aad3c

File tree

1 file changed

+15
-57
lines changed

1 file changed

+15
-57
lines changed

.github/workflows/test-lint-pr.yml

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,49 @@ on:
66
types: [opened, synchronize, reopened, ready_for_review, review_requested, review_request_removed]
77
push:
88
branches: [ main ] # Also run on direct pushes to main
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
912

1013
jobs:
11-
check-approval:
12-
name: Check if PR has contributor approval
13-
runs-on: ubuntu-latest
14-
permissions:
15-
pull-requests: read
16-
# Skip this check for direct pushes to main
17-
if: github.event_name == 'pull_request'
18-
outputs:
19-
approved: ${{ steps.check-approval.outputs.approved }}
20-
steps:
21-
- name: Check if PR has been approved by a contributor
22-
id: check-approval
23-
uses: actions/github-script@v7
24-
with:
25-
script: |
26-
const APPROVED_ASSOCIATION = ['COLLABORATOR', 'CONTRIBUTOR', 'MEMBER', 'OWNER']
27-
const PR_AUTHOR_ASSOCIATION = context.payload.pull_request.author_association;
28-
const { data: reviews } = await github.rest.pulls.listReviews({
29-
owner: context.repo.owner,
30-
repo: context.repo.repo,
31-
pull_number: context.issue.number,
32-
});
33-
34-
const isApprovedContributor = APPROVED_ASSOCIATION.includes(PR_AUTHOR_ASSOCIATION);
35-
36-
// Check if any contributor has approved
37-
const isApproved = reviews.some(review =>
38-
review.state === 'APPROVED' && APPROVED_ASSOCIATION.includes(review.author_association)
39-
) || isApprovedContributor;
40-
41-
core.setOutput('approved', isApproved);
42-
43-
if (!isApproved) {
44-
core.notice('This PR does not have approval from a Contributor. Workflow will not run test jobs.');
45-
return false;
46-
}
47-
48-
return true;
49-
5014
unit-test:
5115
name: Unit Tests - Python ${{ matrix.python-version }} - ${{ matrix.os-name }}
52-
needs: check-approval
5316
permissions:
5417
contents: read
55-
# Only run if PR is approved or this is a direct push to main
56-
if: github.event_name == 'push' || needs.check-approval.outputs.approved == 'true'
5718
strategy:
5819
matrix:
5920
include:
6021
# Linux
6122
- os: ubuntu-latest
62-
os-name: linux
23+
os-name: 'linux'
6324
python-version: "3.10"
6425
- os: ubuntu-latest
65-
os-name: linux
26+
os-name: 'linux'
6627
python-version: "3.11"
6728
- os: ubuntu-latest
68-
os-name: linux
29+
os-name: 'linux'
6930
python-version: "3.12"
7031
- os: ubuntu-latest
71-
os-name: linux
32+
os-name: 'linux'
7233
python-version: "3.13"
7334
# Windows
7435
- os: windows-latest
75-
os-name: windows
36+
os-name: 'windows'
7637
python-version: "3.10"
7738
- os: windows-latest
78-
os-name: windows
39+
os-name: 'windows'
7940
python-version: "3.11"
8041
- os: windows-latest
81-
os-name: windows
42+
os-name: 'windows'
8243
python-version: "3.12"
8344
- os: windows-latest
84-
os-name: windows
45+
os-name: 'windows'
8546
python-version: "3.13"
86-
# MacOS - latest only; not enough runners for MacOS
47+
# MacOS - latest only; not enough runners for macOS
8748
- os: macos-latest
88-
os-name: macos
89-
python-version: "3.13"
90-
fail-fast: false
49+
os-name: 'macOS'
50+
python-version: "3.13"
51+
fail-fast: true
9152
runs-on: ${{ matrix.os }}
9253
env:
9354
LOG_LEVEL: DEBUG
@@ -108,14 +69,11 @@ jobs:
10869
id: tests
10970
run: hatch test tests --cover
11071
continue-on-error: false
111-
11272
lint:
11373
name: Lint
11474
runs-on: ubuntu-latest
115-
needs: check-approval
11675
permissions:
11776
contents: read
118-
if: github.event_name == 'push' || needs.check-approval.outputs.approved == 'true'
11977
steps:
12078
- name: Checkout code
12179
uses: actions/checkout@v4

0 commit comments

Comments
 (0)
0