Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce new bot-framework library #5236

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a455073
prototype probot less gcf-utils
chingor13 Sep 20, 2023
22a6509
error handling
chingor13 Sep 20, 2023
efaebe9
pubsub and errors
chingor13 Sep 20, 2023
fdf643c
test: mock task enqueuer
chingor13 Sep 25, 2023
28091b6
refactor: rename to bot-framework
chingor13 Sep 25, 2023
0587bb6
ci: test on node 18
chingor13 Sep 25, 2023
78be503
chore: fix license headers
chingor13 Sep 25, 2023
db28dcc
chore: fix lint
chingor13 Sep 25, 2023
76a384f
test: rewrite error handling tests
chingor13 Sep 25, 2023
d555fda
chore: fix copyright years
chingor13 Sep 25, 2023
7a0ba0f
test: add load tests
chingor13 Sep 25, 2023
5aed06c
context logger and octokit
chingor13 Sep 25, 2023
daea452
context logger/octokit
chingor13 Sep 25, 2023
29402ca
test: task retry tests
chingor13 Sep 25, 2023
610f084
test: add test for payload cache
chingor13 Sep 25, 2023
e5171f0
save payload in cache
chingor13 Sep 25, 2023
a0fade8
sign payload outside of task enqueuer
chingor13 Sep 25, 2023
2a4de70
move task caller options to cloud task enqueuer
chingor13 Sep 26, 2023
1273263
port bot-request test
chingor13 Sep 26, 2023
11f5ddb
port logging tests
chingor13 Sep 26, 2023
bb9e724
test: port error logging tests
chingor13 Sep 26, 2023
71f2d3c
test: port server tests
chingor13 Sep 26, 2023
cdaae23
chore: fix header years
chingor13 Sep 26, 2023
9e0fba6
chore: remove unnecessary import
chingor13 Sep 26, 2023
b397b81
Merge branch 'main' into no-probot
chingor13 Oct 3, 2023
675a03b
separate GCPBootstrapper from Bootstrapper
chingor13 Oct 9, 2023
b40768d
add environment-secret-loader
chingor13 Oct 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ (endsWith(matrix.package, '-utils') || matrix.package == 'canary-bot' || matrix.package == 'datastore-lock' || matrix.package == 'object-selector' || matrix.package == 'release-please' ) && 18 || 14 }}
node-version: ${{ (endsWith(matrix.package, '-utils') || matrix.package == 'bot-framework' || matrix.package == 'canary-bot' || matrix.package == 'datastore-lock' || matrix.package == 'object-selector' || matrix.package == 'release-please' ) && 18 || 14 }}
- run: echo ./packages/${{ matrix.package }}
- run: cd ./packages/${{ matrix.package }}
- run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions packages/bot-framework/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exclude": [".mocharc.js", "build/test"]
}
7 changes: 7 additions & 0 deletions packages/bot-framework/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/
coverage/
node_modules/
.env
*.pem
Dockerfile
.dockerignore
4 changes: 4 additions & 0 deletions packages/bot-framework/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules
**/coverage
test/fixtures
build/
4 changes: 4 additions & 0 deletions packages/bot-framework/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./node_modules/gts",
"root": true
}
3 changes: 3 additions & 0 deletions packages/bot-framework/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
coverage
28 changes: 28 additions & 0 deletions packages/bot-framework/.mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 Google LLC
//
// 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 config = {
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000
}
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
if (process.env.MOCHA_REPORTER_OUTPUT) {
config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`;
}
module.exports = config
6 changes: 6 additions & 0 deletions packages/bot-framework/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/coverage
test/fixtures
build/
docs/
protos/
17 changes: 17 additions & 0 deletions packages/bot-framework/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Google LLC
//
// 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
//
// https://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.

module.exports = {
...require('gts/.prettierrc.json')
}
49 changes: 49 additions & 0 deletions packages/bot-framework/Dockerfile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was for local testing and can be removed later.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2021 Google LLC
#
# 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.

# Use a multi-stage docker build to limit production dependencies.

# Use the official lightweight Node.js 14 image.
# https://hub.docker.com/_/node
FROM node:18-slim AS BUILD

# Create and change to the app directory.
WORKDIR /usr/src/app

# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
COPY package*.json ./

# Install build dependencies.
RUN npm ci

# Now copy all the code so we can compile
COPY . ./

RUN npm run compile

FROM node:18-slim

# Create and change to the app directory.
WORKDIR /usr/src/app

COPY package*.json ./
COPY --from=BUILD /usr/src/app/build build
RUN npm ci --only=production

ENV NODE_ENV "production"

# Run the web service on container startup.
CMD [ "npm", "--no-update-notifier", "run", "start" ]
18 changes: 18 additions & 0 deletions packages/bot-framework/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# foo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine I want to write a new bot.* Please describe the list of services provided by this library and why I would want to use them.

  • I know we said we never want to write a new bot, but I think imagining we might will result in a README that better helps maintainers.


Instructions are provided in [googleapis/repo-automation-bots](https://github.com/googleapis/repo-automation-bots/blob/main/README.md) for deploying and testing your bots.

This bot uses nock for mocking requests to GitHub, and snap-shot-it for capturing responses; This allows updates to the API surface to be treated as a visual diff, rather than tediously asserting against each field.

## Running tests:

`npm test`

## Contributing

If you have suggestions for how foo could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License
Apache 2.0 © 2021 Google LLC.
27 changes: 27 additions & 0 deletions packages/bot-framework/cloudbuild-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Google LLC
#
# 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.

steps:
- name: gcr.io/cloud-builders/docker
id: 'build-docker'
waitFor: ['-']
dir: 'packages/'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/'
- '.'

# TODO: create container test
# TODO: create unit & integration tests
38 changes: 38 additions & 0 deletions packages/bot-framework/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2021 Google LLC
#
# 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.

steps:
- name: gcr.io/cloud-builders/npm
id: "build"
waitFor: ["-"]
entrypoint: bash
args:
- "-e"
- "./scripts/build-function.sh"
- "$_DIRECTORY"

- name: gcr.io/cloud-builders/gcloud
id: "publish-function"
waitFor: ["build"]
entrypoint: bash
args:
- "-e"
- "./scripts/publish-function.sh"
- "$_DIRECTORY"
- "$PROJECT_ID"
- "$_BUCKET"
- "$_KEY_LOCATION"
- "$_KEY_RING"
- "$_FUNCTION_REGION"
- "nodejs12"
Loading
Loading