Skip to content

Commit df45b33

Browse files
authored
Merge pull request #2334 from jplag/develop
Merge develop into Main
2 parents 483cfc4 + fba51d1 commit df45b33

File tree

228 files changed

+3789
-3209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+3789
-3209
lines changed

.github/workflows/complete-e2e.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ jobs:
3131

3232
steps:
3333
- uses: actions/checkout@v4
34-
34+
3535
- name: Set up JDK
3636
uses: actions/setup-java@v4
3737
with:
3838
java-version: 21
3939
distribution: 'temurin'
40-
40+
4141
- uses: actions/setup-node@v4
4242
with:
4343
node-version: "18"
44-
44+
4545
- name: Build Assembly
4646
run: mvn -DskipTests clean package assembly:single
47-
47+
4848
- name: Rename Jar
4949
run: mv cli/target/jplag-*-jar-with-dependencies.jar cli/target/jplag.jar
50-
50+
5151
- name: Upload Assembly
5252
uses: actions/upload-artifact@v4
5353
with:
@@ -84,7 +84,7 @@ jobs:
8484
with:
8585
java-version: 21
8686
distribution: 'temurin'
87-
87+
8888
- name: Get JAR
8989
uses: actions/download-artifact@v4
9090
with:
@@ -94,7 +94,7 @@ jobs:
9494
if: ${{ matrix.os == 'windows-latest' }}
9595
run: |
9696
Expand-Archive -LiteralPath .github/workflows/files/${{ matrix.dataset.zip }} -DestinationPath ./
97-
97+
9898
- name: Copy and unzip dataset macos and ubuntu
9999
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'}}
100100
run: |
@@ -103,12 +103,12 @@ jobs:
103103
- name: Run JPlag
104104
run: |
105105
java -jar jplag.jar ${{ matrix.dataset.folder }} -l ${{ matrix.dataset.language }} -r ${{ matrix.dataset.name }}-report ${{ matrix.dataset.cliArgs }}
106-
106+
107107
- name: Upload result
108108
uses: actions/upload-artifact@v4
109109
with:
110110
name: "${{ matrix.dataset.name }}-${{ matrix.os }}"
111-
path: "${{ matrix.dataset.name }}-report.zip"
111+
path: "${{ matrix.dataset.name }}-report.jplag"
112112
retention-days: 30
113113

114114
e2e_test:
@@ -132,7 +132,7 @@ jobs:
132132
run: |
133133
npm install
134134
npm run build
135-
135+
136136
- name: Install playwright
137137
working-directory: report-viewer
138138
run: npx playwright install --with-deps

.github/workflows/report-viewer-demo.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
branches:
77
- main
8-
8+
99
jobs:
1010
build-jar:
1111
runs-on: ubuntu-latest
@@ -19,10 +19,10 @@ jobs:
1919
with:
2020
java-version: 21
2121
distribution: 'temurin'
22-
22+
2323
- name: Build Assembly
2424
run: mvn clean package assembly:single
25-
25+
2626
- name: Upload Assembly
2727
uses: actions/upload-artifact@v4
2828
with:
@@ -43,39 +43,39 @@ jobs:
4343
with:
4444
java-version: 21
4545
distribution: 'temurin'
46-
46+
4747
- name: Get JAR
4848
uses: actions/download-artifact@v4
4949
with:
5050
name: JPlag
51-
51+
5252
- name: Copy and unzip submissions
5353
run: unzip ./.github/workflows/files/progpedia.zip
54-
54+
5555
- name: Rename jar
5656
run: mv *.jar ./jplag.jar
57-
57+
5858
- name: Run JPlag
5959
run: java -jar jplag.jar ACCEPTED -bc base -r example
60-
60+
6161
- name: Upload Result
6262
uses: actions/upload-artifact@v4
6363
with:
6464
name: "Result"
65-
path: "example.zip"
66-
65+
path: "example.jplag"
66+
6767

6868
build-and-deploy:
6969
needs: run-example
7070
runs-on: ubuntu-latest
7171
steps:
7272
- name: Checkout 🛎️
7373
uses: actions/checkout@v4
74-
74+
7575
- uses: actions/setup-node@v4
7676
with:
7777
node-version: "18"
78-
78+
7979
- name: Set version of Report Viewer
8080
shell: bash
8181
run: |
@@ -88,7 +88,7 @@ jobs:
8888
echo "$json" > report-viewer/src/version.json
8989
echo "Version of Report Viewer:"
9090
cat report-viewer/src/version.json
91-
91+
9292
- name: Download Results
9393
uses: actions/download-artifact@v4
9494
with:
@@ -100,14 +100,14 @@ jobs:
100100
run: |
101101
npm install
102102
npm run build-demo
103-
103+
104104
- name: Deploy 🚀
105-
uses: JamesIves/[email protected].2
105+
uses: JamesIves/[email protected].3
106106
with:
107107
branch: gh-pages
108108
folder: report-viewer/dist
109109
repository-name: JPlag/Demo
110110
token: ${{ secrets.SDQ_DEV_DEPLOY_TOKEN }}
111111
clean: true
112112
single-commit: true
113-
113+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Report Viewer Develop Demo Deployment
2+
3+
on:
4+
workflow_dispatch: # Use this to dispatch from the Actions Tab
5+
push:
6+
branches:
7+
- develop
8+
9+
jobs:
10+
build-jar:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout 🛎️
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 21
21+
distribution: 'temurin'
22+
23+
- name: Build Assembly
24+
run: mvn clean package assembly:single
25+
26+
- name: Upload Assembly
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: "JPlag"
30+
path: "cli/target/jplag-*-jar-with-dependencies.jar"
31+
32+
33+
run-example:
34+
needs: build-jar
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout 🛎️
39+
uses: actions/checkout@v4
40+
41+
- name: Set up JDK
42+
uses: actions/setup-java@v4
43+
with:
44+
java-version: 21
45+
distribution: 'temurin'
46+
47+
- name: Get JAR
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: JPlag
51+
52+
- name: Copy and unzip submissions
53+
run: unzip ./.github/workflows/files/progpedia.zip
54+
55+
- name: Rename jar
56+
run: mv *.jar ./jplag.jar
57+
58+
- name: Run JPlag
59+
run: java -jar jplag.jar ACCEPTED -bc base -r example
60+
61+
- name: Upload Result
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: "Result"
65+
path: "example.jplag"
66+
67+
68+
build-and-deploy:
69+
needs: run-example
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout 🛎️
73+
uses: actions/checkout@v4
74+
75+
- uses: actions/setup-node@v4
76+
with:
77+
node-version: "18"
78+
79+
- name: Download Results
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: Result
83+
path: report-viewer/public
84+
85+
- name: Install and Build 🔧
86+
working-directory: report-viewer
87+
run: |
88+
npm install
89+
npm run build-dev-demo
90+
91+
- name: Deploy 🚀
92+
uses: JamesIves/[email protected]
93+
with:
94+
branch: gh-pages
95+
folder: report-viewer/dist
96+
repository-name: JPlag/DevDemo
97+
token: ${{ secrets.SDQ_DEV_DEPLOY_TOKEN }}
98+
clean: true
99+
single-commit: true
100+

.github/workflows/report-viewer-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
npm run build-dev
2828
2929
- name: Deploy 🚀
30-
uses: JamesIves/[email protected].2
30+
uses: JamesIves/[email protected].3
3131
with:
3232
branch: gh-pages
3333
folder: report-viewer/dist
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
'''
2+
This script extracts all help text parameter descriptions from the documentation and compares it to the help text generated by the jar file.
3+
Steps:
4+
1) Get content of files that should contain the help text (mentioned in variable filesToCheck).
5+
2) Extract all triple fenced code blocks from the file content. (```)
6+
3) Find the code block that starts with "Parameter descriptions:". This is the one that contains the CLI text.
7+
4) Remove empty lines at the end of the code block, as this can mess up the comparison.
8+
5) Get the help text from the jar file using the command "java -jar jplag.jar -h".
9+
6) Compare the CLI text from the jar with the one in the documentation. If they do not match, add an error to the list of errors.
10+
7) Print the errors found, if any. If no errors are found, print "No errors found." and exit with code 0.
11+
12+
Important: This script relies on the help text being inside a tripple fe4nced code block (```) starting with "Parameter descriptions:". If this ever changes this script will fail.
13+
'''
14+
import subprocess
15+
16+
# Extract all triple fenced blocks from the text and returns them without the ```
17+
# Each section is a list of lines, and the list of sections is a list of lists
18+
def getAllCodeSections(text):
19+
codeSections = []
20+
currentSection = None
21+
22+
for line in text:
23+
if line.startswith("```"):
24+
if currentSection is not None:
25+
codeSections.append(currentSection)
26+
currentSection = None
27+
else:
28+
currentSection = []
29+
else:
30+
if currentSection is not None:
31+
currentSection.append(line)
32+
33+
if currentSection is not None:
34+
codeSections.append(currentSection)
35+
36+
return codeSections
37+
38+
# Reads a file as a list of lines
39+
def getFilesText(file):
40+
f = open(file, 'r', encoding='utf-8')
41+
return f.read().split('\n')
42+
43+
# Filters the sections to find the one that starts with "Parameter descriptions:", which is the one indicating the CLI text
44+
def getCliTextCodeSection(sections):
45+
for section in sections:
46+
if section[0].startswith("Parameter descriptions:"):
47+
return section
48+
return None
49+
50+
# Removes empty lines at the end of the list
51+
def removeEmptyLinesAtEndOfDocument(text):
52+
while len(text) > 0 and text[-1].strip() == "":
53+
text.pop()
54+
return text
55+
56+
# Stores the offset of the CLI text in the original file
57+
lineOffset = {}
58+
59+
# Reads the file and extracts the CLI text from it
60+
def getCliTextFromFile(file):
61+
text = getFilesText(file)
62+
codeSections = getAllCodeSections(text)
63+
cliTextSection = getCliTextCodeSection(codeSections)
64+
if cliTextSection is None:
65+
return None
66+
removedEmptyLines = removeEmptyLinesAtEndOfDocument(cliTextSection)
67+
lineOffset[file] = text.index(cliTextSection[0]) + 1 if cliTextSection else 0
68+
return removedEmptyLines
69+
70+
class Error:
71+
def __init__(self, fileName, lineNumber, message):
72+
self.fileName = fileName
73+
self.lineNumber = lineNumber
74+
self.message = message
75+
76+
def __str__(self):
77+
offset = lineOffset[self.fileName] if self.fileName in lineOffset else 0
78+
return f"{self.fileName.split('/')[-1]}:{self.lineNumber+offset}: {self.message}"
79+
80+
errors = []
81+
82+
# get help text from jar, the first 5 lines get removed as they are not part of the help text in our markdown documents
83+
helpTextLines = subprocess.run(["java", "-jar", "jplag.jar", "-h"], capture_output=True, text=True).stdout.split('\n')[5::]
84+
helpTextLines = removeEmptyLinesAtEndOfDocument(helpTextLines)
85+
86+
# these are the files that contain the help text
87+
filesToCheck = ["../../../README.md", "../../../docs/1.-How-to-Use-JPlag.md"]
88+
89+
# Verifies that the CLI text from the jar matches the one in the md file
90+
def checkCliTextAgainstHelpText(mdText, fileName):
91+
minLines = min(len(mdText), len(helpTextLines))
92+
if (len(mdText) != len(helpTextLines)):
93+
errors.append(Error(fileName, minLines, f"The number of lines in the CLI text from the jar({len(helpTextLines)}) does not match the md text({len(mdText)})."))
94+
for i in range(minLines):
95+
if (mdText[i] != helpTextLines[i]):
96+
helpSpace = helpTextLines[i].replace(" ", '\u23B5')
97+
mdSpace = mdText[i].replace(" ", '\u23B5')
98+
errors.append(Error(fileName, i, f"Does not match the CLI text from the jar. Expected: '{helpSpace}', Found: '{mdSpace}'."))
99+
100+
for file in filesToCheck:
101+
cliText = getCliTextFromFile(file)
102+
103+
if cliText is None:
104+
errors.append(Error(file, 0, "No CLI text found in the file."))
105+
else:
106+
checkCliTextAgainstHelpText(cliText, file)
107+
108+
if len(errors) > 0:
109+
print("Errors found:")
110+
for error in errors:
111+
print(error)
112+
exit(1)
113+
else:
114+
print("No errors found.")
115+
exit(0)

0 commit comments

Comments
 (0)