generated from pagopa/pagopa-functions-template
-
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 pull request #7 from pagopa/PAGOPA-2645-tuning-fdr-to-eventhub
feat: PAGOPA-2645 test tuning
- Loading branch information
Showing
15 changed files
with
477 additions
and
121 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = async ({github, context, core}) => { | ||
const 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) { | ||
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, | ||
repo: context.repo.repo, | ||
comment_id: comment.id | ||
}) | ||
} | ||
} | ||
github.rest.issues.createComment({ | ||
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('Missing required labels') | ||
} |
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,99 @@ | ||
module.exports = async ({github, context, core}) => { | ||
const additions = context.payload.pull_request.additions || 0 | ||
const deletions = context.payload.pull_request.deletions || 0 | ||
let changes = additions + deletions; | ||
console.log('additions: ' + additions + ' + deletions: ' + deletions + ' = total changes: ' + changes); | ||
|
||
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/' + 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, | ||
0); | ||
const ignored_deletions = ignored_deletions_str.split('\n').map(elem => parseInt(elem || 0)).reduce( | ||
(accumulator, currentValue) => accumulator + currentValue, | ||
0); | ||
|
||
ignored += ignored_additions + ignored_deletions; | ||
} | ||
changes -= ignored | ||
console.log('ignored lines: ' + ignored + ' , consider changes: ' + changes); | ||
} | ||
|
||
var labels = await github.rest.issues.listLabelsOnIssue({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
|
||
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/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({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
for (const comment of comments.data) { | ||
if (comment.body.includes('This PR exceeds the recommended size')) { | ||
github.rest.issues.deleteComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment.id | ||
}) | ||
} | ||
} | ||
|
||
if (changes < 200) { | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['size/small'] | ||
}) | ||
} | ||
|
||
if (changes > 400) { | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['size/large'] | ||
}) | ||
|
||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'This PR exceeds the recommended size of 400 lines. Please make sure you are NOT addressing multiple issues with one PR. _Note this PR might be rejected due to its size._' | ||
}) | ||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
apiVersion: v2 | ||
name: pagopa-functions-template | ||
description: Microservice description | ||
name: pagopa-fdr-to-event-hub | ||
description: Microservice fdr to event hub | ||
type: application | ||
version: 0.27.0 | ||
appVersion: 0.0.2 | ||
version: 0.43.0 | ||
appVersion: 0.0.2-16-PAGOPA-2645-tuning-fdr-to-eventhub | ||
dependencies: | ||
- name: microservice-chart | ||
version: 1.21.0 | ||
version: 7.1.1 | ||
repository: "https://pagopa.github.io/aks-microservice-chart-blueprint" |
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.