Skip to content

Commit

Permalink
Merge pull request #3 from AlexanderLavelle/master
Browse files Browse the repository at this point in the history
master into schemagenmod
  • Loading branch information
AlexanderLavelle authored Apr 6, 2024
2 parents 4c9c04b + f0c8140 commit 6415971
Show file tree
Hide file tree
Showing 439 changed files with 55,810 additions and 9,314 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
# Select proto files.
(cat $HOME/files_added.txt; echo; cat $HOME/files_modified.txt) | tr ' ' '\n' | grep '\.proto$' > proto_files.txt || true
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9

- name: Set up Bazel 3.4.1
- name: Set up Bazel 5.3.0
run: |
# Instruction from https://docs.bazel.build/versions/master/install-ubuntu.html
curl -sSL https://github.com/bazelbuild/bazel/releases/download/3.4.1/bazel-3.4.1-installer-linux-x86_64.sh -o bazel_installer.sh
curl -sSL https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel-5.3.0-installer-linux-x86_64.sh -o bazel_installer.sh
chmod +x bazel_installer.sh
sudo ./bazel_installer.sh
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/csat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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})
47 changes: 47 additions & 0 deletions .github/workflows/scripts/constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2023 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
let CONSTANT_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_PARAM: '&entry.2137816233=',
MSG: 'Are you satisfied with the resolution of your issue?',
}
}

};
module.exports = CONSTANT_VALUES;
61 changes: 61 additions & 0 deletions .github/workflows/scripts/csat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2023 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const CONSTANT_VALUES = require('./constant');

/**
* Invoked from stale_csat.js and csat.yaml file to post survey link
* in closed issue.
* @param {!Object.<string,!Object>} github contains pre defined functions.
* context Information about the workflow run.
* @return {null}
*/
module.exports = async ({ github, context }) => {
const issue = context.payload.issue.html_url;
let baseUrl = '';
// 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(CONSTANT_VALUES.GLOBALS.LABELS.BUG) ||
label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.BUG_INSTALL) ||
label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TYPE_PERFORMANCE) ||
label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TYPE_OTHER) ||
label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TYPE_SUPPORT) ||
label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TYPE_DOCS_BUG)) {
console.log(
`label-${label.name}, posting CSAT survey for issue =${issue}`);
if (context.repo.repo.includes('mediapipe'))
baseUrl = CONSTANT_VALUES.MODULE.CSAT.MEDIA_PIPE_BASE_URL;
else
baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL;

const yesCsat = `<a href="${baseUrl + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.YES +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + issue}"> ${CONSTANT_VALUES.MODULE.CSAT.YES}</a>`;

const noCsat = `<a href="${baseUrl + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.NO +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + issue}"> ${CONSTANT_VALUES.MODULE.CSAT.NO}</a>`;
const comment = CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' +
noCsat + '\n';
let issueNumber = context.issue.number ?? context.payload.issue.number;
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
}
};
62 changes: 62 additions & 0 deletions .github/workflows/scripts/stale_csat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2023 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
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.
* @param {!Object.<string,!Object>} github contains pre defined functions.
* context contains information about the workflow run.
*/
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 issueList = closeTimeIssues.data;
for (let i = 0; i < issueList.length; i++) {
if (issueList[i].node_id && issueList[i].node_id.indexOf('PR') != -1)
continue;

let comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueList[i].number
});
let noOfComments = comments.data.length;
let lastComment = comments.data[noOfComments - 1];
let strCom = JSON.stringify(lastComment);
if (strCom.indexOf(CONSTANT.MODULE.CSAT.MSG) == -1) {
context.payload.issue = {};
context.payload.issue.number = issueList[i].number;
context.payload.issue.labels = issueList[i].labels;
context.payload.issue.html_url = issueList[i].html_url;
await csat({github, context});
}
}
};
73 changes: 70 additions & 3 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,85 @@
name: Mark and close stale pull requests
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This workflow alerts and then closes the stale issues/PRs after specific time
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale

name: Mark and close stale PRs/issues

on:
schedule:
- cron: "30 1 * * *"


permissions:
contents: read
issues: write
pull-requests: write

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3.0.8
- uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
#Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale
exempt-issue-labels: 'override-stale'
#Comma separated list of labels that can be assigned to PRs to exclude them from being marked as stale
exempt-pr-labels: "override-stale"
#Limit the No. of API calls in one run default value is 30.
operations-per-run: 1000
# Prevent to remove stale label when PRs or issues are updated.
remove-stale-when-updated: true
# List of labels to remove when issues/PRs unstale.
labels-to-remove-when-unstale: 'stat:awaiting response'
stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
days-before-stale: 30
days-before-close: 5

#comment on PR if stale for more then 30 days.
close-pr-message: This PR was closed due to lack of activity after being marked stale for past 30 days.

# comment on issues if not active for more then 7 days.
stale-issue-message: 'This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.'

#comment on issues if stale for more then 7 days.
close-issue-message: 'This issue was closed due to lack of activity after being marked stale for past 7 days.'

# reason for closed the issue default value is not_planned
close-issue-reason: completed

# Number of days of inactivity before a stale issue is closed
days-before-issue-close: 7

# Number of days of inactivity before an issue Request becomes stale
days-before-issue-stale: 7

#Check for label to stale or close the issue/PR
any-of-labels: 'stat:awaiting response'

#stale label for PRs
stale-pr-label: 'stale'

#stale label for issues
stale-issue-label: 'stale'
- uses: actions/checkout@v3
- uses: actions/github-script@v6
with:
script: |
const script = require('./\.github/workflows/scripts/stale_csat.js')
script({github, context})
Loading

0 comments on commit 6415971

Please sign in to comment.