Skip to content

Commit 09546cb

Browse files
author
Roman Glushko
committed
#184 Checking another way of getting PR changelog - via an external github action
1 parent b35818d commit 09546cb

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

.github/workflows/gradle.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ jobs:
2424
run: chmod +x gradlew
2525
# - name: Run automated tests
2626
# run: ./gradlew test -i
27-
- name: Pull Base Branch
28-
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
27+
- uses: trilom/[email protected]
28+
- name: Run Code Style Check
29+
run: |
30+
echo 'Modified Files: ${{ steps.file_changes.outputs.files}}'
2931
- name: Run Code Style Check
3032
run: ./gradlew checkstyleCI -i
3133
env:
32-
TARGET_BRANCH: ${{ github.base_ref }}
33-
WORKING_BRANCH: ${{ github.head_ref }}
34+
MODIFIED_FILES: ${{ steps.file_changes.outputs.files}}
3435
- name: Run PMD Quality Check
3536
run: ./gradlew pmdMain -i
3637
- name: Run Spotbugs Quality Check
@@ -80,6 +81,8 @@ jobs:
8081
run: chmod +x gradlew
8182
- name: Pull Base Branch
8283
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
84+
- name: Pull Working Branch
85+
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
8386
# - name: Run automated tests
8487
# run: ./gradlew test -i
8588
- name: Run Code Style Check

gradle-tasks/staticChecks.gradle

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,43 +65,46 @@ task checkstyleCI(type: Checkstyle) {
6565
*/
6666
def getChangedFiles() {
6767
// Get the target and source branch
68-
def envTargetBranch = System.getenv("TARGET_BRANCH")
69-
def envSourceBranch = System.getenv("WORKING_BRANCH")
68+
//def envTargetBranch = System.getenv("TARGET_BRANCH")
69+
//def envSourceBranch = System.getenv("WORKING_BRANCH")
70+
def modifiedFiles = System.getenv("MODIFIED_FILES")
7071

71-
println "Target Branch: ${envTargetBranch}"
72-
println "Source Branch: ${envSourceBranch}"
72+
println "Modified Files: ${modifiedFiles}"
7373

74-
// Compare to master if no branch specified
75-
def targetBranch
76-
if (project.hasProperty("branch")) {
77-
targetBranch = project.property("branch")
78-
} else {
79-
targetBranch = envTargetBranch ? "origin/${envTargetBranch}" : getParentBranch()
80-
}
81-
def sourceBranch = envSourceBranch ? "origin/${envSourceBranch}" : ""
74+
//println "Target Branch: ${envTargetBranch}"
75+
//println "Source Branch: ${envSourceBranch}"
8276

83-
println "Merging ${sourceBranch} into ${targetBranch}"
77+
// Compare to master if no branch specified
78+
// def targetBranch
79+
// if (project.hasProperty("branch")) {
80+
// targetBranch = project.property("branch")
81+
// } else {
82+
// targetBranch = envTargetBranch ? "origin/${envTargetBranch}" : getParentBranch()
83+
// }
84+
// def sourceBranch = envSourceBranch ? "origin/${envSourceBranch}" : ""
85+
//
86+
// println "Merging ${sourceBranch} into ${targetBranch}"
8487

8588
// Get list of all changed files including status
86-
def systemOutStream = new ByteArrayOutputStream()
87-
def command = "git diff --name-status --diff-filter=dr $targetBranch $sourceBranch"
88-
command.execute().waitForProcessOutput(systemOutStream, System.err)
89-
def allFiles = systemOutStream.toString().trim().split('\n')
90-
systemOutStream.close()
91-
92-
// Remove the status prefix
93-
Pattern statusPattern = Pattern.compile("(\\w)\\t+(.+)")
89+
// def systemOutStream = new ByteArrayOutputStream()
90+
// def command = "git diff --name-status --diff-filter=dr $targetBranch $sourceBranch"
91+
// command.execute().waitForProcessOutput(systemOutStream, System.err)
92+
// def allFiles = systemOutStream.toString().trim().split('\n')
93+
// systemOutStream.close()
94+
//
95+
// // Remove the status prefix
96+
// Pattern statusPattern = Pattern.compile("(\\w)\\t+(.+)")
9497
List<String> files = new ArrayList<>()
9598

96-
println "Changed files:"
99+
//println "Changed files:"
97100

98-
for (file in allFiles) {
99-
Matcher matcher = statusPattern.matcher(file)
100-
if (matcher.find()) {
101-
println "+ ${matcher.group(2)}"
102-
files.add(matcher.group(2))
103-
}
104-
}
101+
// for (file in allFiles) {
102+
// Matcher matcher = statusPattern.matcher(file)
103+
// if (matcher.find()) {
104+
// println "+ ${matcher.group(2)}"
105+
// files.add(matcher.group(2))
106+
// }
107+
// }
105108

106109
// Return the list of touched files
107110
files

0 commit comments

Comments
 (0)