Skip to content

Commit 42ef6ba

Browse files
ci: High risk file changes as PR comment (#3554)
Remove the no changes in high-risk file script and hashes, and replace it by adding a GH PR comment.
1 parent 26d116c commit 42ef6ba

File tree

6 files changed

+63
-46
lines changed

6 files changed

+63
-46
lines changed

.github/file-filters.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is used by the action https://github.com/dorny/paths-filter (which we have forked to https://github.com/getsentry/paths-filter)
2+
3+
high_risk_code: &high_risk_code
4+
- 'Sources/Sentry/SentryNSURLSessionTaskSearch.m'
5+
- 'Sources/Sentry/SentryNetworkTracker.m'
6+
- 'Sources/Sentry/SentryUIViewControllerSwizzling.m'
7+
- 'Sources/Sentry/SentryNSDataSwizzling.m'
8+
- 'Sources/Sentry/SentrySubClassFinder.m'
9+
- 'Sources/Sentry/SentryCoreDataSwizzling.m'
10+
- 'Sources/Sentry/SentrySwizzleWrapper.m'
11+
- 'Sources/Sentry/include/SentrySwizzle.h'
12+
- 'Sources/Sentry/SentrySwizzle.m'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Changes In High Risk Code
2+
on:
3+
pull_request:
4+
5+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
files-changed:
12+
name: Detect changed files
13+
runs-on: ubuntu-latest
14+
# Map a step output to a job output
15+
outputs:
16+
high_risk_code: ${{ steps.changes.outputs.high_risk_code }}
17+
high_risk_code_files: ${{ steps.changes.outputs.high_risk_code_files }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Get changed files
21+
id: changes
22+
uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
23+
with:
24+
token: ${{ github.token }}
25+
filters: .github/file-filters.yml
26+
27+
# Enable listing of files matching each filter.
28+
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
29+
list-files: csv
30+
31+
validate-high-risk-code:
32+
if: needs.files-changed.outputs.high_risk_code == 'true'
33+
needs: files-changed
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Comment on PR to notify of changes in high risk files
37+
uses: actions/github-script@v7
38+
env:
39+
high_risk_code: ${{ needs.files-changed.outputs.high_risk_code_files }}
40+
with:
41+
script: |
42+
const highRiskFiles = process.env.high_risk_code;
43+
const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n');
44+
github.rest.issues.createComment({
45+
issue_number: context.issue.number,
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: `### 🚨 Detected changes in high risk code 🚨 \n High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:\n ${fileList}`
49+
})
50+
51+

.github/workflows/lint.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- 'Samples/**'
1111
- '.github/workflows/lint.yml'
1212
- 'scripts/ci-select-xcode.sh'
13-
- 'scripts/no-changes-in-high-risk-files.sh'
1413

1514
pull_request:
1615
paths:
@@ -20,7 +19,6 @@ on:
2019
- 'Samples/**'
2120
- '.github/workflows/lint.yml'
2221
- 'scripts/ci-select-xcode.sh'
23-
- 'scripts/no-changes-in-high-risk-files.sh'
2422
- 'Sentry.xcodeproj/**'
2523
- '*.podspec'
2624

@@ -74,10 +72,3 @@ jobs:
7472
- run: pod repo update
7573
- name: Validate HybridPod Podspec
7674
run: pod lib lint ./Tests/HybridSDKTest/HybridPod.podspec --allow-warnings --verbose --platforms=ios "--include-podspecs={SentryPrivate.podspec,Sentry.podspec}"
77-
78-
validate-high-risk-files:
79-
name: No changes in high risk files
80-
runs-on: ubuntu-latest
81-
steps:
82-
- uses: actions/checkout@v4
83-
- run: ./scripts/no-changes-in-high-risk-files.sh

.pre-commit-config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,3 @@ repos:
4545
types_or: ["swift", "objective-c", "objective-c++", "c", "c++" ]
4646
args:
4747
- "lint"
48-
49-
- id: no-changes-in-high-risk-files
50-
name: No Changes in High Risk Files
51-
entry: make
52-
language: system
53-
types_or: ["swift","objective-c", "objective-c++", "c", "c++"]
54-
args:
55-
- "no-changes-in-high-risk-files"

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ lint:
1818
swiftlint --strict
1919
.PHONY: lint
2020

21-
no-changes-in-high-risk-files:
22-
@echo "--> Checking if there are changes in high risk files"
23-
./scripts/no-changes-in-high-risk-files.sh
24-
2521
format: format-clang format-swift
2622

2723
# Format ObjC, ObjC++, C, and C++

scripts/no-changes-in-high-risk-files.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)