From e97a7ad9897305a17e9230f0a83ceea4906a9de8 Mon Sep 17 00:00:00 2001 From: Shivam Mishra <124146945+shmishra99@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:53:55 +0530 Subject: [PATCH 1/5] Update stale.yaml --- .github/workflows/stale.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index e93efeb8251..53fd804d643 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -64,3 +64,9 @@ jobs: stale-pr-label: 'stale' # override stale to stalled for Issue stale-issue-label: "stale" + - uses: actions/checkout@v3 + - uses: actions/github-script@v6 + with: + script: | + const script = require('./\.github/workflows/scripts/staleCSAT.js') + script({github, context}) From d0b44f573deedd799eec02bbdf26741a6e182d3b Mon Sep 17 00:00:00 2001 From: Shivam Mishra <124146945+shmishra99@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:58:58 +0530 Subject: [PATCH 2/5] Migrate CSAT from probot to Github action. --- .github/workflows/CSAT.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/CSAT.yml diff --git a/.github/workflows/CSAT.yml b/.github/workflows/CSAT.yml new file mode 100644 index 00000000000..1272636f603 --- /dev/null +++ b/.github/workflows/CSAT.yml @@ -0,0 +1,23 @@ +name: 'CSAT survey' +on: + issues: + types: + - closed + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/github-script@v6 + with: + script: | + const script = require('./\.github/workflows/scripts/CSAT.js') + script({github, context}) + + From 0efaa1b22d680cdf4cad38788e8a387b195d3372 Mon Sep 17 00:00:00 2001 From: Shivam Mishra <124146945+shmishra99@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:05:56 +0530 Subject: [PATCH 3/5] CSAT migration from probot to action workflow. --- .github/workflows/constant.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/constant.js diff --git a/.github/workflows/constant.js b/.github/workflows/constant.js new file mode 100644 index 00000000000..c748e0b83e6 --- /dev/null +++ b/.github/workflows/constant.js @@ -0,0 +1,33 @@ +let CONSTENT_VALUES = { + GLOBALS: { + LABELS: { + STALE: "stale", + AWAITINGRES: "stat:awaiting response", + BUG: 'type:bug', + BUG_INSTALL: 'type:build/install', + TYPE_SUPPORT: 'type:support', + TYPE_OTHER: 'type:others', + TYPE_DOCS_BUG: 'type:docs-bug', + TYPE_PERFORMANCE: 'type:performance' + }, + STATE: { + CLOSED: "closed" + }, + TENSORFLOW_CORE_REPO: 'https://github.com/tensorflow/tensorflow/pull', + PR_TRIGGER_REPO: 'testRep,keras' + }, + MODULE: { + CSAT: { + YES:'Yes', + NO:'No', + BASE_URL: 'https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPG' + + 'k4kc1-qMdv3gc6bEP90vY1ew/viewform?', + MEDIA_PIPE_BASE_URL: 'https://docs.google.com/forms/d/e/1FAIpQLScOLT8zeBHummIZFnfr9wqvxYzWD1DAypyvNia5WVIWtFANYg/viewform?', + SATISFACTION_PARAM: 'entry.85265664=', + ISSUEID_PRAM: '&entry.2137816233=', + MSG: 'Are you satisfied with the resolution of your issue?', + } + } + +} +module.exports = CONSTENT_VALUES From 309f62745fe589b36f3377902896844de7e5e489 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 10 Apr 2023 16:16:31 +0530 Subject: [PATCH 4/5] Migrate CSAT survey to Github action from probot. --- .github/workflows/CSAT.yml | 4 +- .github/workflows/scripts/CSAT.js | 48 ++++++++++++++++++++ .github/workflows/{ => scripts}/constant.js | 0 .github/workflows/scripts/staleCSAT.js | 49 +++++++++++++++++++++ 4 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/scripts/CSAT.js rename .github/workflows/{ => scripts}/constant.js (100%) create mode 100644 .github/workflows/scripts/staleCSAT.js diff --git a/.github/workflows/CSAT.yml b/.github/workflows/CSAT.yml index 1272636f603..8fe8db327b8 100644 --- a/.github/workflows/CSAT.yml +++ b/.github/workflows/CSAT.yml @@ -18,6 +18,4 @@ jobs: with: script: | const script = require('./\.github/workflows/scripts/CSAT.js') - script({github, context}) - - + script({github, context}) \ No newline at end of file diff --git a/.github/workflows/scripts/CSAT.js b/.github/workflows/scripts/CSAT.js new file mode 100644 index 00000000000..defb0610655 --- /dev/null +++ b/.github/workflows/scripts/CSAT.js @@ -0,0 +1,48 @@ + +const CONSTENT_VALUES = require('./constant'); +/* +Invoked from staleCSAT.js and CSAT.yaml file to +post survey link in closed issue. +*/ +module.exports = async ({ github, context }) => { + const issue = context.payload.issue.html_url; + let base_url = ''; + //Loop over all ths label present in issue and check if specific label is present for survey link. + for (const label of context.payload.issue.labels) { + if (label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.BUG) || + label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.BUG_INSTALL) || + label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.TYPE_PERFORMANCE) || + label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.TYPE_OTHER) || + label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.TYPE_SUPPORT) || + label.name.includes(CONSTENT_VALUES.GLOBALS.LABELS.TYPE_DOCS_BUG)) { + console.log(`label-${label.name}, posting CSAT survey for issue =${issue}`); + if (context.repo.repo.includes('mediapipe')) + base_url = CONSTENT_VALUES.MODULE.CSAT.MEDIA_PIPE_BASE_URL; + else + base_url = CONSTENT_VALUES.MODULE.CSAT.BASE_URL; + const yesCsat = + (CONSTENT_VALUES.MODULE.CSAT.YES) + .link( + base_url + CONSTENT_VALUES.MODULE.CSAT.SATISFACTION_PARAM + + CONSTENT_VALUES.MODULE.CSAT.YES + CONSTENT_VALUES.MODULE.CSAT.ISSUEID_PRAM + issue) + const noCsat = + (CONSTENT_VALUES.MODULE.CSAT.NO) + .link( + base_url + CONSTENT_VALUES.MODULE.CSAT.SATISFACTION_PARAM + + CONSTENT_VALUES.MODULE.CSAT.NO + CONSTENT_VALUES.MODULE.CSAT.ISSUEID_PRAM + issue) + const comment = CONSTENT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' + noCsat + '\n'; + let isnumber = context.issue.number ?? context.payload.issue.number; + + await github.rest.issues.createComment({ + issue_number: isnumber, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); + return + } + } + } + + + diff --git a/.github/workflows/constant.js b/.github/workflows/scripts/constant.js similarity index 100% rename from .github/workflows/constant.js rename to .github/workflows/scripts/constant.js diff --git a/.github/workflows/scripts/staleCSAT.js b/.github/workflows/scripts/staleCSAT.js new file mode 100644 index 00000000000..1578d261ceb --- /dev/null +++ b/.github/workflows/scripts/staleCSAT.js @@ -0,0 +1,49 @@ + +const csat = require('./CSAT.js'); +const constant = require("./constant.js"); +/* +When stale bot closes the issue this function will +invoke and post CSAT link on the issue. +This function will fetch all the issues closed within 20 minutes and +post the survey link if survey link is not posted already. +*/ + +module.exports = async ({ github, context }) => { + + let date = new Date(); + let totalMilliSeconds = date.getTime(); + let minutes = 20; + let millisecondsToSubtract = minutes * 60 * 1000; + let closeTime = totalMilliSeconds-millisecondsToSubtract; + let newDate = new Date(closeTime); + let ISOCloseTime = newDate.toISOString(); + let closeTimeIssues = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state:"closed", + labels:"stale", + since:ISOCloseTime + }); + let ISSUESLIST = closeTimeIssues.data; + for(let i=0;i Date: Mon, 10 Apr 2023 16:19:26 +0530 Subject: [PATCH 5/5] Migrate CSAT survey to Github action from probot. --- .github/workflows/stale.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 53fd804d643..294c6342222 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -70,3 +70,4 @@ jobs: script: | const script = require('./\.github/workflows/scripts/staleCSAT.js') script({github, context}) +