-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1781 from jplag/develop
Merge develop into main
- Loading branch information
Showing
138 changed files
with
4,334 additions
and
3,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Close linked issue on PR merge | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
close_issues: | ||
if: github.event.pull_request.merged == true && github.base_ref == 'develop' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run script | ||
working-directory: .github/workflows/scripts | ||
run: | | ||
pip install requests | ||
python closeDevIssues.py ${{ secrets.GITHUB_TOKEN }} jplag JPlag ${{ github.event.pull_request.number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Builds JPlag and then runs Datasets and Report Viewer e2e tests on multiple OS | ||
name: Complete e2e Test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- ".github/workflows/complete-e2e.yml" | ||
- "report-viewer/**" | ||
- "**/pom.xml" | ||
- "**.java" | ||
- "**.g4" | ||
|
||
jobs: | ||
pre_job: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
concurrent_skipping: 'same_content_newer' | ||
skip_after_successful_duplicate: 'true' | ||
|
||
build_jar: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: 'temurin' | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Build Assembly | ||
run: mvn -Pwith-report-viewer -DskipTests clean package assembly:single | ||
|
||
- name: Rename Jar | ||
run: mv cli/target/jplag-*-jar-with-dependencies.jar cli/target/jplag.jar | ||
|
||
- name: Upload Assembly | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "JPlag" | ||
path: "cli/target/jplag.jar" | ||
retention-days: 30 | ||
|
||
run_jplag: | ||
needs: build_jar | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
dataset: [ | ||
{zip: "progpedia.zip", name: "progpedia", folder: "ACCEPTED", language: "java", cliArgs: "-bc base"}, | ||
{zip: "fileSingleRoot.zip", name: "fileSingleRoot", folder: "fileSingleRoot", language: "java", cliArgs: ""}, | ||
{zip: "folderSingleRoot.zip", name: "folderSingleRoot", folder: "folderSingleRoot", language: "java", cliArgs: ""}, | ||
{zip: "fileMultiRoot.zip", name: "fileMultiRoot", folder: "f0", language: "java", cliArgs: "--new f1"}, | ||
{zip: "folderMultiRoot.zip", name: "folderMultiRoot", folder: "f0", language: "java", cliArgs: "--new f1"}, | ||
{zip: "mixedMultiRoot.zip", name: "mixedBaseFile", folder: "f0", language: "java", cliArgs: "--new f1"}, | ||
{zip: "mixedMultiRoot.zip", name: "mixedBaseFolder", folder: "f1", language: "java", cliArgs: "--new f0"}, | ||
{zip: "cpp.zip", name: "cpp", folder: "./cpp", language: "cpp", cliArgs: ""}, | ||
{zip: "csharp.zip", name: "csharp", folder: "./csharp", language: "csharp", cliArgs: ""}, | ||
{zip: "python.zip", name: "python", folder: "./python", language: "python3", cliArgs: ""} | ||
] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: 'temurin' | ||
|
||
- name: Get JAR | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: JPlag | ||
|
||
- name: Copy and unzip dataset windows | ||
if: ${{ matrix.os == 'windows-latest' }} | ||
run: | | ||
Expand-Archive -LiteralPath .github/workflows/files/${{ matrix.dataset.zip }} -DestinationPath ./ | ||
- name: Copy and unzip dataset macos and ubuntu | ||
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'}} | ||
run: | | ||
unzip .github/workflows/files/${{ matrix.dataset.zip }} | ||
- name: Run JPlag | ||
run: | | ||
java -jar jplag.jar ${{ matrix.dataset.folder }} -l ${{ matrix.dataset.language }} -r ${{ matrix.dataset.name }}-report ${{ matrix.dataset.cliArgs }} | ||
- name: Upload result | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "${{ matrix.dataset.name }}-${{ matrix.os }}" | ||
path: "${{ matrix.dataset.name }}-report.zip" | ||
retention-days: 30 | ||
|
||
e2e_test: | ||
needs: run_jplag | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install and Build | ||
working-directory: report-viewer | ||
run: | | ||
npm install | ||
npm run build | ||
- name: Install playwright | ||
working-directory: report-viewer | ||
run: npx playwright install --with-deps | ||
|
||
- name: Download JPlag Reports | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: "*-${{ matrix.os }}" | ||
path: "report-viewer/tests/e2e/assets" | ||
merge-multiple: true | ||
|
||
- name: Run tests | ||
working-directory: report-viewer | ||
run: | | ||
npm run test:e2e | ||
- name: Upload test results | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: "test-results-${{ matrix.os }}" | ||
path: | | ||
report-viewer/test-results | ||
report-viewer/playwright-report | ||
retention-days: 30 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import requests | ||
import re | ||
import sys | ||
|
||
headers = {"Authorization": f"Bearer {sys.argv[1]}"} | ||
|
||
owner = sys.argv[2] | ||
repo = sys.argv[3] | ||
pr_number = int(sys.argv[4]) | ||
|
||
query = f""" | ||
{{ | ||
repository(owner: "{owner}", name: "{repo}") {{ | ||
pullRequest(number: {pr_number}) {{ | ||
merged | ||
baseRefName | ||
body | ||
closingIssuesReferences (first: 50) {{ | ||
nodes {{ | ||
number | ||
}} | ||
}} | ||
}} | ||
}} | ||
}} | ||
""" | ||
|
||
def run_query(query): | ||
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers) | ||
if request.status_code == 200: | ||
return request.json() | ||
else: | ||
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query)) | ||
|
||
|
||
closing_keywords = [ | ||
'closes', 'close', 'closed', 'fix', 'fixes', 'fixed', 'resolves', 'resolve', 'resolved' | ||
] | ||
|
||
# checks all subsequeces of the pr body for closing keywords and extracts the coresponidng issue numbers | ||
def subsequences_matching_regex(input_string, regex): | ||
matches = [] | ||
for i in range(len(input_string)): | ||
for j in range(i+1, len(input_string)+1): | ||
subsequence = input_string[i:j] | ||
match = re.fullmatch(regex, subsequence) | ||
if match: | ||
matches.append(int(match.group(1))) | ||
return matches | ||
|
||
# gets all issues linked to pr either via the closing keywords or the sidebar | ||
def get_linked_issues(result): | ||
issue_body = result['body'].lower() + "." # we append a dot to the end of the body to make sure the last word is checked with the regex | ||
closing_issues = [] | ||
for keyword in closing_keywords: | ||
closing_issues.extend(subsequences_matching_regex(issue_body, f'{keyword} #([0-9]+)[^0-9]')) | ||
for k in result['closingIssuesReferences']['nodes']: | ||
closing_issues.append(k['number']) | ||
return list(set(closing_issues)) | ||
|
||
result = run_query(query)['data']['repository']['pullRequest'] | ||
issues = get_linked_issues(result) | ||
|
||
def close_issue(issue_number): | ||
requests.post(f"https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/comments", json={"body": f"Closed by #{pr_number}."}, headers=headers) | ||
requests.patch(f"https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}", json={"state": "closed"}, headers=headers) | ||
|
||
if result['baseRefName'] != "develop": | ||
print("PR not merged to develop, not closing issues") | ||
elif result['merged']: | ||
print(f"Closing issues: {issues}") | ||
for issue in issues: | ||
close_issue(issue) | ||
print(f"Closed issue {issue}") | ||
else: | ||
print("PR not merged, not closing issues") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.