Коммит
d8601249b3
|
@ -13,7 +13,7 @@ requesters:
|
|||
- github_actions
|
||||
`;
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(provider, "getConfigContent")
|
||||
.mockImplementation(() => configContent);
|
||||
expect(provider.getConfigContent()).toBe(configContent);
|
||||
|
@ -28,7 +28,7 @@ requesters:
|
|||
|
||||
test("We do not receive the expected config content", async () => {
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(provider, "getConfigContent")
|
||||
.mockImplementation(() => false);
|
||||
expect(provider.getConfigContent()).toBe(false);
|
||||
|
@ -42,7 +42,7 @@ test("We receive malformed yaml from the config content", async () => {
|
|||
let configContent = `---
|
||||
requeaklfsdhjalkfhlakhfkahlkfah`;
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(provider, "getConfigContent")
|
||||
.mockImplementation(() => configContent);
|
||||
expect(provider.getConfigContent()).toBe(configContent);
|
||||
|
|
|
@ -12,7 +12,7 @@ jest.spyOn(core, "setOutput").mockImplementation(() => {});
|
|||
|
||||
test("We can create a review", async () => {
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest.spyOn(provider, "createReview").mockImplementation(() => true);
|
||||
jest.spyOn(provider, "createReview").mockImplementation(() => true);
|
||||
expect(provider.createReview()).toBe(true);
|
||||
|
||||
let pullRequest = new PullRequest(provider);
|
||||
|
@ -26,7 +26,7 @@ test("We can list commits", async () => {
|
|||
{ author: { login: "danhoerst" } },
|
||||
];
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(provider, "listPRCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(provider.listPRCommits()).toBe(prCommits);
|
||||
|
@ -39,7 +39,7 @@ test("We can list commits", async () => {
|
|||
test("We can list labels", async () => {
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(provider, "listLabelsOnPR")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(provider.listLabelsOnPR()).toBe(prLabels);
|
||||
|
@ -64,7 +64,7 @@ index 2f4e8d9..93c2072 100644
|
|||
with:
|
||||
name: dist`;
|
||||
let provider = new GitHubProvider("token");
|
||||
let spy = jest.spyOn(provider, "getPRDiff").mockImplementation(() => prDiff);
|
||||
jest.spyOn(provider, "getPRDiff").mockImplementation(() => prDiff);
|
||||
expect(provider.getPRDiff()).toBe(prDiff);
|
||||
|
||||
let pullRequest = new PullRequest(provider);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GitHubProvider } from "../src/github-provider";
|
||||
import { PrivilegedRequester } from "../src/privileged-requester";
|
||||
// import { PrivilegedRequester } from "../src/privileged-requester";
|
||||
import { PullRequest } from "../src/pull-request";
|
||||
import { Runner } from "../src/runner";
|
||||
import * as core from "@actions/core";
|
||||
|
@ -25,7 +25,7 @@ afterEach(() => {
|
|||
describe("processCommits", () => {
|
||||
test("We process commits successfully", async () => {
|
||||
let prCommits = [{ author: { login: "robot" } }];
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(pullRequest.listCommits()).toBe(prCommits);
|
||||
|
@ -39,7 +39,7 @@ describe("processCommits", () => {
|
|||
{ author: { login: "robot" } },
|
||||
{ author: { login: "danhoerst" } },
|
||||
];
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(pullRequest.listCommits()).toBe(prCommits);
|
||||
|
@ -63,7 +63,7 @@ index 2f4e8d9..93c2072 100644
|
|||
if: blah
|
||||
with:
|
||||
name: dist`;
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "getDiff")
|
||||
.mockImplementation(() => prDiff);
|
||||
expect(pullRequest.getDiff()).toBe(prDiff);
|
||||
|
@ -86,7 +86,7 @@ index 2f4e8d9..93c2072 100644
|
|||
if: blah
|
||||
with:
|
||||
name: dist`;
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "getDiff")
|
||||
.mockImplementation(() => prDiff);
|
||||
expect(pullRequest.getDiff()).toBe(prDiff);
|
||||
|
@ -117,7 +117,7 @@ describe("labelsEqual", () => {
|
|||
describe("processLabels", () => {
|
||||
test("We process labels successfully", async () => {
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listLabels")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(pullRequest.listLabels()).toBe(prLabels);
|
||||
|
@ -130,7 +130,7 @@ describe("processLabels", () => {
|
|||
|
||||
test("We process labels unsuccessfully", async () => {
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let spy = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listLabels")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(pullRequest.listLabels()).toBe(prLabels);
|
||||
|
@ -148,13 +148,13 @@ describe("processPrivilegedReviewer", () => {
|
|||
process.env["INPUT_CHECKLABELS"] = "true";
|
||||
process.env["INPUT_CHECKDIFF"] = "true";
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let spyLabels = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listLabels")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(pullRequest.listLabels()).toBe(prLabels);
|
||||
|
||||
let prCommits = [{ author: { login: "robot" } }];
|
||||
let spyCommits = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(pullRequest.listCommits()).toBe(prCommits);
|
||||
|
@ -171,7 +171,7 @@ index 2f4e8d9..93c2072 100644
|
|||
if: blah
|
||||
with:
|
||||
name: dist`;
|
||||
let spyDiff = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "getDiff")
|
||||
.mockImplementation(() => prDiff);
|
||||
expect(pullRequest.getDiff()).toBe(prDiff);
|
||||
|
@ -189,7 +189,7 @@ index 2f4e8d9..93c2072 100644
|
|||
{ author: { login: "robot" } },
|
||||
{ author: { login: "malicious" } },
|
||||
];
|
||||
let spyCommits = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(pullRequest.listCommits()).toBe(prCommits);
|
||||
|
@ -205,7 +205,7 @@ index 2f4e8d9..93c2072 100644
|
|||
{ author: { login: "robot" } },
|
||||
{ author: { login: "malicious" } },
|
||||
];
|
||||
let spyCommits = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listCommits")
|
||||
.mockImplementation(() => prCommits);
|
||||
expect(pullRequest.listCommits()).toBe(prCommits);
|
||||
|
@ -219,7 +219,7 @@ index 2f4e8d9..93c2072 100644
|
|||
test("We process labels unsuccessfully with the option enabled", async () => {
|
||||
process.env["INPUT_CHECKLABELS"] = "true";
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let spyLabels = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listLabels")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(pullRequest.listLabels()).toBe(prLabels);
|
||||
|
@ -232,7 +232,7 @@ index 2f4e8d9..93c2072 100644
|
|||
|
||||
test("We allow bad labels when the option to check them is not set", async () => {
|
||||
let prLabels = [{ name: "bug" }, { name: "feature-request" }];
|
||||
let spyLabels = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "listLabels")
|
||||
.mockImplementation(() => prLabels);
|
||||
expect(pullRequest.listLabels()).toBe(prLabels);
|
||||
|
@ -258,7 +258,7 @@ index 2f4e8d9..93c2072 100644
|
|||
if: blah
|
||||
with:
|
||||
name: dist`;
|
||||
let spyDiff = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "getDiff")
|
||||
.mockImplementation(() => prDiff);
|
||||
expect(pullRequest.getDiff()).toBe(prDiff);
|
||||
|
@ -283,7 +283,7 @@ index 2f4e8d9..93c2072 100644
|
|||
if: blah
|
||||
with:
|
||||
name: dist`;
|
||||
let spyDiff = jest
|
||||
jest
|
||||
.spyOn(pullRequest, "getDiff")
|
||||
.mockImplementation(() => prDiff);
|
||||
expect(pullRequest.getDiff()).toBe(prDiff);
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
"rules": {}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
|
|
@ -4,35 +4,34 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
package-check:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js 18.x
|
||||
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # pin@v3.4.1
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v3.8.1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version-file: .node-version
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
- name: rebuild the dist/ directory
|
||||
run: npm run bundle
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
- name: compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --text --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
|
@ -40,7 +39,7 @@ jobs:
|
|||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v2
|
||||
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # pin@v3.1.2
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./
|
||||
with:
|
||||
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
|
@ -7,6 +7,6 @@ jobs:
|
|||
units:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
20.6.0
|
20
README.md
20
README.md
|
@ -1,5 +1,7 @@
|
|||
# Privileged Requester
|
||||
|
||||
[![CodeQL](https://github.com/github/privileged-requester/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/github/privileged-requester/actions/workflows/codeql-analysis.yml) [![package-check](https://github.com/github/privileged-requester/actions/workflows/package-check.yml/badge.svg)](https://github.com/github/privileged-requester/actions/workflows/package-check.yml) [![units-test](https://github.com/github/privileged-requester/actions/workflows/test.yml/badge.svg)](https://github.com/github/privileged-requester/actions/workflows/test.yml) [![privileged-requester](https://github.com/github/privileged-requester/actions/workflows/privileged-requester.yml/badge.svg)](https://github.com/github/privileged-requester/actions/workflows/privileged-requester.yml)
|
||||
|
||||
This GitHub Action will automatically approve pull requests based off of requester criteria defined in the target repository.
|
||||
|
||||
## Workflow Configuration
|
||||
|
@ -14,7 +16,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# checkout the repository
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# run privileged-requester
|
||||
- uses: github/privileged-requester@vX.X.X
|
||||
|
@ -53,17 +55,17 @@ Here are the configuration options for this Action:
|
|||
|
||||
| Input | Required? | Default | Description |
|
||||
|-----------| --------- |---------------------------------------------| ----------- |
|
||||
| myToken | yes | ${{ github.token }} | The GitHub token used to create an authenticated client - Provided for you by default! |
|
||||
| `myToken` | yes | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! |
|
||||
| robotUserToken | no | - | An alternative robot user PAT to be used instead of the built-in Actions token |
|
||||
| path | yes | config/privileged-requester.yaml | Path where the privileged requester configuration can be found |
|
||||
| prCreator | yes | ${{ github.event.pull_request.user.login }} | The creator of the PR for this pull request event |
|
||||
| prNumber | yes | ${{ github.event.pull_request.number }} | The number of the PR for this pull request event |
|
||||
| checkCommits | yes | "true" | An option to check that every commit in the PR is made from the privileged requester |
|
||||
| checkDiff | yes | "true" | An option to check that the PR diff only has a removal diff, with no additions |
|
||||
| checkLabels | yes | "true" | An option to check that the labels on the PR match those defined in the privileged requester config |
|
||||
| `path` | yes | `config/privileged-requester.yaml` | Path where the privileged requester configuration can be found |
|
||||
| `prCreator` | yes | `${{ github.event.pull_request.user.login }}` | The creator of the PR for this pull request event |
|
||||
| `prNumber` | yes | `${{ github.event.pull_request.number }}` | The number of the PR for this pull request event |
|
||||
| `checkCommits` | yes | `"true"` | An option to check that every commit in the PR is made from the privileged requester |
|
||||
| `checkDiff` | yes | `"true"` | An option to check that the PR diff only has a removal diff, with no additions |
|
||||
| `checkLabels` | yes | `"true"` | An option to check that the labels on the PR match those defined in the privileged requester config |
|
||||
|
||||
## Outputs 📤
|
||||
|
||||
| Output | Description |
|
||||
| ------ | ----------- |
|
||||
| approved | The string "true" if the privileged-requester approved the pull request |
|
||||
| `approved` | The string `"true"` if the privileged-requester approved the pull request |
|
||||
|
|
|
@ -39,5 +39,5 @@ outputs:
|
|||
approved: # output will be available to future steps
|
||||
description: "Whether or not the PR was approved - 'true' or 'false'"
|
||||
runs:
|
||||
using: 'node16'
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -47,6 +47,28 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@fastify/busboy
|
||||
MIT
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
@octokit/auth-token
|
||||
MIT
|
||||
The MIT License
|
||||
|
@ -576,6 +598,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
|
||||
undici
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
universal-user-agent
|
||||
ISC
|
||||
# [ISC License](https://spdx.org/licenses/ISC)
|
||||
|
|
2
index.js
2
index.js
|
@ -14,4 +14,4 @@ const provider = new GitHubProvider(myToken);
|
|||
const pullRequest = new PullRequest(provider);
|
||||
const privilegedRequester = new PrivilegedRequester(provider);
|
||||
const runner = new Runner(pullRequest, privilegedRequester);
|
||||
await runner.run();
|
||||
runner.run();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -20,23 +20,24 @@
|
|||
"keywords": [
|
||||
"GitHub",
|
||||
"Actions",
|
||||
"JavaScript"
|
||||
"JavaScript",
|
||||
"pull-request"
|
||||
],
|
||||
"author": "",
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/github/privileged-requester/issues"
|
||||
},
|
||||
"homepage": "https://github.com/github/privileged-requester#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.5",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^5.1.1",
|
||||
"js-yaml": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.18.6",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"@vercel/ncc": "^0.38.0",
|
||||
"eslint": "^8.25.0",
|
||||
"jest": "^29.2.0",
|
||||
"nock": "^13.2.9",
|
||||
|
|
Загрузка…
Ссылка в новой задаче