Skip to content

Commit

Permalink
Merge branch 'main' into renovate/lycheeverse-lychee-action-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 authored Aug 7, 2024
2 parents 82432a5 + 8607835 commit 3c55594
Show file tree
Hide file tree
Showing 40 changed files with 2,364 additions and 2,145 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
outputs:
nodePaths: ${{ steps.interrogate.outputs.nodePaths }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 14
node-version: 18
- id: interrogate
run: node ./.github/workflows/list-node-paths-for-deps.js
updateDeps:
Expand All @@ -27,12 +27,13 @@ jobs:
matrix:
package: ${{fromJson(needs.findPackages.outputs.nodePaths)}}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ matrix.node }}
node-version: 18
- run: echo ./packages/${{ matrix.package }}
- run: cd ./packages/${{ matrix.package }} && npm audit fix
continue-on-error: true
- uses: googleapis/code-suggester@9c92ffb751cbdc880473aa650013b3a3292f743a # v4
env:
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
bashPaths: ${{ steps.interrogate.outputs.bashPaths }}
requiredJobs: ${{ steps.interrogate.outputs.requiredJobs }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
Expand All @@ -32,7 +32,7 @@ jobs:
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ (endsWith(matrix.package, '-utils') || matrix.package == 'auto-approve' || matrix.package == 'canary-bot' || matrix.package == 'conventional-commit-lint' || matrix.package == 'datastore-lock' || matrix.package == 'object-selector' || matrix.package == 'release-please' || matrix.package == 'secret-rotator' || matrix.package == 'owl-bot' ) && 18 || 14 }}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: goimports
run: |
test -z "$($(go env GOPATH)/bin/goimports -l .)"
Expand All @@ -79,7 +79,7 @@ jobs:
module: ${{fromJson(needs.changeFinder.outputs.bashPaths)}}
steps:
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: bashtest
run: |
./test.sh
Expand All @@ -88,7 +88,7 @@ jobs:
runs-on: ubuntu-latest
needs: changeFinder
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 18
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
outputs:
nodePaths: ${{ steps.interrogate.outputs.nodePaths }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
Expand All @@ -27,7 +27,7 @@ jobs:
matrix:
package: ${{fromJson(needs.findPackages.outputs.nodePaths)}}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ matrix.node }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Link Checker
id: lychee
Expand Down
5 changes: 4 additions & 1 deletion packages/auto-approve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ processes:
- "NodeGeneratorDependency"
- "OwlBotTemplateChangesNode"
- "OwlBotPRsNode"
- "RubyApiaryCodegen"
```
These processes represent different workflows for what auto-approve will approve and merge in a given repository. To see their logic in full, see the corresponding file in /src/process-checks.
Expand Down Expand Up @@ -203,7 +204,9 @@ Below is what each process checks for:
- Checks that the body of the PR DOES contain 'PiperOrigin-RevId'
- Checks that the PR is the first of owlbot PRs in the repo (so that they are not merged out of order)
- Checks that there are no other commit authors other than owlbot on the repo

* RubyApiaryCodegen
- Checks that the author is 'yoshi-code-bot'
- Checks that the title of the PR matches the regexp: /^feat: Automated regeneration of .* client$/

This change in configuration permits the following:
* Allows for more complete testing as described by c8, by codifying the logic in TS as opposed to the JSON validation schema
Expand Down
2 changes: 1 addition & 1 deletion packages/auto-approve/__snapshots__/check-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports['check for config whether YAML file has valid schema should fail if ther
`

exports['check for config whether YAML file has valid schema V2 should fail if YAML has any other properties than the ones specified 1'] = `
[{"wrongProperty":{"allowedValues":["UpdateDiscoveryArtifacts","RegenerateReadme","DiscoveryDocUpdate","PythonDependency","PythonSampleDependency","NodeDependency","NodeRelease","JavaApiaryCodegen","JavaDependency","OwlBotTemplateChanges","OwlBotTemplateChangesNode","OwlBotPRsNode","OwlBotAPIChanges","PHPApiaryCodegen","PythonSampleAppDependency","JavaSampleAppDependency","DockerDependency","GoDependency","GoApiaryCodegen","NodeGeneratorDependency"]},"message":"must be equal to one of the allowed values"}]
[{"wrongProperty":{"allowedValues":["UpdateDiscoveryArtifacts","RegenerateReadme","DiscoveryDocUpdate","PythonDependency","PythonSampleDependency","NodeDependency","NodeRelease","JavaApiaryCodegen","JavaDependency","OwlBotTemplateChanges","OwlBotTemplateChangesNode","OwlBotPRsNode","OwlBotAPIChanges","PHPApiaryCodegen","PythonSampleAppDependency","JavaSampleAppDependency","DockerDependency","GoDependency","GoApiaryCodegen","RubyApiaryCodegen","NodeGeneratorDependency"]},"message":"must be equal to one of the allowed values"}]
`

exports['check for config whether YAML file has valid schema V2 should fail if the property is wrong 1'] = `
Expand Down
40 changes: 20 additions & 20 deletions packages/auto-approve/package-lock.json

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

5 changes: 5 additions & 0 deletions packages/auto-approve/src/check-pr-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {PHPApiaryCodegen} from './process-checks/php/apiary-codegen';
import {PythonSampleDependency} from './process-checks/python/sample-dependency';
import {logger as defaultLogger, GCFLogger} from 'gcf-utils';
import {GoApiaryCodegen} from './process-checks/go/apiary-codegen';
import {RubyApiaryCodegen} from './process-checks/ruby/apiary-codegen';
// This file manages the logic to check whether a given PR matches the config in the repository

// We need this typeMap to convert the JSON input (string) into a corresponding type.
Expand Down Expand Up @@ -122,6 +123,10 @@ const typeMap = [
configValue: 'NodeGeneratorDependency',
configType: NodeGeneratorDependency,
},
{
configValue: 'RubyApiaryCodegen',
configType: RubyApiaryCodegen,
},
];

/**
Expand Down
59 changes: 59 additions & 0 deletions packages/auto-approve/src/process-checks/ruby/apiary-codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 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.

import {PullRequest} from '../../interfaces';
import {
checkAuthor,
checkTitleOrBody,
reportIndividualChecks,
} from '../../utils-for-pr-checking';
import {Octokit} from '@octokit/rest';
import {BaseLanguageRule} from '../base';

/**
* The RubyApiaryCodegen class's checkPR function returns
* true if the PR:
- has an author that is 'yoshi-code-bot'
- has a title that matches the regexp: /^feat: Automated regeneration of .* client$/
*/
export class RubyApiaryCodegen extends BaseLanguageRule {
classRule = {
author: 'yoshi-code-bot',
titleRegex: /^feat: Automated regeneration of .* client$/,
};
constructor(octokit: Octokit) {
super(octokit);
}

public async checkPR(incomingPR: PullRequest): Promise<boolean> {
const authorshipMatches = checkAuthor(
this.classRule.author,
incomingPR.author
);

const titleMatches = checkTitleOrBody(
incomingPR.title,
this.classRule.titleRegex
);
reportIndividualChecks(
['authorshipMatches', 'titleMatches'],
[authorshipMatches, titleMatches],
incomingPR.repoOwner,
incomingPR.repoName,
incomingPR.prNumber
);

return authorshipMatches && titleMatches;
}
}
1 change: 1 addition & 0 deletions packages/auto-approve/src/valid-pr-schema-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"DockerDependency",
"GoDependency",
"GoApiaryCodegen",
"RubyApiaryCodegen",
"NodeGeneratorDependency"
]
}
Expand Down
62 changes: 62 additions & 0 deletions packages/auto-approve/test/ruby-apiary-codegen.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2024 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.

import {RubyApiaryCodegen} from '../src/process-checks/ruby/apiary-codegen';
import {describe, it} from 'mocha';
import assert from 'assert';
const {Octokit} = require('@octokit/rest');

const octokit = new Octokit({
auth: 'mypersonalaccesstoken123',
});
describe('RubyApiaryCodegen', () => {
it('should return false in checkPR if incoming PR does not match classRules', async () => {
const incomingPR = {
author: 'testAuthor',
title: 'testTitle',
fileCount: 3,
changedFiles: [{filename: 'hello', sha: '2345'}],
repoName: 'testRepoName',
repoOwner: 'testRepoOwner',
prNumber: 1,
body: 'body',
};

const rule = new RubyApiaryCodegen(octokit);

assert.deepStrictEqual(await rule.checkPR(incomingPR), false);
});

it('should return true in checkPR if incoming PR does match classRules', async () => {
const incomingPR = {
author: 'yoshi-code-bot',
title: 'feat: Automated regeneration of admin v1 client',
fileCount: 3,
changedFiles: [
{
filename: 'README.md',
sha: '2345',
},
],
repoName: 'testRepoName',
repoOwner: 'testRepoOwner',
prNumber: 1,
body: 'body',
};

const rule = new RubyApiaryCodegen(octokit);

assert.ok(await rule.checkPR(incomingPR));
});
});
Loading

0 comments on commit 3c55594

Please sign in to comment.