Skip to content

Commit

Permalink
refactor: use sinon to mock octokit methods (#5195)
Browse files Browse the repository at this point in the history
feat!: require node 18
feat!: remove `addOrUpdateIssueComment` which is moved to issue-utils.
  • Loading branch information
chingor13 committed Sep 11, 2023
1 parent 4a53082 commit 057125e
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 444 deletions.
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 {
// 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,
};

0 comments on commit 057125e

Please sign in to comment.