generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into VAS-834-feat-add-noti…
…ce-generation # Conflicts: # .github/workflows/code_review.yml # .github/workflows/deploy_with_github_runner.yml
- Loading branch information
Showing
10 changed files
with
72 additions
and
150 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
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 |
---|---|---|
|
@@ -28,35 +28,26 @@ jobs: | |
with: | ||
configuration-path: '.github/auto_assign.yml' | ||
|
||
check_format: | ||
name: Check Format | ||
check_labels: | ||
name: Check Required Labels | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Formatting | ||
id: format | ||
continue-on-error: true | ||
uses: findologic/intellij-format-action@main | ||
with: | ||
path: . | ||
fail-on-changes: false | ||
|
||
- uses: actions/[email protected] | ||
if: steps.format.outcome != 'success' | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Verify PR Labels | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major') && !contains(github.event.pull_request.labels.*.name, 'minor') && !contains(github.event.pull_request.labels.*.name, 'patch') && !contains(github.event.pull_request.labels.*.name, 'patch') && !contains(github.event.pull_request.labels.*.name, 'skip') }} | ||
uses: actions/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
console.log(context); | ||
var comments = await github.rest.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
for (const comment of comments.data) { | ||
console.log(comment); | ||
if (comment.body.includes('Comment this PR with')){ | ||
if (comment.body.includes('This pull request does not contain a valid label')){ | ||
github.rest.issues.deleteComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
|
@@ -66,12 +57,12 @@ jobs: | |
} | ||
} | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'Comment this PR with *update_code* to update `openapi.json` and format the code. Consider to use pre-commit to format the code.' | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'This pull request does not contain a valid label. Please add one of the following labels: `[major, minor, patch, patch, skip]`' | ||
}) | ||
core.setFailed('Format your code.') | ||
core.setFailed('Missing required labels') | ||
check_size: | ||
runs-on: ubuntu-latest | ||
|
@@ -84,7 +75,8 @@ jobs: | |
- name: Check Size | ||
uses: actions/[email protected] | ||
env: | ||
IGNORED_FILES: openapi.json, openapi-node.json | ||
IGNORED_FILES: openapi.json | ||
BRANCH_NAME: ${{ github.head_ref}} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
|
@@ -93,15 +85,15 @@ jobs: | |
var changes = additions + deletions | ||
console.log('additions: '+additions+' + deletions: '+deletions+ ' = total changes: ' + changes); | ||
const { IGNORED_FILES } = process.env | ||
const { IGNORED_FILES, BRANCH_NAME } = process.env | ||
const ignored_files = IGNORED_FILES.trim().split(',').filter(word => word.length > 0); | ||
if (ignored_files.length > 0){ | ||
var ignored = 0 | ||
const execSync = require('child_process').execSync; | ||
for (const file of IGNORED_FILES.trim().split(',')) { | ||
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/${{ github.head_ref}} | grep ' + file + ' | cut -f 1', { encoding: 'utf-8' }) | ||
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/${{ github.head_ref}} | grep ' + file + ' | cut -f 2', { encoding: 'utf-8' }) | ||
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/'+BRANCH_NAME+' | grep ' + file + ' | cut -f 1', { encoding: 'utf-8' }) | ||
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/'+BRANCH_NAME+' | grep ' + file + ' | cut -f 2', { encoding: 'utf-8' }) | ||
const ignored_additions = ignored_additions_str.split('\n').map(elem=> parseInt(elem || 0)).reduce( | ||
(accumulator, currentValue) => accumulator + currentValue, | ||
|
@@ -122,21 +114,26 @@ jobs: | |
repo: context.repo.repo | ||
}); | ||
if (labels.data.find(label => label.name == 'size/large')){ | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: 'size/large' | ||
}) | ||
} | ||
if (labels.data.find(label => label.name == 'size/small')){ | ||
if (changes <= 400){ | ||
if (labels.data.find(label => label.name == 'size/large')){ | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: 'size/small' | ||
name: 'size/large' | ||
}) | ||
} | ||
} | ||
if (changes >= 200){ | ||
if (labels.data.find(label => label.name == 'size/small')){ | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: 'size/small' | ||
}) | ||
} | ||
} | ||
var comments = await github.rest.issues.listComments({ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import requests | ||
import json | ||
|
||
import requests | ||
|
||
url = 'https://github.com/pagopa/template-java-spring-microservice/tree/main/.github/workflows' | ||
url = 'https://api.github.com/repos/pagopa/template-java-spring-microservice/contents/.github/workflows' | ||
url_raw = 'https://raw.githubusercontent.com/pagopa/template-java-spring-microservice/main/' | ||
|
||
response = requests.get(url) | ||
|
||
for item in json.loads(response.text)["payload"]["tree"]["items"]: | ||
for item in json.loads(response.text): | ||
path = item["path"] | ||
name = item["name"] | ||
print(name) | ||
response = requests.get(url_raw+path) | ||
response = requests.get(url_raw + path) | ||
fo = open(name, "w") | ||
fo.write(response.text) | ||
fo.close() | ||
|
||
|
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