Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
286 commits
Select commit Hold shift + click to select a range
2873c76
Merge branch 'master' into fixes/general
WayneWhitehead Mar 4, 2025
ca78e4f
Update composables-checks workflow for hardcoded values
WayneWhitehead Mar 4, 2025
388753a
Change error to warning for hardcoded values
WayneWhitehead Mar 4, 2025
198ae0e
Update GitHub API call in workflow file
WayneWhitehead Mar 4, 2025
a813627
Exclude 'const val' from grep results
WayneWhitehead Mar 4, 2025
5c0700d
Separate string and size warnings in workflow
WayneWhitehead Mar 4, 2025
048b0cb
Enhance warnings with file name and path
WayneWhitehead Mar 4, 2025
f3f4853
Update string lines grep command in workflow
WayneWhitehead Mar 4, 2025
84604d4
Exclude `@SerializedName` in string checks
WayneWhitehead Mar 4, 2025
0ef4088
Update composables-checks to check changed files
WayneWhitehead Mar 4, 2025
a8c7e52
Update composables-checks workflow to fetch all branches
WayneWhitehead Mar 4, 2025
c36dbf6
Update composables-checks workflow to fetch all branches
WayneWhitehead Mar 4, 2025
868aeb7
Update composables-checks workflow to fetch branches
WayneWhitehead Mar 4, 2025
8df79fb
Optimize file change detection in workflow
WayneWhitehead Mar 4, 2025
944c4ed
Merge pull request #4 from WayneWhitehead/WayneWhitehead-patch-1
WayneWhitehead Mar 4, 2025
fe8725a
Add workflows for composable and PR checks
WayneWhitehead Mar 4, 2025
750134c
Post warnings as review comments
WayneWhitehead Mar 4, 2025
e510bae
Update PR checks workflow with commit ID
WayneWhitehead Mar 4, 2025
d9d1ef2
Fix missing newline at end of file
WayneWhitehead Mar 4, 2025
50811e6
Fix missing newline at end of file
WayneWhitehead Mar 4, 2025
c6fa26b
Fix missing newline at end of file
WayneWhitehead Mar 4, 2025
12bbef7
Remove unused GitHub actions import
WayneWhitehead Mar 4, 2025
edec631
Update .github/workflows/pr-checks.yml
WayneWhitehead Mar 4, 2025
2edb48e
Fix string and size warnings parsing logic
WayneWhitehead Mar 4, 2025
020b50a
Reorder variable declarations in pr-checks.yml
WayneWhitehead Mar 4, 2025
2249d59
Consolidate warnings handling in PR checks workflow
WayneWhitehead Mar 4, 2025
74630ed
Refactor GitHub context import in workflow
WayneWhitehead Mar 4, 2025
4dc0bec
Remove redundant require statement in pr-checks.yml
WayneWhitehead Mar 4, 2025
488c7a4
Remove redundant require statement in pr-checks.yml
WayneWhitehead Mar 4, 2025
e79e5fd
Fix incorrect key 'position' to 'line' in YAML
WayneWhitehead Mar 4, 2025
c67bf29
Fix incorrect key 'position' to 'line' in YAML
WayneWhitehead Mar 4, 2025
988411f
Add HARDCODE constant to WeatherViewModel
WayneWhitehead Mar 4, 2025
e161cd9
Update PR checks workflow for hardcoded values
WayneWhitehead Mar 4, 2025
e4df130
Update fetch-depth and diff command in workflow
WayneWhitehead Mar 4, 2025
11fe7fe
Remove unused GitHub actions imports
WayneWhitehead Mar 4, 2025
64122e1
Update PR checks workflow for fetch-depth and warnings
WayneWhitehead Mar 4, 2025
f6b79c2
Enhance PR checks for hardcoded values
WayneWhitehead Mar 4, 2025
21342cd
Remove unused GitHub Actions imports
WayneWhitehead Mar 4, 2025
14fa4c7
Simplify hardcoded values check in PR workflow
WayneWhitehead Mar 4, 2025
0bc7276
Update PR checks workflow for hardcoded values
WayneWhitehead Mar 4, 2025
770f200
Enhance hardcoded values detection in PR checks
WayneWhitehead Mar 4, 2025
12a7104
Remove unused GitHub Actions imports
WayneWhitehead Mar 4, 2025
75f1e33
Simplify hardcoded values check in PR workflow
WayneWhitehead Mar 4, 2025
0188a01
Refactor PR checks workflow for hardcoded values
WayneWhitehead Mar 4, 2025
0f32a2c
Refactor PR checks workflow for clarity
WayneWhitehead Mar 4, 2025
d66f818
Add changed files check to PR workflow
WayneWhitehead Mar 4, 2025
690b4b9
Remove duplicate 'Get list of changed files' step
WayneWhitehead Mar 4, 2025
ebbd68b
Remove unused GitHub Actions imports
WayneWhitehead Mar 4, 2025
28bed04
Remove unused GitHub Actions imports
WayneWhitehead Mar 4, 2025
4309649
Add changed-files action to PR checks
WayneWhitehead Mar 4, 2025
77372a1
Improve hardcoded values detection and reporting
WayneWhitehead Mar 4, 2025
bd984d3
Encode warnings in base64 in PR checks
WayneWhitehead Mar 4, 2025
1084fa0
Encode warnings in base64 in PR checks
WayneWhitehead Mar 4, 2025
2ddcb86
Improve hardcoded value detection and reporting
WayneWhitehead Mar 4, 2025
ad3bdd2
Refactor hardcoded values detection and comments
WayneWhitehead Mar 4, 2025
6e66eeb
Refactor hardcoded values detection and comments
WayneWhitehead Mar 4, 2025
a2816a6
Simplify hardcoded values detection in PR checks
WayneWhitehead Mar 4, 2025
e0a48a3
Remove shell node declaration in workflow
WayneWhitehead Mar 4, 2025
f9f4d05
Update shell command in GitHub workflow
WayneWhitehead Mar 4, 2025
cc61841
Encode and decode DETAILS variable with base64
WayneWhitehead Mar 4, 2025
e4e9562
Update shell command in GitHub workflow
WayneWhitehead Mar 4, 2025
11669d0
Refactor PR checks to use details.txt
WayneWhitehead Mar 4, 2025
6f2a5a7
Update shell command in pr-checks.yml
WayneWhitehead Mar 4, 2025
a010dd3
Update PR checks workflow to use Node.js
WayneWhitehead Mar 4, 2025
f8469d0
Update shell command in pr-checks.yml
WayneWhitehead Mar 4, 2025
4ebfb51
Update shell to use bash in workflow
WayneWhitehead Mar 4, 2025
5d2decb
Update shell to use bash in workflow
WayneWhitehead Mar 4, 2025
3577ecf
Refactor PR checks workflow script
WayneWhitehead Mar 4, 2025
86e4799
Add condition to post warnings as comments
WayneWhitehead Mar 4, 2025
de9cc79
Refactor PR checks workflow script execution
WayneWhitehead Mar 4, 2025
8c0a3ec
Update shell command in GitHub Actions
WayneWhitehead Mar 4, 2025
1ee2c4a
Update shell command in GitHub Actions
WayneWhitehead Mar 4, 2025
8a306dd
Enhance PR checks workflow script
WayneWhitehead Mar 4, 2025
1a38bf2
Update shell command in pr-checks.yml
WayneWhitehead Mar 4, 2025
e8c79ed
Update shell command in pr-checks.yml
WayneWhitehead Mar 4, 2025
e3d2cdc
Update PR checks workflow script and comments
WayneWhitehead Mar 4, 2025
225cd37
Update shell command and remove unused imports
WayneWhitehead Mar 4, 2025
87517c0
Update PR checks workflow script and shell
WayneWhitehead Mar 4, 2025
ab66b40
Update shell command and remove unused imports
WayneWhitehead Mar 4, 2025
3810e43
Update PR checks workflow to post warnings
WayneWhitehead Mar 4, 2025
1460a07
Update shell command and remove unused imports
WayneWhitehead Mar 4, 2025
d19c98e
Fix hardcoded value detection in PR checks
WayneWhitehead Mar 4, 2025
0d6174c
Fix hardcoded value detection in PR checks
WayneWhitehead Mar 4, 2025
6a64023
Update shell command and remove unused imports
WayneWhitehead Mar 4, 2025
9d43109
Simplify hardcoded values check in PRs
WayneWhitehead Mar 4, 2025
3cee6bb
Fix line number extraction in PR checks
WayneWhitehead Mar 4, 2025
26a57c0
Fix line number extraction in PR checks
WayneWhitehead Mar 4, 2025
2d1f4ec
Remove unused require statements in pr-checks.yml
WayneWhitehead Mar 4, 2025
37c63f4
Update workflow to check for hardcoded values
WayneWhitehead Mar 4, 2025
e03c7a9
Remove hardcoded value and update PR checks
WayneWhitehead Mar 4, 2025
8272bbb
Remove unused variable declarations in workflow
WayneWhitehead Mar 4, 2025
c9ddd6d
Update ViewModel unit test workflow
WayneWhitehead Mar 4, 2025
3b41774
Update PR comment parameters in workflow
WayneWhitehead Mar 4, 2025
311b0b2
Add position tracking to PR checks script
WayneWhitehead Mar 4, 2025
bf29cc6
Remove unused variable declarations in workflow
WayneWhitehead Mar 4, 2025
1e672b5
Simplify PR comment logic in workflow
WayneWhitehead Mar 4, 2025
ed079e0
Remove unused variable declarations in workflow
WayneWhitehead Mar 4, 2025
df2c5a4
Avoid duplicate comments in PR checks
WayneWhitehead Mar 4, 2025
2fe59d3
Remove unused variable declarations in workflow
WayneWhitehead Mar 4, 2025
29b81b2
Update Android SDK to version 35
WayneWhitehead Mar 4, 2025
7ab6a11
Add Gradle 8.8.0 setup to workflow
WayneWhitehead Mar 4, 2025
271ab85
Remove Gradle setup from workflow file
WayneWhitehead Mar 4, 2025
155f442
Update Gradle command for unit tests
WayneWhitehead Mar 4, 2025
50b1709
Remove continue-on-error from workflow
WayneWhitehead Mar 6, 2025
0805f01
Enhance ViewModel test file validation
WayneWhitehead Mar 6, 2025
794471e
Add logging for modified ViewModel files
WayneWhitehead Mar 6, 2025
5a4432a
Add unit test, coverage report, and error comment steps
WayneWhitehead Mar 6, 2025
9d7d146
Update Android SDK setup and fetch command
WayneWhitehead Mar 6, 2025
40b06da
Fix syntax for fetching modified ViewModel files
WayneWhitehead Mar 6, 2025
a196229
Fix ViewModel file fetching in workflow
WayneWhitehead Mar 6, 2025
f73c8a8
Update Android SDK setup and fetch modified files
WayneWhitehead Mar 6, 2025
e99f046
Update Android SDK setup components
WayneWhitehead Mar 6, 2025
75bb389
Update GitHub Actions workflow for viewmodel tests
WayneWhitehead Mar 6, 2025
c5f5af6
Update viewmodel unit tests workflow configuration
WayneWhitehead Mar 6, 2025
ee0a315
Update viewmodel-unit-tests workflow configuration
WayneWhitehead Mar 6, 2025
b79ef09
Improve missing test files check
WayneWhitehead Mar 6, 2025
a7709a2
Update GitHub Actions workflow versions and conditions
WayneWhitehead Mar 6, 2025
ca26238
Update condition for running unit tests
WayneWhitehead Mar 6, 2025
36a8b2a
Fix JDK setup and unit test condition
WayneWhitehead Mar 6, 2025
d02a196
Remove Gradle dependencies caching step
WayneWhitehead Mar 6, 2025
d5c84a3
Update viewmodel-unit-tests workflow configuration
WayneWhitehead Mar 6, 2025
48679f5
Remove 'edited' type from pull_request trigger
WayneWhitehead Mar 6, 2025
5647b05
Update conditions and formatting in workflow file
WayneWhitehead Mar 6, 2025
7c44e13
Add initialization for TEST_FILES variable
WayneWhitehead Mar 6, 2025
767399e
Add error comment if test files missing
WayneWhitehead Mar 6, 2025
41bfb58
Refactor test file existence check logic
WayneWhitehead Mar 6, 2025
435028f
Remove unused GitHub import in workflow
WayneWhitehead Mar 6, 2025
71594fd
Remove unused core module import
WayneWhitehead Mar 6, 2025
d4b1c54
Refactor GitHub Actions script for test files
WayneWhitehead Mar 6, 2025
08d7aad
Fix coverage report output in workflow
WayneWhitehead Mar 6, 2025
6551601
Fix syntax error in viewmodel-unit-tests.yml
WayneWhitehead Mar 6, 2025
9cfd222
Remove unused environment variables in workflow
WayneWhitehead Mar 6, 2025
1abc275
Add condition to generate and verify coverage
WayneWhitehead Mar 6, 2025
f14e06d
Add logging for modified ViewModel files
WayneWhitehead Mar 6, 2025
6c88e26
Add logging for checking test files
WayneWhitehead Mar 6, 2025
4665a97
Update test file path generation logic
WayneWhitehead Mar 6, 2025
315e51a
Refactor test file search logic
WayneWhitehead Mar 6, 2025
bfb8fbc
Refactor test file search logic
WayneWhitehead Mar 6, 2025
898e76e
Refactor test file existence check logic
WayneWhitehead Mar 6, 2025
22ba875
Refactor test file search logic
WayneWhitehead Mar 6, 2025
6790fcb
Refactor test file search function
WayneWhitehead Mar 6, 2025
4dc5e1c
Fix test file search paths in workflow
WayneWhitehead Mar 6, 2025
61c394e
Enhance test file search patterns
WayneWhitehead Mar 6, 2025
abee799
Fix ViewModel test file path and patterns
WayneWhitehead Mar 6, 2025
075d3ac
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
38fba60
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
740da9a
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
370ed47
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
424348d
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
64d6ee6
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
e83e525
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
04d3ade
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
95ad181
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
aa3f1b5
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
b091320
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
2bc71aa
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
6698aae
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
24d2701
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
efa19fe
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
00d783f
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
35551f2
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
e2ed86b
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
61dc24e
Updated Gradle for Tests
WayneWhitehead Mar 6, 2025
3751fd4
Update test report path in workflow
WayneWhitehead Mar 11, 2025
b871984
Update coverage report and post comment
WayneWhitehead Mar 11, 2025
a273a68
Add step to log coverage report content
WayneWhitehead Mar 11, 2025
e5fcb8b
Enhance test report extraction and comments
WayneWhitehead Mar 11, 2025
675499f
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
c65894b
Update ViewModel unit test workflows
WayneWhitehead Mar 12, 2025
648b7d8
Add ViewModel unit tests and coverage reporting
WayneWhitehead Mar 12, 2025
fad718f
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
50ec5d8
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
3f43a7f
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
3595a74
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
f3dddfa
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
3ac4ec4
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
6aea5f7
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
3e8c066
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
7f89540
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
a3b44ed
Updated Gradle for Tests
WayneWhitehead Mar 12, 2025
0a2f6f5
Updated Tests for Models
WayneWhitehead Mar 12, 2025
4cf0293
Updated Tests for Models
WayneWhitehead Mar 12, 2025
1594f51
Updated Tests for Models
WayneWhitehead Mar 12, 2025
270fc36
Updated Tests for Models
WayneWhitehead Mar 13, 2025
78b15e1
Updated Tests for Models
WayneWhitehead Mar 13, 2025
87ff385
Updated Tests for Models
WayneWhitehead Mar 13, 2025
ad83b95
Updated Workflow 1
WayneWhitehead Mar 13, 2025
6a465bc
Updated Workflow 1
WayneWhitehead Mar 13, 2025
3875b28
Updated Workflow 2
WayneWhitehead Mar 13, 2025
70cadea
Updated Workflow 2
WayneWhitehead Mar 13, 2025
444e3fd
Updated Workflow 3
WayneWhitehead Mar 13, 2025
9a3a4c4
Updated Workflow 4
WayneWhitehead Mar 13, 2025
af2894e
Updated Workflow 4
WayneWhitehead Mar 13, 2025
97a9802
Updated Workflow 5
WayneWhitehead Mar 13, 2025
840e0c2
Updated Workflow 5
WayneWhitehead Mar 13, 2025
28930cf
Updated Workflow 6
WayneWhitehead Mar 13, 2025
18a5778
Updated Workflow 7
WayneWhitehead Mar 13, 2025
8616322
Updated Workflow 8
WayneWhitehead Mar 13, 2025
29b3131
Updated Workflow 9
WayneWhitehead Mar 13, 2025
86be469
Updated Workflow 10
WayneWhitehead Mar 13, 2025
2480d30
Updated Workflow 11
WayneWhitehead Mar 13, 2025
09edebe
Updated Workflow 12
WayneWhitehead Mar 13, 2025
5552b7b
Updated Workflow 14
WayneWhitehead Mar 13, 2025
494ad5b
Updated Workflow 14
WayneWhitehead Mar 13, 2025
3b0a86d
Updated Workflow 16
WayneWhitehead Mar 13, 2025
d85a273
Updated Workflow 16
WayneWhitehead Mar 13, 2025
0ffb7bd
Updated Workflow 17
WayneWhitehead Mar 13, 2025
3694ee6
Updated Workflow 18
WayneWhitehead Mar 13, 2025
d29332b
Updated Workflow 18
WayneWhitehead Mar 13, 2025
20823bc
Updated Workflow 18
WayneWhitehead Mar 13, 2025
d9eae29
Updated Workflow 19
WayneWhitehead Mar 13, 2025
f1b3409
Updated Workflow 21
WayneWhitehead Mar 13, 2025
d38f6fc
Updated Workflow 21
WayneWhitehead Mar 13, 2025
c5a350b
Updated Workflow 22
WayneWhitehead Mar 13, 2025
ffb7099
Updated Workflow 23
WayneWhitehead Mar 13, 2025
58ce8cf
Updated Workflow 24
WayneWhitehead Mar 13, 2025
6b1b958
Updated Workflow 25
WayneWhitehead Mar 13, 2025
6d44e31
Updated Workflow 26
WayneWhitehead Mar 13, 2025
b4ec02b
Updated Workflow 26
WayneWhitehead Mar 13, 2025
346567d
Updated Workflow 27
WayneWhitehead Mar 13, 2025
0cc17ef
Updated Workflow 28
WayneWhitehead Mar 13, 2025
1ec4557
Updated Workflow 29
WayneWhitehead Mar 13, 2025
63e947f
Updated Workflow 30
WayneWhitehead Mar 13, 2025
bb1ec75
Updated Workflow 31
WayneWhitehead Mar 13, 2025
8740e46
Updated Workflow 32
WayneWhitehead Mar 13, 2025
8fe9a79
Updated Workflow 33
WayneWhitehead Mar 13, 2025
da5359a
Updated Workflow 34
WayneWhitehead Mar 13, 2025
a992070
Updated Workflow 35
WayneWhitehead Mar 13, 2025
3bf9300
Updated Workflow 36
WayneWhitehead Mar 13, 2025
0fc8c69
Updated Workflow 37
WayneWhitehead Mar 18, 2025
2e8efa8
Updated Workflow 38
WayneWhitehead Mar 18, 2025
c4289ef
Updated Workflow 39
WayneWhitehead Mar 18, 2025
1205c13
Updated Workflow 40
WayneWhitehead Mar 20, 2025
29346f7
Updated Workflow 41
WayneWhitehead Mar 20, 2025
65fbdf0
Updated Workflow 42
WayneWhitehead Mar 20, 2025
0d86ae5
Updated Workflow 43
WayneWhitehead Mar 20, 2025
0a7fc6b
Updated Workflow 44
WayneWhitehead Mar 20, 2025
ec098c7
Updated Workflow 45
WayneWhitehead Mar 20, 2025
c0405bf
Updated Workflow 46
WayneWhitehead Mar 20, 2025
bee2ef3
Updated Workflow 47
WayneWhitehead Mar 20, 2025
1212aea
Updated Workflow 48
WayneWhitehead Mar 20, 2025
ac6fc57
Updated Workflow 49
WayneWhitehead Mar 20, 2025
f45e6a1
Updated Workflow 50
WayneWhitehead Mar 20, 2025
2497395
Updated Workflow 51
WayneWhitehead Mar 20, 2025
554a2c3
Updated Workflow 52
WayneWhitehead Mar 20, 2025
a65d353
Updated Workflow 54
WayneWhitehead Mar 20, 2025
0a3764c
Updated Workflow 56
WayneWhitehead Mar 20, 2025
792bfa0
Updated Workflow 56
WayneWhitehead Mar 20, 2025
fa2d58b
Updated Workflow 57
WayneWhitehead Mar 29, 2025
260127f
Updated Workflow 58
WayneWhitehead Mar 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: PR Checks

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
update-pr-details:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Update PR Title and Labels
uses: actions/github-script@v5
with:
script: |
const branchName = context.payload.pull_request.head.ref;
const baseBranchName = context.payload.pull_request.base.ref;
const prNumber = context.payload.pull_request.number;
let prTitle = context.payload.pull_request.title;

let newTitle = prTitle;
let label = '';

if (branchName.startsWith('feature/')) {
if (!prTitle.startsWith('✨')) {
newTitle = `✨ ${prTitle}`;
}
label = 'Feature';
} else if (branchName.startsWith('fixes/')) {
if (!prTitle.startsWith('🐞')) {
newTitle = `🐞 ${prTitle}`;
}
label = 'Bugfix';
} else if (branchName.startsWith('hotfix/')) {
if (!prTitle.startsWith('🚑')) {
newTitle = `🚑 ${prTitle}`;
}
label = 'Hotfix';
} else if (branchName.startsWith('refactor/')) {
if (!prTitle.startsWith('🔧')) {
newTitle = `🔧 ${prTitle}`;
}
label = 'Refactor';
} else if (branchName.startsWith('release/')) {
newTitle = `${branchName} ➡️ ${baseBranchName}`;
label = 'Release';
}

if (newTitle !== prTitle) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
title: newTitle
});
}

if (label) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: [label]
});
}

check-hardcoded-values:
runs-on: ubuntu-latest
needs: update-pr-details
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find and comment on hardcoded values
uses: actions/github-script@v5
with:
script: |
// Get the list of changed files
const changedFiles = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});

// Get existing comments
const existingComments = await github.rest.pulls.listReviewComments({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});

for (const file of changedFiles.data) {
if (file.filename.endsWith('.kt') && !file.filename.endsWith('Test.kt')) {
// Get the diff of the changed file
const diffLines = file.patch.split('\n').filter(line => line.startsWith('+') && !line.startsWith('++'));

let lineNumber = 0;
for (const line of file.patch.split('\n')) {
if (line.startsWith('@@')) {
// Extract the starting line number from the diff hunk header
const match = line.match(/@@ \-(\d+),\d+ \+(\d+),\d+ @@/);
if (match) {
lineNumber = parseInt(match[2]) - 1;
}
} else if (line.startsWith('+')) {
lineNumber++;
if (line.match(/"[^"]*"|[0-9]+\.dp/) && !line.includes('const val') && !line.includes('@SerializedName')) {
const message = `Hardcoded string found on line ${lineNumber}`;

console.log(`File: ${file.filename}`);
console.log(`Line Number: ${lineNumber}`);
console.log(`Message: ${message}`);

// Check if there's already an unresolved comment from github-actions[bot] on this line
const existingComment = existingComments.data.find(comment =>
comment.path === file.filename && comment.line === lineNumber && comment.user.login === 'github-actions[bot]' && comment.position !== null
);

if (!existingComment) {
// Post a comment on the pull request
await github.rest.pulls.createReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
body: message,
commit_id: context.payload.pull_request.head.sha,
path: file.filename,
line: lineNumber,
side: 'RIGHT'
});
} else {
console.log(`Unresolved comment already exists from github-actions[bot] on ${file.filename} at line ${lineNumber}`);
}
}
} else if (!line.startsWith('-')) {
lineNumber++;
}
}
}
}
Loading