Skip to content

Commit 9bf1d27

Browse files
authored
Remove usage of pull_request_target everywhere (#878)
* Remove usage of GH workflows everywhere * Add SSL testing
1 parent 538182a commit 9bf1d27

3 files changed

Lines changed: 37 additions & 74 deletions

File tree

.github/workflows/checkNextChangelog.yml

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Check for NEXT_CHANGELOG.md Changes
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
branches: [ main ]
66

77
permissions:
88
contents: read
9-
pull-requests: write
109

1110
jobs:
1211
check-next-changelog:
@@ -67,47 +66,8 @@ jobs:
6766
echo "NO_CHANGELOG=true found in PR message. Skipping changelog check."
6867
exit 0
6968
else
70-
echo "WARNING: file NEXT_CHANGELOG.md not changed. If this is expected, add NO_CHANGELOG=true to the PR message."
69+
echo "ERROR: NEXT_CHANGELOG.md not changed and NO_CHANGELOG=true not found in PR message."
70+
echo "Please update NEXT_CHANGELOG.md or add NO_CHANGELOG=true to the PR description."
7171
exit 1
7272
fi
73-
fi
74-
75-
- name: Comment on PR with instructions if needed
76-
if: failure() # This step will only run if the previous step fails (i.e., if NEXT_CHANGELOG.md was not modified and NO_CHANGELOG=true was not in the PR message)
77-
env:
78-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
run: |
80-
# Check if a comment exists with the instructions
81-
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
82-
--jq '.[] | select(.body | startswith("<!-- NEXT_CHANGELOG_INSTRUCTIONS -->")) | .id')
83-
echo "Previous comment IDs: $previous_comment_ids"
84-
85-
# If no previous comment exists, add one with instructions
86-
if [ -z "$previous_comment_ids" ]; then
87-
echo "Adding instructions comment."
88-
gh pr comment ${{ github.event.pull_request.number }} --body \
89-
"<!-- NEXT_CHANGELOG_INSTRUCTIONS -->
90-
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
91-
If this is not necessary for your PR, please include the following in your PR description:
92-
NO_CHANGELOG=true
93-
and rerun the job."
94-
fi
95-
96-
- name: Delete instructions comment on success
97-
if: success() # This step will only run if the previous check passed (i.e., if NEXT_CHANGELOG.md was modified or NO_CHANGELOG=true is in the PR message)
98-
env:
99-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100-
run: |
101-
# Check if there is a previous instructions comment
102-
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
103-
--jq '.[] | select(.body | startswith("<!-- NEXT_CHANGELOG_INSTRUCTIONS -->")) | .id')
104-
105-
# If a comment exists, delete it
106-
if [ -n "$previous_comment_ids" ]; then
107-
echo "Deleting previous instructions comment."
108-
for comment_id in $previous_comment_ids; do
109-
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" --method DELETE
110-
done
111-
else
112-
echo "No instructions comment found to delete."
113-
fi
73+
fi

.github/workflows/coverageReport.yml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ name: Code Coverage
22

33
permissions:
44
contents: read
5-
pull-requests: write
6-
issues: write
75

86
on:
9-
pull_request_target:
7+
pull_request:
108

119
jobs:
1210
coverage:
@@ -52,34 +50,38 @@ jobs:
5250
echo "No coverage override found"
5351
fi
5452
55-
- name: Add coverage to PR (with strict checks)
53+
- name: Check coverage percentage
5654
if: steps.override.outputs.override == 'false'
57-
id: jacoco
58-
uses: madrapps/jacoco-report@v1.7.2
59-
with:
60-
paths: |
61-
${{ github.workspace }}/target/site/jacoco/jacoco.xml
62-
token: ${{ secrets.GITHUB_TOKEN }}
63-
min-coverage-overall: 85
64-
title: '📊 Code Coverage Report'
65-
update-comment: true
66-
pass-emoji: ':green_circle:'
67-
fail-emoji: ':red_circle:'
55+
run: |
56+
COVERAGE_FILE="target/site/jacoco/jacoco.xml"
57+
if [ ! -f "$COVERAGE_FILE" ]; then
58+
echo "ERROR: Coverage file not found at $COVERAGE_FILE"
59+
exit 1
60+
fi
6861
69-
- name: Add coverage to PR (with override)
70-
if: steps.override.outputs.override == 'true'
71-
id: jacoco-override
72-
uses: madrapps/jacoco-report@v1.7.2
73-
with:
74-
paths: |
75-
${{ github.workspace }}/target/site/jacoco/jacoco.xml
76-
token: ${{ secrets.GITHUB_TOKEN }}
77-
min-coverage-overall: 85
78-
min-coverage-changed-files: 0
79-
title: '📊 Code Coverage Report (SKIPPED: ${{ steps.override.outputs.reason }})'
80-
update-comment: true
81-
pass-emoji: ':green_circle:'
82-
fail-emoji: ':red_circle:'
62+
# Install xmllint if not available
63+
if ! command -v xmllint &> /dev/null; then
64+
sudo apt-get update && sudo apt-get install -y libxml2-utils
65+
fi
66+
67+
COVERED=$(xmllint --xpath "string(//report/counter[@type='INSTRUCTION']/@covered)" "$COVERAGE_FILE")
68+
MISSED=$(xmllint --xpath "string(//report/counter[@type='INSTRUCTION']/@missed)" "$COVERAGE_FILE")
69+
TOTAL=$((COVERED + MISSED))
70+
71+
# Use Python for floating-point math
72+
PERCENTAGE=$(python3 -c "covered=${COVERED}; total=${TOTAL}; print(round((covered/total)*100, 2))")
73+
74+
echo "Branch Coverage: $PERCENTAGE%"
75+
echo "Required Coverage: 85%"
76+
77+
# Use Python to compare the coverage with 85
78+
python3 -c "import sys; sys.exit(0 if float('$PERCENTAGE') >= 85 else 1)"
79+
if [ $? -eq 1 ]; then
80+
echo "ERROR: Coverage is $PERCENTAGE%, which is less than the required 85%"
81+
exit 1
82+
else
83+
echo "SUCCESS: Coverage is $PERCENTAGE%, which meets the required 85%"
84+
fi
8385
8486
- name: Coverage enforcement summary
8587
run: |

.github/workflows/sslTesting.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
name: SSL Certificate Validation Test with Squid Proxy
2121

2222
on:
23+
push:
24+
branches: [ main ]
2325
workflow_dispatch:
2426
inputs:
2527
branch:
@@ -30,7 +32,6 @@ on:
3032
description: 'Repository to checkout (e.g., user/repo)'
3133
required: false
3234
default: 'databricks/databricks-jdbc'
33-
pull_request_target:
3435

3536
jobs:
3637
ssl-test:

0 commit comments

Comments
 (0)