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

refactor: use sinon to mock octokit methods #5195

Merged
merged 8 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 14
node-version: 18
- id: interrogate
run: node ./.github/workflows/interrogate.js
env:
Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 14
node-version: ${{ matrix.package == 'gcf-utils' && 18 || 14 }}
- run: echo ./packages/${{ matrix.package }}
- run: cd ./packages/${{ matrix.package }}
- run: npm ci
Expand Down Expand Up @@ -90,6 +90,6 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 14
node-version: 18
- run: npm install
- run: node ./.github/workflows/finale.js '${{needs.changeFinder.outputs.requiredJobs}}' ${{secrets.GITHUB_TOKEN}}
3 changes: 2 additions & 1 deletion packages/gcf-utils/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "./node_modules/gts"
"extends": "./node_modules/gts",
"root": true
}
3 changes: 2 additions & 1 deletion packages/gcf-utils/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000
"timeout": 10000,
"exit": true
}
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
Expand Down
14 changes: 7 additions & 7 deletions packages/gcf-utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/gcf-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"typescript": "^4.9.4"
},
"engines": {
"node": ">= 14"
"node": ">= 18"
},
"keywords": [
"google cloud functions",
Expand Down
45 changes: 45 additions & 0 deletions packages/gcf-utils/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.
//

export const RUNNING_IN_TEST = process.env.NODE_ENV === 'test';
// Adding 30 second delay for each batch with 30 tasks
export const DEFAULT_FLOW_CONTROL_DELAY_IN_SECOND = 30;

// Wrapper options for configuring the probot server
export interface WrapConfig {
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
// Whether to enable octokit request logging
logging: boolean;
// Whether to skip the webhook secret verification. Useful for local testing
skipVerification: boolean;
// Number of times to attempt retries on cron requests
maxCronRetries: number;
// Number of times to attempt retries on webhook requests
maxRetries: number;
// Number of times to attempt retries on pub/sub requests
maxPubSubRetries: number;
// When batch scheduling cron requests, delay groups of requests by X seconds
// to avoid flooding
flowControlDelayInSeconds: number;
}

// Default configuration options
export const DEFAULT_WRAP_CONFIG: WrapConfig = {
logging: false,
skipVerification: RUNNING_IN_TEST,
maxCronRetries: 0,
maxRetries: 10,
maxPubSubRetries: 0,
flowControlDelayInSeconds: DEFAULT_FLOW_CONTROL_DELAY_IN_SECOND,
};
Loading
Loading