├── .github ├── funding.yml ├── label-merge-conflicts.png ├── workflows │ ├── release.yml │ ├── rebase.yml │ ├── codeql-analysis.yml │ └── test.yml └── dependabot.yml ├── .prettierignore ├── .eslintignore ├── .gitattributes ├── src ├── main.ts ├── wait.ts ├── util.ts ├── interfaces.ts ├── label.ts ├── run.ts ├── pulls.ts └── queries.ts ├── .prettierrc.json ├── jest.config.js ├── tsconfig.json ├── COPYING ├── LICENSE ├── action.yml ├── package.json ├── .gitignore ├── .eslintrc.json ├── README.md ├── dist ├── sourcemap-register.js └── licenses.txt └── __tests__ └── main.test.ts /.github/funding.yml: -------------------------------------------------------------------------------- 1 | github: [prince-chrismc] 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | dist/** -diff linguist-generated=true -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import {run} from './run' 2 | 3 | run() 4 | -------------------------------------------------------------------------------- /.github/label-merge-conflicts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pt-br/label-merge-conflicts-action/main/.github/label-merge-conflicts.png -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "arrowParens": "avoid" 10 | } 11 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | release: 3 | types: [published] 4 | jobs: 5 | tag-major: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: Actions-R-Us/actions-tagger@v2 9 | with: 10 | token: ${{ secrets.REPO_PAT }} 11 | -------------------------------------------------------------------------------- /src/wait.ts: -------------------------------------------------------------------------------- 1 | export async function wait(milliseconds: number): Promise { 2 | return new Promise(resolve => { 3 | if (isNaN(milliseconds)) { 4 | throw new Error('milliseconds not a number') 5 | } 6 | 7 | setTimeout(() => resolve('done!'), milliseconds) 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Enable version updates for npm 4 | - package-ecosystem: 'npm' 5 | # Look for `package.json` and `lock` files in the `root` directory 6 | directory: '/' 7 | # Check the npm registry for updates every day (weekdays) 8 | schedule: 9 | interval: 'daily' 10 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | collectCoverageFrom: ['**/*.ts', '!src/main.ts'], 7 | testRunner: 'jest-circus/runner', 8 | transform: { 9 | '^.+\\.ts$': 'ts-jest' 10 | }, 11 | verbose: true 12 | } 13 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | rebase: 9 | if: github.event.issue.pull_request != '' && github.actor == 'prince-chrismc' && contains(github.event.comment.body, '/rebase') 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | token: ${{ secrets.REPO_PAT }} 15 | fetch-depth: 0 # otherwise, you will fail to push refs to dest repo 16 | - uses: cirrus-actions/rebase@1.4 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.REPO_PAT }} 19 | -------------------------------------------------------------------------------- /src/util.ts: -------------------------------------------------------------------------------- 1 | import {IGitHubPRNode, IGitHubPullRequest, IGitHubLabelNode, IGitHubRepoLabels} from './interfaces' 2 | 3 | export function getPullrequestsWithoutMergeStatus(pullrequests: IGitHubPRNode[]): IGitHubPRNode[] { 4 | return pullrequests.filter((pullrequest: IGitHubPRNode) => { 5 | return pullrequest.node.mergeable === 'UNKNOWN' 6 | }) 7 | } 8 | 9 | export function isAlreadyLabeled(pullrequest: IGitHubPullRequest, label: IGitHubLabelNode): boolean { 10 | return ( 11 | pullrequest.labels.edges.find((l: IGitHubLabelNode) => { 12 | return l.node.id === label.node.id 13 | }) !== undefined 14 | ) 15 | } 16 | 17 | export function findLabelByName(labelData: IGitHubRepoLabels, labelName: string): IGitHubLabelNode { 18 | for (const label of labelData.repository.labels.edges) { 19 | if (label.node.name === labelName) { 20 | return label 21 | } 22 | } 23 | 24 | throw new Error(`The label "${labelName}" was not found in your repository!`) 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "outDir": "./lib", /* Redirect output structure to the directory. */ 6 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 7 | "strict": true, /* Enable all strict type-checking options. */ 8 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | }, 11 | "exclude": ["node_modules", "**/*.test.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Marko Schilde 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface IGitHubLabelNode { 2 | node: { 3 | id: string 4 | name: string 5 | } 6 | } 7 | 8 | export interface IGitHubRepoLabels { 9 | repository: { 10 | labels: { 11 | edges: IGitHubLabelNode[] 12 | } 13 | } 14 | } 15 | 16 | export interface IGitHubPullRequest { 17 | id: string 18 | number: number 19 | author: { 20 | login: string 21 | } 22 | mergeable: string 23 | potentialMergeCommit: { 24 | oid: string 25 | } 26 | labels: { 27 | edges: IGitHubLabelNode[] 28 | } 29 | } 30 | 31 | export interface IGitHubPRNode { 32 | node: IGitHubPullRequest 33 | } 34 | 35 | export interface IGitHubPageInfo { 36 | endCursor: string 37 | hasNextPage: boolean 38 | } 39 | 40 | export interface IGitHubRepoPullRequest { 41 | repository: { 42 | pullRequest: IGitHubPullRequest 43 | } 44 | } 45 | 46 | export interface IGitHubRepoPullRequests { 47 | repository: { 48 | pullRequests: { 49 | edges: IGitHubPRNode[] 50 | pageInfo: IGitHubPageInfo 51 | } 52 | } 53 | } 54 | 55 | export interface IGitHubFileChange { 56 | sha: string 57 | filename: string 58 | } 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Label Merge Conflicts" 2 | description: 'Label pull requests with merge conflicts and subtle git-blob merge changes beyond those flagged by GitHub' 3 | author: "prince-chrismc" 4 | branding: 5 | icon: "git-merge" 6 | color: "red" 7 | inputs: 8 | conflict_label_name: 9 | description: "label name used to marked PRs with merge conflicts" 10 | required: true 11 | github_token: 12 | description: "GitHub token / secret" 13 | required: true 14 | max_retries: 15 | description: "number of times to retry on a failed mergable check" 16 | required: false 17 | default: "5" 18 | wait_ms: 19 | description: "miliseconds between retries" 20 | required: false 21 | default: "5000" 22 | detect_merge_changes: 23 | description: "treat soft changes within the merge commits as conflicts and label accordingly" 24 | required: false 25 | default: "false" 26 | slack_webhook_channel: 27 | description: "the slack channel to output the message" 28 | required: true 29 | default: "#release-management" 30 | slack_webhook_url: 31 | description: "slack webhook url" 32 | required: true 33 | runs: 34 | using: "node12" 35 | main: "dist/index.js" 36 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main, dependabot/* ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '41 13 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'javascript' ] 36 | 37 | steps: 38 | - name: Checkout repository 39 | uses: actions/checkout@v2 40 | 41 | - name: Initialize CodeQL 42 | uses: github/codeql-action/init@v1 43 | with: 44 | languages: ${{ matrix.language }} 45 | 46 | - name: Autobuild 47 | uses: github/codeql-action/autobuild@v1 48 | - name: Perform CodeQL Analysis 49 | uses: github/codeql-action/analyze@v1 50 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | pull_request: 4 | push: 5 | branches: [ main ] 6 | workflow_dispatch: {} 7 | 8 | jobs: 9 | ci: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/cache@v2 14 | with: 15 | path: node_modules 16 | key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} 17 | - run: yarn install 18 | - run: yarn all 19 | - uses: EndBug/add-and-commit@v7 20 | if: ${{ github.ref != 'refs/heads/main' }} 21 | with: 22 | author_name: github-actions[bot] 23 | author_email: github-actions[bot]@users.noreply.github.com 24 | message: 'auto commit: linting and/or packing changes' 25 | add: '*' 26 | 27 | e2e: # make sure the action works on a clean machine without building 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: ./ 32 | with: 33 | conflict_label_name: "has conflict" 34 | github_token: ${{ secrets.REPO_PAT }} 35 | detect_merge_changes: true 36 | 37 | coverage: 38 | needs: [ci, e2e] 39 | runs-on: ubuntu-latest 40 | steps: 41 | - uses: actions/checkout@v2 42 | - uses: actions/cache@v2 43 | with: 44 | path: node_modules 45 | key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} 46 | - run: yarn install 47 | - run: yarn test --coverage 48 | - uses: codecov/codecov-action@v1 49 | with: 50 | directory: coverage/ 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "label-merge-conflicts-action", 3 | "version": "1.1.0", 4 | "private": true, 5 | "description": "GitHub Action to automatically label PRs with merge conflicts", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "tsc", 9 | "format": "prettier --write **/*.ts", 10 | "lint": "eslint --fix src/**/*.ts", 11 | "package": "ncc build --source-map --license licenses.txt", 12 | "test": "jest", 13 | "all": "yarn format && yarn lint && yarn test && yarn build && yarn package" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/prince-chrismc/label-merge-conflicts-action.git" 18 | }, 19 | "keywords": [ 20 | "actions", 21 | "node", 22 | "setup", 23 | "typescript", 24 | "github", 25 | "actions", 26 | "label" 27 | ], 28 | "author": "prince-chrismc", 29 | "license": "MIT", 30 | "dependencies": { 31 | "@actions/core": "^1.4.0", 32 | "@actions/github": "^5.0.0", 33 | "@octokit/webhooks-definitions": "^3.67.3", 34 | "axios": "^0.21.1" 35 | }, 36 | "devDependencies": { 37 | "@types/jest": "^26.0.23", 38 | "@types/node": "^15.14.0", 39 | "@typescript-eslint/parser": "^4.28.1", 40 | "@vercel/ncc": "^0.28.0", 41 | "eslint": "^7.29.0", 42 | "eslint-plugin-github": "^4.1.3", 43 | "eslint-plugin-jest": "^24.3.6", 44 | "jest": "^26.6.3", 45 | "jest-circus": "^27.0.6", 46 | "js-yaml": "^4.1.0", 47 | "nock": "^13.1.0", 48 | "prettier": "2.3.2", 49 | "ts-jest": "^26.5.6", 50 | "typescript": "^4.3.5" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directory 2 | node_modules 3 | 4 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # next.js build output 76 | .next 77 | 78 | # nuxt.js build output 79 | .nuxt 80 | 81 | # vuepress build output 82 | .vuepress/dist 83 | 84 | # Serverless directories 85 | .serverless/ 86 | 87 | # FuseBox cache 88 | .fusebox/ 89 | 90 | # DynamoDB Local files 91 | .dynamodb/ 92 | 93 | # OS metadata 94 | .DS_Store 95 | Thumbs.db 96 | 97 | # Ignore built ts files 98 | __tests__/runner/* 99 | lib/**/* -------------------------------------------------------------------------------- /src/label.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import {Context} from '@actions/github/lib/context' 3 | import {GitHub} from '@actions/github/lib/utils' 4 | 5 | import {IGitHubPullRequest, IGitHubLabelNode} from './interfaces' 6 | import {checkPullRequestForMergeChanges} from './pulls' 7 | import {addLabelToLabelable, removeLabelFromLabelable} from './queries' 8 | import {isAlreadyLabeled} from './util' 9 | 10 | interface Labelable { 11 | labelId: string 12 | labelableId: string 13 | } 14 | 15 | async function applyLabelable( 16 | octokit: InstanceType, 17 | labelable: Labelable, 18 | hasLabel: boolean, 19 | pullRequestNumber: number, 20 | pullRequestAuthor: string, 21 | context: Context 22 | ) { 23 | if (hasLabel) { 24 | core.debug(`Skipping #${pullRequestNumber}, it is already labeled`) 25 | return 26 | } 27 | 28 | core.info(`Labeling #${pullRequestNumber}...`) 29 | await addLabelToLabelable(octokit, labelable, pullRequestNumber, pullRequestAuthor, context) 30 | } 31 | 32 | export async function updatePullRequestConflictLabel( 33 | octokit: InstanceType, 34 | context: Context, 35 | pullRequest: IGitHubPullRequest, 36 | conflictLabel: IGitHubLabelNode, 37 | detectMergeChanges: boolean 38 | ): Promise { 39 | const hasLabel = isAlreadyLabeled(pullRequest, conflictLabel) 40 | const labelable: Labelable = {labelId: conflictLabel.node.id, labelableId: pullRequest.id} 41 | 42 | switch (pullRequest.mergeable) { 43 | case 'CONFLICTING': 44 | await applyLabelable(octokit, labelable, hasLabel, pullRequest.number, pullRequest?.author?.login, context) 45 | break 46 | 47 | case 'MERGEABLE': 48 | if (detectMergeChanges && (await checkPullRequestForMergeChanges(octokit, context, pullRequest))) { 49 | await applyLabelable(octokit, labelable, hasLabel, pullRequest.number, pullRequest?.author?.login, context) 50 | break 51 | } 52 | 53 | if (hasLabel) { 54 | core.info(`Unmarking #${pullRequest.number}...`) 55 | await removeLabelFromLabelable(octokit, labelable) 56 | } 57 | break 58 | 59 | default: 60 | break 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jest", "@typescript-eslint"], 3 | "extends": ["plugin:github/recommended"], 4 | "parser": "@typescript-eslint/parser", 5 | "parserOptions": { 6 | "ecmaVersion": 9, 7 | "sourceType": "module", 8 | "project": "./tsconfig.json" 9 | }, 10 | "rules": { 11 | "semi": ["error", "never"], 12 | "import/no-namespace": "off", 13 | "@typescript-eslint/no-unused-vars": "error", 14 | "@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}], 15 | "@typescript-eslint/no-require-imports": "error", 16 | "@typescript-eslint/array-type": "error", 17 | "@typescript-eslint/await-thenable": "error", 18 | "@typescript-eslint/ban-ts-comment": "error", 19 | "@typescript-eslint/consistent-type-assertions": "error", 20 | "@typescript-eslint/explicit-function-return-type": "off", 21 | "@typescript-eslint/func-call-spacing": ["error", "never"], 22 | "@typescript-eslint/no-array-constructor": "error", 23 | "@typescript-eslint/no-empty-interface": "error", 24 | "@typescript-eslint/no-extraneous-class": "error", 25 | "@typescript-eslint/no-for-in-array": "error", 26 | "@typescript-eslint/no-inferrable-types": "error", 27 | "@typescript-eslint/no-misused-new": "error", 28 | "@typescript-eslint/no-namespace": "error", 29 | "@typescript-eslint/no-non-null-assertion": "warn", 30 | "@typescript-eslint/no-unnecessary-qualifier": "error", 31 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 32 | "@typescript-eslint/no-useless-constructor": "error", 33 | "@typescript-eslint/no-var-requires": "error", 34 | "@typescript-eslint/prefer-for-of": "warn", 35 | "@typescript-eslint/prefer-function-type": "warn", 36 | "@typescript-eslint/prefer-includes": "error", 37 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 38 | "@typescript-eslint/promise-function-async": "error", 39 | "@typescript-eslint/require-array-sort-compare": "error", 40 | "@typescript-eslint/restrict-plus-operands": "error", 41 | "@typescript-eslint/type-annotation-spacing": "error", 42 | "@typescript-eslint/unbound-method": "error" 43 | }, 44 | "env": { 45 | "node": true, 46 | "es6": true, 47 | "jest/globals": true 48 | } 49 | } -------------------------------------------------------------------------------- /src/run.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as github from '@actions/github' 3 | import {Context} from '@actions/github/lib/context' 4 | import {GitHub} from '@actions/github/lib/utils' 5 | import {PullRequestEvent} from '@octokit/webhooks-definitions/schema' 6 | 7 | import {getLabels} from './queries' 8 | import {findLabelByName} from './util' 9 | import {gatherPullRequest, gatherPullRequests} from './pulls' 10 | import {updatePullRequestConflictLabel} from './label' 11 | import {IGitHubLabelNode} from './interfaces' 12 | 13 | export async function run(): Promise { 14 | try { 15 | const conflictLabelName = core.getInput('conflict_label_name', {required: true}) 16 | const myToken = core.getInput('github_token', {required: true}) 17 | 18 | const octokit = github.getOctokit(myToken) 19 | const maxRetries = parseInt(core.getInput('max_retries'), 10) || 1 // Force invalid inputs to a 1 20 | const waitMs = parseInt(core.getInput('wait_ms'), 10) 21 | core.debug(`maxRetries=${maxRetries}; waitMs=${waitMs}`) 22 | 23 | const detectMergeChanges = core.getInput('detect_merge_changes') === 'true' 24 | core.debug(`detectMergeChanges=${detectMergeChanges}`) 25 | 26 | // Get the label to use 27 | const conflictLabel = findLabelByName( 28 | await getLabels(octokit, github.context, conflictLabelName), 29 | conflictLabelName 30 | ) 31 | 32 | if (github.context.eventName === 'pull_request') { 33 | return await runOnPullRequest(octokit, github.context, conflictLabel, waitMs, maxRetries, detectMergeChanges) 34 | } 35 | 36 | await runOnAll(octokit, github.context, conflictLabel, waitMs, maxRetries, detectMergeChanges) 37 | } catch (error) { 38 | core.setFailed(error.message) 39 | } 40 | } 41 | 42 | export async function runOnPullRequest( 43 | octokit: InstanceType, 44 | context: Context, 45 | conflictLabel: IGitHubLabelNode, 46 | waitMs: number, 47 | maxRetries: number, 48 | detectMergeChanges: boolean 49 | ): Promise { 50 | const prEvent = context.payload as PullRequestEvent 51 | core.startGroup(`🔎 Gather data for Pull Request #${prEvent.number}`) 52 | const pr = await gatherPullRequest(octokit, context, prEvent, waitMs, maxRetries) 53 | core.endGroup() 54 | 55 | core.startGroup('🏷️ Updating labels') 56 | await updatePullRequestConflictLabel(octokit, context, pr, conflictLabel, detectMergeChanges) 57 | core.endGroup() 58 | } 59 | 60 | export async function runOnAll( 61 | octokit: InstanceType, 62 | context: Context, 63 | conflictLabel: IGitHubLabelNode, 64 | waitMs: number, 65 | maxRetries: number, 66 | detectMergeChanges: boolean 67 | ): Promise { 68 | core.startGroup('🔎 Gather data for all Pull Requests') 69 | const pullRequests = await gatherPullRequests(octokit, context, waitMs, maxRetries) 70 | core.endGroup() 71 | 72 | core.startGroup('🏷️ Updating labels') 73 | for (const pullRequest of pullRequests) { 74 | await updatePullRequestConflictLabel(octokit, context, pullRequest.node, conflictLabel, detectMergeChanges) 75 | } 76 | core.endGroup() 77 | } 78 | -------------------------------------------------------------------------------- /src/pulls.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import {Context} from '@actions/github/lib/context' 3 | import {GitHub} from '@actions/github/lib/utils' 4 | import {PullRequestEvent} from '@octokit/webhooks-definitions/schema' 5 | 6 | import {IGitHubPRNode, IGitHubPullRequest} from './interfaces' 7 | import {wait} from './wait' 8 | import {getCommitChanges, getPullRequestChanges, getPullRequests, getPullRequest} from './queries' 9 | import {getPullrequestsWithoutMergeStatus} from './util' 10 | 11 | export async function gatherPullRequest( 12 | octokit: InstanceType, 13 | context: Context, 14 | prEvent: PullRequestEvent, 15 | waitMs: number, 16 | maxRetries: number 17 | ): Promise { 18 | let tries = 0 19 | let pullRequest: IGitHubPullRequest 20 | let uknownStatus: boolean = typeof prEvent.pull_request.mergeable !== 'boolean' 21 | 22 | do { 23 | tries++ 24 | 25 | if (uknownStatus) { 26 | // on event trigger we still need to give it time to calc if it was unknown 27 | core.info(`...waiting for mergeable info...`) 28 | await wait(waitMs) 29 | } 30 | 31 | pullRequest = await getPullRequest(octokit, context, prEvent.number) // Always get it since the conversion is non-trivial 32 | uknownStatus = pullRequest.mergeable === 'UNKNOWN' 33 | } while (uknownStatus && maxRetries >= tries) 34 | 35 | if (uknownStatus) { 36 | throw new Error(`Could not determine mergeable status for: #${prEvent.number}`) 37 | } 38 | 39 | return pullRequest 40 | } 41 | 42 | export async function gatherPullRequests( 43 | octokit: InstanceType, 44 | context: Context, 45 | waitMs: number, 46 | maxRetries: number 47 | ): Promise { 48 | let tries = 0 49 | let pullRequests: IGitHubPRNode[] = [] 50 | let pullrequestsWithoutMergeStatus: IGitHubPRNode[] = [] 51 | 52 | do { 53 | tries++ 54 | // if merge status is unknown for any PR, wait a bit and retry 55 | if (pullrequestsWithoutMergeStatus.length > 0) { 56 | core.info(`...waiting for mergeable info...`) 57 | await wait(waitMs) 58 | } 59 | 60 | pullRequests = await getPullRequests(octokit, context) 61 | pullrequestsWithoutMergeStatus = getPullrequestsWithoutMergeStatus(pullRequests) // filter PRs with unknown mergeable status 62 | } while (pullrequestsWithoutMergeStatus.length > 0 && maxRetries >= tries) 63 | 64 | // after $maxRetries we give up, probably GitHub had some issues 65 | if (pullrequestsWithoutMergeStatus.length > 0) { 66 | // Only set failed so that we can proccess the rest of the pull requests the do have mergeable calculated 67 | core.setFailed( 68 | `Could not determine mergeable status for: #${pullrequestsWithoutMergeStatus 69 | .map(pr => { 70 | return pr.node.number 71 | }) 72 | .join(', #')}` 73 | ) 74 | } 75 | 76 | return pullRequests 77 | } 78 | 79 | export const checkPullRequestForMergeChanges = async ( 80 | octokit: InstanceType, 81 | context: Context, 82 | pullRequest: IGitHubPullRequest 83 | ): Promise => { 84 | const prChangedFiles = await getPullRequestChanges(octokit, context, pullRequest.number) 85 | const mergeChangedFiles = await getCommitChanges(octokit, context, pullRequest.potentialMergeCommit.oid) 86 | 87 | if (prChangedFiles.length !== mergeChangedFiles.length) { 88 | core.info(`#${pullRequest.number} has a difference in the number of files`) 89 | return true // I'd be shocked if it was not! 90 | } 91 | 92 | // TODO: There's an assumption the files list should always be ordered the same which needs to be verified. 93 | for (let i = 0; i < prChangedFiles.length; i++) { 94 | if (prChangedFiles[i].sha !== mergeChangedFiles[i].sha) { 95 | core.info(`#${pullRequest.number} has a mismatching SHA's`) 96 | return true 97 | } 98 | } 99 | 100 | return false 101 | } 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Label Pull Requests with Merge Conflicts Automatically 2 | 3 | [![MIT](https://img.shields.io/github/license/prince-chrismc/label-merge-conflicts-action)](https://github.com/prince-chrismc/label-merge-conflicts-action/blob/main/LICENSE) 4 | [![codecov](https://img.shields.io/codecov/c/github/prince-chrismc/label-merge-conflicts-action)](https://codecov.io/gh/prince-chrismc/label-merge-conflicts-action) 5 | 6 | ## Purpose 7 | 8 | This action _intuitively_ checks open pull request(s) for merge conflicts and marks them with a [label](https://guides.github.com/features/issues/#filtering). 9 | 10 | ![comic](https://github.com/prince-chrismc/label-merge-conflicts-action/blob/main/.github/label-merge-conflicts.png?raw=true) 11 | 12 | > Work by [Geek & Poke: Being A Coder Made Easy](https://geek-and-poke.com/geekandpoke/2010/10/21/being-a-code-made-easy-chapter-1.html) ([CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)) just shorter. 13 | 14 | ## Add it to your Project 15 | 16 | ### Create a Label 17 | 18 | You'll need to manually create a label through GitHub. This can be done through the UI if you so with. 19 | 20 | ### Setup a Workflow 21 | 22 | ```yml 23 | name: Auto Label Conflicts 24 | on: 25 | push: 26 | branches: [master] 27 | pull_request: 28 | branches: [master] 29 | 30 | permissions: # Optional: minimum permission required to add labels 31 | issues: write 32 | pull-requests: write 33 | 34 | jobs: 35 | auto-label: 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: prince-chrismc/label-merge-conflicts-action@v1 39 | with: 40 | conflict_label_name: "has conflict" 41 | github_token: ${{ secrets.GITHUB_TOKEN }} 42 | # These are optional incase you need to adjust for the limitations described below 43 | max_retries: 5 44 | wait_ms: 15000 45 | detect_merge_changes: false # or true to handle as conflicts 46 | ``` 47 | 48 | ## Limitations 49 | 50 | 1. GitHub does not reliably compute the `mergeable` status which is used by this action to detect merge conflicts. 51 | * If `main` changes the mergeable status is unknown until someone (most likely this action) requests it. 52 | [GitHub then tries to compute the status with an async job.](https://stackoverflow.com/a/30620973) 53 | * This is usually quick and simple, but there are no guarantees and GitHub might have issues. You can tweak `max_retries` and `wait_ms` to increase the timeout before giving up on a Pull Request. 54 | 2. GitHub does not run actions on pull requests which have conflicts 55 | * When there is a conflict it prevents the merge commit from being calculated. [See this thread](https://github.community/t/run-actions-on-pull-requests-with-merge-conflicts/17104). 56 | * This is required for the [`mergeable`](https://docs.github.com/en/graphql/reference/enums#mergeablestate) as per the [API documentation](https://docs.github.com/en/rest/reference/pulls#get-a-pull-request) 57 | 58 | ## FAQ - What are _Merge Changes_? 59 | 60 | When [merging a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges), no matter the 61 | [strategy](https://git-scm.com/docs/merge-strategies), there may _inadvertently be changes_ (i.e 62 | [git blobs](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects) which over lap and need to be recombined) which can have negative side effects. For example... 63 | 64 | > I was working on an app with a friend and [...] I ran `git pull`. There were no merge conflicts, but _git added duplicate functions_ to a file after merge. 65 | > I spent an hour trying to figure our what the problem was before realizing that **git had made a mistake** while merging. 66 | > [ref](https://news.ycombinator.com/item?id=9871042) 67 | 68 | ## FAQ - How do I fix _"Resource not accessible by integration"_? 69 | 70 | > ℹ️ _This is a rapidly changing topic_. Feel free to [open an issue](https://github.com/prince-chrismc/label-merge-conflicts-action/issues/new?title=Question:%20Permissions&labels=help%20wanted) if there's any problems. 71 | 72 | If a user without write access opens a 'Pull Request' from their fork then GitHub will not be granted adequate permissions to set the labels 73 | [details here](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/#setting-permissions-in-the-workflow). 74 | Hence the _not accessible_ error. Try the following steps: 75 | 76 | - using the ([potentially dangerous](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)) event `pull_request_target` 77 | - setting the [workflow permissions](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) provided in the 78 | [example](#setup-a-workflow). 79 | 80 | It boils down to the GitHub Action's permissions current behavoir. 81 | The [default permissions](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token) for any 82 | [event type](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) is 83 | [`read` only](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token). The default can be 84 | [adjusted for the repository](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository) or 85 | [set for each workflow](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) explicitly. However, as per the documentation... 86 | 87 | > Pull requests from public forks are still considered a special case and will receive a read token regardless of these settings. 88 | 89 | See [actions/labeler#12](https://github.com/actions/labeler/issues/12), [actions/first-interaction#10](https://github.com/actions/first-interaction/issues/10), and [Actions are severely limited](https://github.community/t/github-actions-are-severely-limited-on-prs/18179#M9249) for more information and some history on the issue. 90 | -------------------------------------------------------------------------------- /src/queries.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import * as core from '@actions/core' 3 | import {Context} from '@actions/github/lib/context' 4 | import {GitHub} from '@actions/github/lib/utils' 5 | import { 6 | IGitHubPRNode, 7 | IGitHubRepoLabels, 8 | IGitHubRepoPullRequests, 9 | IGitHubFileChange, 10 | IGitHubRepoPullRequest, 11 | IGitHubPullRequest 12 | } from './interfaces' 13 | 14 | const getPullRequestPages = async ( 15 | octokit: InstanceType, 16 | context: Context, 17 | cursor?: string 18 | ): Promise => { 19 | const query = `query ($owner: String!, $repo: String!, $after: String) { 20 | repository(owner:$owner name:$repo) { 21 | pullRequests(first: 100, states: OPEN, after: $after) { 22 | edges { 23 | node { 24 | id 25 | number 26 | author { 27 | login 28 | } 29 | mergeable 30 | potentialMergeCommit { 31 | oid 32 | } 33 | labels(first: 100) { 34 | edges { 35 | node { 36 | id 37 | name 38 | } 39 | } 40 | } 41 | } 42 | } 43 | pageInfo { 44 | endCursor 45 | hasNextPage 46 | } 47 | } 48 | } 49 | }` 50 | 51 | return octokit.graphql(query, { 52 | ...context.repo, 53 | after: cursor 54 | }) 55 | } 56 | 57 | // fetch all PRs 58 | export const getPullRequests = async ( 59 | octokit: InstanceType, 60 | context: Context 61 | ): Promise => { 62 | let pullrequests: IGitHubPRNode[] = [] 63 | let cursor: string | undefined 64 | let hasNextPage = false 65 | 66 | do { 67 | const pullrequestData = await getPullRequestPages(octokit, context, cursor) 68 | 69 | pullrequests = pullrequests.concat(pullrequestData.repository.pullRequests.edges) 70 | cursor = pullrequestData.repository.pullRequests.pageInfo.endCursor 71 | hasNextPage = pullrequestData.repository.pullRequests.pageInfo.hasNextPage 72 | } while (hasNextPage) 73 | 74 | return pullrequests 75 | } 76 | 77 | export const getPullRequest = async ( 78 | octokit: InstanceType, 79 | context: Context, 80 | number: number 81 | ): Promise => { 82 | const query = `query ($owner: String!, $repo: String!, $number: Int!) { 83 | repository(owner: $owner name: $repo) { 84 | pullRequest(number: $number) { 85 | id 86 | number 87 | author { 88 | login 89 | } 90 | mergeable 91 | potentialMergeCommit { 92 | oid 93 | } 94 | labels(first: 100) { 95 | edges { 96 | node { 97 | id 98 | name 99 | } 100 | } 101 | } 102 | } 103 | } 104 | }` 105 | 106 | const repoPr: IGitHubRepoPullRequest = await octokit.graphql(query, { 107 | ...context.repo, 108 | number 109 | }) 110 | 111 | return repoPr.repository.pullRequest 112 | } 113 | 114 | export const getLabels = async ( 115 | octokit: InstanceType, 116 | context: Context, 117 | labelName: string 118 | ): Promise => { 119 | const query = `query ($owner: String!, $repo: String!, $labelName: String!) { 120 | repository(owner: $owner name: $repo) { 121 | labels(first: 10, query: $labelName) { 122 | edges { 123 | node { 124 | id 125 | name 126 | } 127 | } 128 | } 129 | } 130 | }` 131 | 132 | return octokit.graphql(query, { 133 | ...context.repo, 134 | labelName 135 | }) 136 | } 137 | 138 | export const addLabelToLabelable = async ( 139 | octokit: InstanceType, 140 | { 141 | labelId, 142 | labelableId 143 | }: { 144 | labelId: string 145 | labelableId: string 146 | }, 147 | pullRequestNumber: number, 148 | pullRequestAuthor: string, 149 | context: Context 150 | ) => { 151 | const slackWebhookUrl = core.getInput('slack_webhook_url', {required: true}) 152 | const slackWebhookChannel = core.getInput('slack_webhook_channel', {required: true}) 153 | const {owner, repo} = context.repo 154 | const slackMessage = 155 | pullRequestAuthor === 'githubys' 156 | ? `There's a *backmerge* conflict on (${repo}). Please fix it before it lands on the release mgmt process.` 157 | : `There's a conflict on (${repo}). If you are the author (@${pullRequestAuthor}), please fix it.` 158 | const pullMessage = 159 | pullRequestAuthor === 'githubys' 160 | ? `:warning: There is a backmerge conflict on this PR. Please fix it before it lands on the release mgmt process.` 161 | : `:warning: There is a conflict on this PR. @${pullRequestAuthor} as you are the author, please fix it.` 162 | 163 | const query = `mutation ($label: String!, $pullRequest: String!) { 164 | addLabelsToLabelable(input: {labelIds: [$label], labelableId: $pullRequest}) { 165 | clientMutationId 166 | } 167 | }` 168 | const addComment = `mutation comment($id: ID!, $body: String!) { 169 | addComment(input: {subjectId: $id, body: $body}) { 170 | clientMutationId 171 | } 172 | } 173 | ` 174 | 175 | await axios.post(slackWebhookUrl, { 176 | channel: slackWebhookChannel, 177 | text: slackMessage, 178 | username: 'PR Conflicts Bot', 179 | // eslint-disable-next-line camelcase 180 | icon_emoji: ':warning:' 181 | }) 182 | 183 | await octokit.graphql(query, {label: labelId, pullRequest: labelableId}) 184 | 185 | return octokit.graphql(addComment, { 186 | id: labelableId, 187 | body: pullMessage 188 | }) 189 | } 190 | 191 | export const removeLabelFromLabelable = async ( 192 | octokit: InstanceType, 193 | { 194 | labelId, 195 | labelableId 196 | }: { 197 | labelId: string 198 | labelableId: string 199 | } 200 | ) => { 201 | const query = `mutation ($label: String!, $pullRequest: String!) { 202 | removeLabelsFromLabelable(input: {labelIds: [$label], labelableId: $pullRequest}) { 203 | clientMutationId 204 | } 205 | }` 206 | 207 | return octokit.graphql(query, {label: labelId, pullRequest: labelableId}) 208 | } 209 | 210 | export const getPullRequestChanges = async ( 211 | octokit: InstanceType, 212 | context: Context, 213 | pullRequestnumber: number 214 | ): Promise => { 215 | const head = await octokit.rest.pulls.listFiles({ 216 | ...context.repo, 217 | pull_number: pullRequestnumber, // eslint-disable-line camelcase 218 | /** 219 | * This is correct the different default values which on larger pull requests is an issue. 220 | * There is no pagination support. 221 | * 222 | * https://docs.github.com/en/rest/reference/pulls#list-pull-requests-files 223 | * > Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default. 224 | * 225 | * https://docs.github.com/en/rest/reference/repos#get-a-commit 226 | * > If there are more than 300 files in the commit diff, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. 227 | */ 228 | per_page: 300 // eslint-disable-line camelcase 229 | }) 230 | 231 | return head.data 232 | } 233 | 234 | export const getCommitChanges = async ( 235 | octokit: InstanceType, 236 | context: Context, 237 | sha: string 238 | ): Promise => { 239 | const mergeCommit = await octokit.rest.repos.getCommit({ 240 | ...context.repo, 241 | ref: sha 242 | }) 243 | 244 | if (typeof mergeCommit.data.files === 'undefined') { 245 | throw new Error(`merge commit with an unknown diff!`) 246 | } 247 | 248 | return mergeCommit.data.files as IGitHubFileChange[] 249 | } 250 | -------------------------------------------------------------------------------- /dist/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | module.exports=(()=>{var e={650:e=>{var r=Object.prototype.toString;var n=typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},645:(e,r,n)=>{n(284).install()},284:(e,r,n)=>{var t=n(596).SourceMapConsumer;var o=n(622);var i;try{i=n(747);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var u=n(650);var s=false;var a=false;var l=false;var c="auto";var f={};var p={};var g=/^data:application\/json[^,]+base64,/;var h=[];var d=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function handlerExec(e){return function(r){for(var n=0;n"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var u=true;var s=this.isConstructor();var a=!(this.isToplevel()||s);if(a){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"")}}else if(s){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;u=false}if(u){o+=" ("+r+")"}return o}function cloneCallSite(e){var r={};Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(function(n){r[n]=/^(?:is|get)/.test(n)?function(){return e[n].call(e)}:e[n]});r.toString=CallSiteToString;return r}function wrapCallSite(e){if(e.isNative()){return e}var r=e.getFileName()||e.getScriptNameOrSourceURL();if(r){var n=e.getLineNumber();var t=e.getColumnNumber()-1;var o=62;if(n===1&&t>o&&!isInBrowser()&&!e.isEval()){t-=o}var i=mapSourcePosition({source:r,line:n,column:t});e=cloneCallSite(e);var u=e.getFunctionName;e.getFunctionName=function(){return i.name||u()};e.getFileName=function(){return i.source};e.getLineNumber=function(){return i.line};e.getColumnNumber=function(){return i.column+1};e.getScriptNameOrSourceURL=function(){return i.source};return e}var s=e.isEval()&&e.getEvalOrigin();if(s){s=mapEvalOrigin(s);e=cloneCallSite(e);e.getEvalOrigin=function(){return s};return e}return e}function prepareStackTrace(e,r){if(l){f={};p={}}return e+r.map(function(e){return"\n at "+wrapCallSite(e)}).join("")}function getErrorSource(e){var r=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(e.stack);if(r){var n=r[1];var t=+r[2];var o=+r[3];var u=f[n];if(!u&&i&&i.existsSync(n)){try{u=i.readFileSync(n,"utf8")}catch(e){u=""}}if(u){var s=u.split(/(?:\r\n|\r|\n)/)[t-1];if(s){return n+":"+t+"\n"+s+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);if(process.stderr._handle&&process.stderr._handle.setBlocking){process.stderr._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);process.exit(1)}function shimEmitUncaughtException(){var e=process.emit;process.emit=function(r){if(r==="uncaughtException"){var n=arguments[1]&&arguments[1].stack;var t=this.listeners(r).length>0;if(n&&!t){return printErrorAndExit(arguments[1])}}return e.apply(this,arguments)}}var S=h.slice(0);var m=d.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=_;r.install=function(e){e=e||{};if(e.environment){c=e.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(e.retrieveFile){if(e.overrideRetrieveFile){h.length=0}h.unshift(e.retrieveFile)}if(e.retrieveSourceMap){if(e.overrideRetrieveSourceMap){d.length=0}d.unshift(e.retrieveSourceMap)}if(e.hookRequire&&!isInBrowser()){var r;try{r=n(282)}catch(e){}var t=r.prototype._compile;if(!t.__sourceMapSupport){r.prototype._compile=function(e,r){f[r]=e;p[r]=undefined;return t.call(this,e,r)};r.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in e?e.emptyCacheBetweenOperations:false}if(!s){s=true;Error.prepareStackTrace=prepareStackTrace}if(!a){var o="handleUncaughtExceptions"in e?e.handleUncaughtExceptions:true;if(o&&hasGlobalProcessEventEmitter()){a=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){h.length=0;d.length=0;h=S.slice(0);d=m.slice(0)}},837:(e,r,n)=>{var t=n(983);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(537);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&u;i>>>=o;if(i>0){n|=s}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var a=0;var l=0;var c,f;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}f=t.decode(e.charCodeAt(r++));if(f===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(f&s);f&=u;a=a+(f<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,u){var s=Math.floor((n-e)/2)+e;var a=i(t,o[s],true);if(a===0){return s}else if(a>0){if(n-s>1){return recursiveSearch(s,n,t,o,i,u)}if(u==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,s,t,o,i,u)}if(u==r.LEAST_UPPER_BOUND){return s}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},740:(e,r,n)=>{var t=n(983);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var u=r.generatedColumn;return o>n||o==n&&u>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.H=MappingList},226:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(983);var i=n(164);var u=n(837).I;var s=n(215);var a=n(226).U;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var u;switch(i){case SourceMapConsumer.GENERATED_ORDER:u=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:u=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var s=this.sourceRoot;u.map(function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(s,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}},this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var u=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(u>=0){var s=this._originalMappings[u];if(e.column===undefined){var a=s.originalLine;while(s&&s.originalLine===a){t.push({line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:o.getArg(s,"lastGeneratedColumn",null)});s=this._originalMappings[++u]}}else{var l=s.originalColumn;while(s&&s.originalLine===r&&s.originalColumn==l){t.push({line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:o.getArg(s,"lastGeneratedColumn",null)});s=this._originalMappings[++u]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var s=o.getArg(n,"names",[]);var a=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var f=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(a){a=o.normalize(a)}i=i.map(String).map(o.normalize).map(function(e){return a&&o.isAbsolute(a)&&o.isAbsolute(e)?o.relative(a,e):e});this._names=u.fromArray(s.map(String),true);this._sources=u.fromArray(i,true);this._absoluteSources=this._sources.toArray().map(function(e){return o.computeSourceURL(a,e,r)});this.sourceRoot=a;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=f}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){_.source=l+m[1];l+=m[1];_.originalLine=i+m[2];i=_.originalLine;_.originalLine+=1;_.originalColumn=u+m[3];u=_.originalColumn;if(m.length>4){_.name=c+m[4];c+=m[4]}}v.push(_);if(typeof _.originalLine==="number"){d.push(_)}}}a(v,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=v;a(d,o.compareByOriginalPositions);this.__originalMappings=d};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,u){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,u)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var u=o.getArg(t,"name",null);if(u!==null){u=this._names.at(u)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:u}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return e==null})};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var u=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(u)){return this.sourcesContent[this._sources.indexOf(u)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new u;this._names=new u;var s={line:-1,column:0};this._sections=i.map(function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(215);var o=n(983);var i=n(837).I;var u=n(740).H;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new u;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping(function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)});e.sources.forEach(function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var u=e.sourceContentFor(t);if(u!=null){n.setSourceContent(t,u)}});return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var u=this._sourceRoot;if(u!=null){t=o.relative(u,t)}var s=new i;var a=new i;this._mappings.unsortedForEach(function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(u!=null){r.source=o.relative(u,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!s.has(l)){s.add(l)}var c=r.name;if(c!=null&&!a.has(c)){a.add(c)}},this);this._sources=s;this._names=a;e.sources.forEach(function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(u!=null){r=o.relative(u,r)}this.setSourceContent(r,t)}},this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var u=0;var s=0;var a="";var l;var c;var f;var p;var g=this._mappings.toArray();for(var h=0,d=g.length;h0){if(!o.compareByGeneratedPositionsInflated(c,g[h-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){p=this._sources.indexOf(c.source);l+=t.encode(p-s);s=p;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){f=this._names.indexOf(c.name);l+=t.encode(f-u);u=f}}a+=l}return a};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map(function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.h=SourceMapGenerator},990:(e,r,n)=>{var t;var o=n(341).h;var i=n(983);var u=/(\r?\n)/;var s=10;var a="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[a]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(u);var s=0;var a=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return s=0;r--){this.prepend(e[r])}}else if(e[a]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var u,s=0,a=i.length-1;a>=0;a--){u=i[a];if(u==="."){i.splice(a,1)}else if(u===".."){s++}else if(s>0){if(u===""){i.splice(a+1,s);s=0}else{i.splice(a,2);s--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL},596:(e,r,n)=>{n(341).h;r.SourceMapConsumer=n(327).SourceMapConsumer;n(990)},747:e=>{"use strict";e.exports=require("fs")},282:e=>{"use strict";e.exports=require("module")},622:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){if(r[n]){return r[n].exports}var t=r[n]={exports:{}};var o=true;try{e[n](t,t.exports,__webpack_require__);o=false}finally{if(o)delete r[n]}return t.exports}__webpack_require__.ab=__dirname+"/";return __webpack_require__(645)})(); -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | 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: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | 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. 12 | 13 | @actions/github 14 | MIT 15 | The MIT License (MIT) 16 | 17 | Copyright 2019 GitHub 18 | 19 | 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: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | 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. 24 | 25 | @actions/http-client 26 | MIT 27 | Actions Http Client for Node.js 28 | 29 | Copyright (c) GitHub, Inc. 30 | 31 | All rights reserved. 32 | 33 | MIT License 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 36 | associated documentation files (the "Software"), to deal in the Software without restriction, 37 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 38 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 39 | subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 44 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 45 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 47 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | 50 | @octokit/auth-token 51 | MIT 52 | The MIT License 53 | 54 | Copyright (c) 2019 Octokit contributors 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a copy 57 | of this software and associated documentation files (the "Software"), to deal 58 | in the Software without restriction, including without limitation the rights 59 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 60 | copies of the Software, and to permit persons to whom the Software is 61 | furnished to do so, subject to the following conditions: 62 | 63 | The above copyright notice and this permission notice shall be included in 64 | all copies or substantial portions of the Software. 65 | 66 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 67 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 68 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 69 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 70 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 71 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 72 | THE SOFTWARE. 73 | 74 | 75 | @octokit/core 76 | MIT 77 | The MIT License 78 | 79 | Copyright (c) 2019 Octokit contributors 80 | 81 | Permission is hereby granted, free of charge, to any person obtaining a copy 82 | of this software and associated documentation files (the "Software"), to deal 83 | in the Software without restriction, including without limitation the rights 84 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 85 | copies of the Software, and to permit persons to whom the Software is 86 | furnished to do so, subject to the following conditions: 87 | 88 | The above copyright notice and this permission notice shall be included in 89 | all copies or substantial portions of the Software. 90 | 91 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 92 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 93 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 94 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 95 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 96 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 97 | THE SOFTWARE. 98 | 99 | 100 | @octokit/endpoint 101 | MIT 102 | The MIT License 103 | 104 | Copyright (c) 2018 Octokit contributors 105 | 106 | Permission is hereby granted, free of charge, to any person obtaining a copy 107 | of this software and associated documentation files (the "Software"), to deal 108 | in the Software without restriction, including without limitation the rights 109 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 110 | copies of the Software, and to permit persons to whom the Software is 111 | furnished to do so, subject to the following conditions: 112 | 113 | The above copyright notice and this permission notice shall be included in 114 | all copies or substantial portions of the Software. 115 | 116 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 117 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 118 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 119 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 120 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 121 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 122 | THE SOFTWARE. 123 | 124 | 125 | @octokit/graphql 126 | MIT 127 | The MIT License 128 | 129 | Copyright (c) 2018 Octokit contributors 130 | 131 | Permission is hereby granted, free of charge, to any person obtaining a copy 132 | of this software and associated documentation files (the "Software"), to deal 133 | in the Software without restriction, including without limitation the rights 134 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 135 | copies of the Software, and to permit persons to whom the Software is 136 | furnished to do so, subject to the following conditions: 137 | 138 | The above copyright notice and this permission notice shall be included in 139 | all copies or substantial portions of the Software. 140 | 141 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 142 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 143 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 144 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 145 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 146 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 147 | THE SOFTWARE. 148 | 149 | 150 | @octokit/plugin-paginate-rest 151 | MIT 152 | MIT License Copyright (c) 2019 Octokit contributors 153 | 154 | 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: 155 | 156 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 157 | 158 | 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. 159 | 160 | 161 | @octokit/plugin-rest-endpoint-methods 162 | MIT 163 | MIT License Copyright (c) 2019 Octokit contributors 164 | 165 | 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: 166 | 167 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 168 | 169 | 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. 170 | 171 | 172 | @octokit/request 173 | MIT 174 | The MIT License 175 | 176 | Copyright (c) 2018 Octokit contributors 177 | 178 | Permission is hereby granted, free of charge, to any person obtaining a copy 179 | of this software and associated documentation files (the "Software"), to deal 180 | in the Software without restriction, including without limitation the rights 181 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 182 | copies of the Software, and to permit persons to whom the Software is 183 | furnished to do so, subject to the following conditions: 184 | 185 | The above copyright notice and this permission notice shall be included in 186 | all copies or substantial portions of the Software. 187 | 188 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 189 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 190 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 191 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 192 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 193 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 194 | THE SOFTWARE. 195 | 196 | 197 | @octokit/request-error 198 | MIT 199 | The MIT License 200 | 201 | Copyright (c) 2019 Octokit contributors 202 | 203 | Permission is hereby granted, free of charge, to any person obtaining a copy 204 | of this software and associated documentation files (the "Software"), to deal 205 | in the Software without restriction, including without limitation the rights 206 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 207 | copies of the Software, and to permit persons to whom the Software is 208 | furnished to do so, subject to the following conditions: 209 | 210 | The above copyright notice and this permission notice shall be included in 211 | all copies or substantial portions of the Software. 212 | 213 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 214 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 215 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 216 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 217 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 218 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 219 | THE SOFTWARE. 220 | 221 | 222 | @vercel/ncc 223 | MIT 224 | Copyright 2018 ZEIT, Inc. 225 | 226 | 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: 227 | 228 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 229 | 230 | 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. 231 | 232 | axios 233 | MIT 234 | Copyright (c) 2014-present Matt Zabriskie 235 | 236 | Permission is hereby granted, free of charge, to any person obtaining a copy 237 | of this software and associated documentation files (the "Software"), to deal 238 | in the Software without restriction, including without limitation the rights 239 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 240 | copies of the Software, and to permit persons to whom the Software is 241 | furnished to do so, subject to the following conditions: 242 | 243 | The above copyright notice and this permission notice shall be included in 244 | all copies or substantial portions of the Software. 245 | 246 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 247 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 248 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 249 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 250 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 251 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 252 | THE SOFTWARE. 253 | 254 | 255 | before-after-hook 256 | Apache-2.0 257 | Apache License 258 | Version 2.0, January 2004 259 | http://www.apache.org/licenses/ 260 | 261 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 262 | 263 | 1. Definitions. 264 | 265 | "License" shall mean the terms and conditions for use, reproduction, 266 | and distribution as defined by Sections 1 through 9 of this document. 267 | 268 | "Licensor" shall mean the copyright owner or entity authorized by 269 | the copyright owner that is granting the License. 270 | 271 | "Legal Entity" shall mean the union of the acting entity and all 272 | other entities that control, are controlled by, or are under common 273 | control with that entity. For the purposes of this definition, 274 | "control" means (i) the power, direct or indirect, to cause the 275 | direction or management of such entity, whether by contract or 276 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 277 | outstanding shares, or (iii) beneficial ownership of such entity. 278 | 279 | "You" (or "Your") shall mean an individual or Legal Entity 280 | exercising permissions granted by this License. 281 | 282 | "Source" form shall mean the preferred form for making modifications, 283 | including but not limited to software source code, documentation 284 | source, and configuration files. 285 | 286 | "Object" form shall mean any form resulting from mechanical 287 | transformation or translation of a Source form, including but 288 | not limited to compiled object code, generated documentation, 289 | and conversions to other media types. 290 | 291 | "Work" shall mean the work of authorship, whether in Source or 292 | Object form, made available under the License, as indicated by a 293 | copyright notice that is included in or attached to the work 294 | (an example is provided in the Appendix below). 295 | 296 | "Derivative Works" shall mean any work, whether in Source or Object 297 | form, that is based on (or derived from) the Work and for which the 298 | editorial revisions, annotations, elaborations, or other modifications 299 | represent, as a whole, an original work of authorship. For the purposes 300 | of this License, Derivative Works shall not include works that remain 301 | separable from, or merely link (or bind by name) to the interfaces of, 302 | the Work and Derivative Works thereof. 303 | 304 | "Contribution" shall mean any work of authorship, including 305 | the original version of the Work and any modifications or additions 306 | to that Work or Derivative Works thereof, that is intentionally 307 | submitted to Licensor for inclusion in the Work by the copyright owner 308 | or by an individual or Legal Entity authorized to submit on behalf of 309 | the copyright owner. For the purposes of this definition, "submitted" 310 | means any form of electronic, verbal, or written communication sent 311 | to the Licensor or its representatives, including but not limited to 312 | communication on electronic mailing lists, source code control systems, 313 | and issue tracking systems that are managed by, or on behalf of, the 314 | Licensor for the purpose of discussing and improving the Work, but 315 | excluding communication that is conspicuously marked or otherwise 316 | designated in writing by the copyright owner as "Not a Contribution." 317 | 318 | "Contributor" shall mean Licensor and any individual or Legal Entity 319 | on behalf of whom a Contribution has been received by Licensor and 320 | subsequently incorporated within the Work. 321 | 322 | 2. Grant of Copyright License. Subject to the terms and conditions of 323 | this License, each Contributor hereby grants to You a perpetual, 324 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 325 | copyright license to reproduce, prepare Derivative Works of, 326 | publicly display, publicly perform, sublicense, and distribute the 327 | Work and such Derivative Works in Source or Object form. 328 | 329 | 3. Grant of Patent License. Subject to the terms and conditions of 330 | this License, each Contributor hereby grants to You a perpetual, 331 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 332 | (except as stated in this section) patent license to make, have made, 333 | use, offer to sell, sell, import, and otherwise transfer the Work, 334 | where such license applies only to those patent claims licensable 335 | by such Contributor that are necessarily infringed by their 336 | Contribution(s) alone or by combination of their Contribution(s) 337 | with the Work to which such Contribution(s) was submitted. If You 338 | institute patent litigation against any entity (including a 339 | cross-claim or counterclaim in a lawsuit) alleging that the Work 340 | or a Contribution incorporated within the Work constitutes direct 341 | or contributory patent infringement, then any patent licenses 342 | granted to You under this License for that Work shall terminate 343 | as of the date such litigation is filed. 344 | 345 | 4. Redistribution. You may reproduce and distribute copies of the 346 | Work or Derivative Works thereof in any medium, with or without 347 | modifications, and in Source or Object form, provided that You 348 | meet the following conditions: 349 | 350 | (a) You must give any other recipients of the Work or 351 | Derivative Works a copy of this License; and 352 | 353 | (b) You must cause any modified files to carry prominent notices 354 | stating that You changed the files; and 355 | 356 | (c) You must retain, in the Source form of any Derivative Works 357 | that You distribute, all copyright, patent, trademark, and 358 | attribution notices from the Source form of the Work, 359 | excluding those notices that do not pertain to any part of 360 | the Derivative Works; and 361 | 362 | (d) If the Work includes a "NOTICE" text file as part of its 363 | distribution, then any Derivative Works that You distribute must 364 | include a readable copy of the attribution notices contained 365 | within such NOTICE file, excluding those notices that do not 366 | pertain to any part of the Derivative Works, in at least one 367 | of the following places: within a NOTICE text file distributed 368 | as part of the Derivative Works; within the Source form or 369 | documentation, if provided along with the Derivative Works; or, 370 | within a display generated by the Derivative Works, if and 371 | wherever such third-party notices normally appear. The contents 372 | of the NOTICE file are for informational purposes only and 373 | do not modify the License. You may add Your own attribution 374 | notices within Derivative Works that You distribute, alongside 375 | or as an addendum to the NOTICE text from the Work, provided 376 | that such additional attribution notices cannot be construed 377 | as modifying the License. 378 | 379 | You may add Your own copyright statement to Your modifications and 380 | may provide additional or different license terms and conditions 381 | for use, reproduction, or distribution of Your modifications, or 382 | for any such Derivative Works as a whole, provided Your use, 383 | reproduction, and distribution of the Work otherwise complies with 384 | the conditions stated in this License. 385 | 386 | 5. Submission of Contributions. Unless You explicitly state otherwise, 387 | any Contribution intentionally submitted for inclusion in the Work 388 | by You to the Licensor shall be under the terms and conditions of 389 | this License, without any additional terms or conditions. 390 | Notwithstanding the above, nothing herein shall supersede or modify 391 | the terms of any separate license agreement you may have executed 392 | with Licensor regarding such Contributions. 393 | 394 | 6. Trademarks. This License does not grant permission to use the trade 395 | names, trademarks, service marks, or product names of the Licensor, 396 | except as required for reasonable and customary use in describing the 397 | origin of the Work and reproducing the content of the NOTICE file. 398 | 399 | 7. Disclaimer of Warranty. Unless required by applicable law or 400 | agreed to in writing, Licensor provides the Work (and each 401 | Contributor provides its Contributions) on an "AS IS" BASIS, 402 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 403 | implied, including, without limitation, any warranties or conditions 404 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 405 | PARTICULAR PURPOSE. You are solely responsible for determining the 406 | appropriateness of using or redistributing the Work and assume any 407 | risks associated with Your exercise of permissions under this License. 408 | 409 | 8. Limitation of Liability. In no event and under no legal theory, 410 | whether in tort (including negligence), contract, or otherwise, 411 | unless required by applicable law (such as deliberate and grossly 412 | negligent acts) or agreed to in writing, shall any Contributor be 413 | liable to You for damages, including any direct, indirect, special, 414 | incidental, or consequential damages of any character arising as a 415 | result of this License or out of the use or inability to use the 416 | Work (including but not limited to damages for loss of goodwill, 417 | work stoppage, computer failure or malfunction, or any and all 418 | other commercial damages or losses), even if such Contributor 419 | has been advised of the possibility of such damages. 420 | 421 | 9. Accepting Warranty or Additional Liability. While redistributing 422 | the Work or Derivative Works thereof, You may choose to offer, 423 | and charge a fee for, acceptance of support, warranty, indemnity, 424 | or other liability obligations and/or rights consistent with this 425 | License. However, in accepting such obligations, You may act only 426 | on Your own behalf and on Your sole responsibility, not on behalf 427 | of any other Contributor, and only if You agree to indemnify, 428 | defend, and hold each Contributor harmless for any liability 429 | incurred by, or claims asserted against, such Contributor by reason 430 | of your accepting any such warranty or additional liability. 431 | 432 | END OF TERMS AND CONDITIONS 433 | 434 | APPENDIX: How to apply the Apache License to your work. 435 | 436 | To apply the Apache License to your work, attach the following 437 | boilerplate notice, with the fields enclosed by brackets "{}" 438 | replaced with your own identifying information. (Don't include 439 | the brackets!) The text should be enclosed in the appropriate 440 | comment syntax for the file format. We also recommend that a 441 | file or class name and description of purpose be included on the 442 | same "printed page" as the copyright notice for easier 443 | identification within third-party archives. 444 | 445 | Copyright 2018 Gregor Martynus and other contributors. 446 | 447 | Licensed under the Apache License, Version 2.0 (the "License"); 448 | you may not use this file except in compliance with the License. 449 | You may obtain a copy of the License at 450 | 451 | http://www.apache.org/licenses/LICENSE-2.0 452 | 453 | Unless required by applicable law or agreed to in writing, software 454 | distributed under the License is distributed on an "AS IS" BASIS, 455 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 456 | See the License for the specific language governing permissions and 457 | limitations under the License. 458 | 459 | 460 | debug 461 | MIT 462 | (The MIT License) 463 | 464 | Copyright (c) 2014 TJ Holowaychuk 465 | 466 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 467 | and associated documentation files (the 'Software'), to deal in the Software without restriction, 468 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 469 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 470 | subject to the following conditions: 471 | 472 | The above copyright notice and this permission notice shall be included in all copies or substantial 473 | portions of the Software. 474 | 475 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 476 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 477 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 478 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 479 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 480 | 481 | 482 | 483 | deprecation 484 | ISC 485 | The ISC License 486 | 487 | Copyright (c) Gregor Martynus and contributors 488 | 489 | Permission to use, copy, modify, and/or distribute this software for any 490 | purpose with or without fee is hereby granted, provided that the above 491 | copyright notice and this permission notice appear in all copies. 492 | 493 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 494 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 495 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 496 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 497 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 498 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 499 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 500 | 501 | 502 | follow-redirects 503 | MIT 504 | Copyright 2014–present Olivier Lalonde , James Talmage , Ruben Verborgh 505 | 506 | Permission is hereby granted, free of charge, to any person obtaining a copy of 507 | this software and associated documentation files (the "Software"), to deal in 508 | the Software without restriction, including without limitation the rights to 509 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 510 | of the Software, and to permit persons to whom the Software is furnished to do 511 | so, subject to the following conditions: 512 | 513 | The above copyright notice and this permission notice shall be included in all 514 | copies or substantial portions of the Software. 515 | 516 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 517 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 518 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 519 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 520 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 521 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 522 | 523 | 524 | has-flag 525 | MIT 526 | MIT License 527 | 528 | Copyright (c) Sindre Sorhus (sindresorhus.com) 529 | 530 | 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: 531 | 532 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 533 | 534 | 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. 535 | 536 | 537 | is-plain-object 538 | MIT 539 | The MIT License (MIT) 540 | 541 | Copyright (c) 2014-2017, Jon Schlinkert. 542 | 543 | Permission is hereby granted, free of charge, to any person obtaining a copy 544 | of this software and associated documentation files (the "Software"), to deal 545 | in the Software without restriction, including without limitation the rights 546 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 547 | copies of the Software, and to permit persons to whom the Software is 548 | furnished to do so, subject to the following conditions: 549 | 550 | The above copyright notice and this permission notice shall be included in 551 | all copies or substantial portions of the Software. 552 | 553 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 554 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 555 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 556 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 557 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 558 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 559 | THE SOFTWARE. 560 | 561 | 562 | ms 563 | MIT 564 | The MIT License (MIT) 565 | 566 | Copyright (c) 2016 Zeit, Inc. 567 | 568 | Permission is hereby granted, free of charge, to any person obtaining a copy 569 | of this software and associated documentation files (the "Software"), to deal 570 | in the Software without restriction, including without limitation the rights 571 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 572 | copies of the Software, and to permit persons to whom the Software is 573 | furnished to do so, subject to the following conditions: 574 | 575 | The above copyright notice and this permission notice shall be included in all 576 | copies or substantial portions of the Software. 577 | 578 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 579 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 580 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 581 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 582 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 583 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 584 | SOFTWARE. 585 | 586 | 587 | node-fetch 588 | MIT 589 | The MIT License (MIT) 590 | 591 | Copyright (c) 2016 David Frank 592 | 593 | Permission is hereby granted, free of charge, to any person obtaining a copy 594 | of this software and associated documentation files (the "Software"), to deal 595 | in the Software without restriction, including without limitation the rights 596 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 597 | copies of the Software, and to permit persons to whom the Software is 598 | furnished to do so, subject to the following conditions: 599 | 600 | The above copyright notice and this permission notice shall be included in all 601 | copies or substantial portions of the Software. 602 | 603 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 604 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 605 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 606 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 607 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 608 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 609 | SOFTWARE. 610 | 611 | 612 | 613 | once 614 | ISC 615 | The ISC License 616 | 617 | Copyright (c) Isaac Z. Schlueter and Contributors 618 | 619 | Permission to use, copy, modify, and/or distribute this software for any 620 | purpose with or without fee is hereby granted, provided that the above 621 | copyright notice and this permission notice appear in all copies. 622 | 623 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 624 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 625 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 626 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 627 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 628 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 629 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 630 | 631 | 632 | supports-color 633 | MIT 634 | MIT License 635 | 636 | Copyright (c) Sindre Sorhus (sindresorhus.com) 637 | 638 | 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: 639 | 640 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 641 | 642 | 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. 643 | 644 | 645 | tunnel 646 | MIT 647 | The MIT License (MIT) 648 | 649 | Copyright (c) 2012 Koichi Kobayashi 650 | 651 | Permission is hereby granted, free of charge, to any person obtaining a copy 652 | of this software and associated documentation files (the "Software"), to deal 653 | in the Software without restriction, including without limitation the rights 654 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 655 | copies of the Software, and to permit persons to whom the Software is 656 | furnished to do so, subject to the following conditions: 657 | 658 | The above copyright notice and this permission notice shall be included in 659 | all copies or substantial portions of the Software. 660 | 661 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 662 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 663 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 664 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 665 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 666 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 667 | THE SOFTWARE. 668 | 669 | 670 | universal-user-agent 671 | ISC 672 | # [ISC License](https://spdx.org/licenses/ISC) 673 | 674 | Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m) 675 | 676 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 677 | 678 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 679 | 680 | 681 | wrappy 682 | ISC 683 | The ISC License 684 | 685 | Copyright (c) Isaac Z. Schlueter and Contributors 686 | 687 | Permission to use, copy, modify, and/or distribute this software for any 688 | purpose with or without fee is hereby granted, provided that the above 689 | copyright notice and this permission notice appear in all copies. 690 | 691 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 692 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 693 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 694 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 695 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 696 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 697 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 698 | -------------------------------------------------------------------------------- /__tests__/main.test.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as github from '@actions/github' 3 | import nock from 'nock' 4 | 5 | import {wait} from '../src/wait' 6 | import {IGitHubRepoLabels, IGitHubPRNode, IGitHubLabelNode, IGitHubPullRequest} from '../src/interfaces' 7 | import {findLabelByName, isAlreadyLabeled} from '../src/util' 8 | import { 9 | getLabels, 10 | getPullRequests, 11 | addLabelToLabelable, 12 | removeLabelFromLabelable, 13 | getPullRequestChanges, 14 | getCommitChanges, 15 | getPullRequest 16 | } from '../src/queries' 17 | import {checkPullRequestForMergeChanges, gatherPullRequests, gatherPullRequest} from '../src/pulls' 18 | import {updatePullRequestConflictLabel} from '../src/label' 19 | import {run} from '../src/run' 20 | 21 | test('throws invalid number', async () => { 22 | const input = parseInt('foo', 10) 23 | await expect(wait(input)).rejects.toThrow('milliseconds not a number') 24 | }) 25 | 26 | test('wait 500 ms', async () => { 27 | const start = new Date() 28 | await wait(500) 29 | const end = new Date() 30 | var delta = Math.abs(end.getTime() - start.getTime()) 31 | expect(delta).toBeGreaterThan(450) 32 | }) 33 | 34 | describe('label matching', () => { 35 | test('find exact from one label', () => { 36 | const labelNode = {node: {id: '1654984416', name: 'expected_label'}} 37 | const labelData: IGitHubRepoLabels = {repository: {labels: {edges: [labelNode]}}} 38 | const node = findLabelByName(labelData, 'expected_label') 39 | expect(node).toBe(labelNode) 40 | }) 41 | 42 | test('finds from many labels', () => { 43 | const labelNode = {node: {id: '1654984416', name: 'expected_label'}} 44 | const labelData: IGitHubRepoLabels = { 45 | repository: {labels: {edges: [{node: {id: 'MDU6TGFiZWwxMjUyNDcxNTgz', name: 'has conflicts'}}, labelNode]}} 46 | } 47 | const node = findLabelByName(labelData, 'expected_label') 48 | expect(node).toBe(labelNode) 49 | }) 50 | 51 | test('throws when no match', () => { 52 | const labelData: IGitHubRepoLabels = { 53 | repository: { 54 | labels: { 55 | edges: [ 56 | {node: {id: 'MDU6TGFiZWwxMjUyNDcxNTgz', name: 'has conflicts'}}, 57 | {node: {id: '1654984416', name: 'some other label'}} 58 | ] 59 | } 60 | } 61 | } 62 | expect(() => { 63 | findLabelByName(labelData, 'expected_label') 64 | }).toThrowError(/expected_label/) 65 | }) 66 | }) 67 | 68 | describe('pr label checking', () => { 69 | const expectedLabel: IGitHubLabelNode = {node: {id: '1654984416', name: 'expected_label'}} 70 | const makePr = (...label: IGitHubLabelNode[]): IGitHubPullRequest => { 71 | return { 72 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 73 | number: 7, 74 | mergeable: 'MERGEABLE', 75 | potentialMergeCommit: { 76 | oid: '5ed0e15d4ca4ce73e847ee1f0369ee85a6e67bc9' 77 | }, 78 | labels: {edges: [...label]} 79 | } 80 | } 81 | 82 | test('finds from one label', () => { 83 | const prNode = makePr(expectedLabel) 84 | const isLabeled = isAlreadyLabeled(prNode, expectedLabel) 85 | expect(isLabeled).toBeTruthy() 86 | }) 87 | 88 | test('finds from many labels', () => { 89 | const prNode = makePr({node: {id: 'MDU6TGFiZWwxMjUyNDcxNTgz', name: 'has conflicts'}}, expectedLabel) 90 | const isLabeled = isAlreadyLabeled(prNode, expectedLabel) 91 | expect(isLabeled).toBeTruthy() 92 | }) 93 | 94 | test('false when no match', () => { 95 | const prNode = makePr( 96 | {node: {id: 'MDU6TGFiZWwxMjUyNDcxNTgz', name: 'has conflicts'}}, 97 | {node: {id: 'flbvalvbea;lygh;dbl;gblas;', name: 'some other label'}} 98 | ) 99 | const isLabeled = isAlreadyLabeled(prNode, expectedLabel) 100 | expect(isLabeled).toBeFalsy() 101 | }) 102 | }) 103 | 104 | // Inputs for mock @actions/core 105 | let inputs = {} as any 106 | 107 | // Shallow clone original @actions/github context 108 | let originalContext = {...github.context} 109 | 110 | describe('queries', () => { 111 | beforeAll(() => { 112 | // Mock getInput 113 | jest.spyOn(core, 'getInput').mockImplementation((name: string) => { 114 | return inputs[name] 115 | }) 116 | 117 | // Mock error/warning/info/debug 118 | jest.spyOn(core, 'error').mockImplementation(jest.fn()) 119 | jest.spyOn(core, 'warning').mockImplementation(jest.fn()) 120 | jest.spyOn(core, 'info').mockImplementation(jest.fn()) 121 | jest.spyOn(core, 'debug').mockImplementation(jest.fn()) 122 | jest.spyOn(core, 'startGroup').mockImplementation(jest.fn()) 123 | jest.spyOn(core, 'endGroup').mockImplementation(jest.fn()) 124 | jest.spyOn(core, 'setFailed').mockImplementation(jest.fn()) 125 | 126 | // Mock github context 127 | jest.spyOn(github.context, 'repo', 'get').mockImplementation(() => { 128 | return { 129 | owner: 'some-owner', 130 | repo: 'some-repo' 131 | } 132 | }) 133 | github.context.ref = 'refs/heads/some-ref' 134 | github.context.sha = '1234567890123456789012345678901234567890' 135 | github.context.eventName = 'push' 136 | }) 137 | 138 | beforeEach(() => { 139 | // Reset inputs 140 | inputs = {} 141 | github.context.eventName = originalContext.eventName 142 | github.context.payload = originalContext.payload 143 | }) 144 | 145 | afterAll(() => { 146 | // Restore @actions/github context 147 | github.context.ref = originalContext.ref 148 | github.context.sha = originalContext.sha 149 | github.context.eventName = originalContext.eventName 150 | 151 | // Restore 152 | jest.restoreAllMocks() 153 | }) 154 | 155 | const mockPullRequestEvent = { 156 | action: 'opened', 157 | number: 2, 158 | pull_request: { 159 | url: 'https://api.github.com/repos/Codertocat/Hello-World/pulls/2', 160 | id: 279147437, 161 | node_id: 'MDExOlB1bGxSZXF1ZXN0Mjc5MTQ3NDM3', 162 | number: 2, 163 | locked: false, 164 | title: 'Update the README with new information.', 165 | user: { 166 | login: 'Codertocat', 167 | id: 21031067, 168 | node_id: 'MDQ6VXNlcjIxMDMxMDY3' 169 | }, 170 | body: 'This is a pretty simple change that we need to pull into master.', 171 | created_at: '2019-05-15T15:20:33Z', 172 | updated_at: '2019-05-15T15:20:33Z', 173 | head: { 174 | label: 'Codertocat:changes', 175 | ref: 'changes', 176 | sha: 'ec26c3e57ca3a959ca5aad62de7213c562f8c821', 177 | user: { 178 | login: 'Codertocat', 179 | id: 21031067, 180 | node_id: 'MDQ6VXNlcjIxMDMxMDY3' 181 | }, 182 | repo: { 183 | id: 186853002, 184 | node_id: 'MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=', 185 | name: 'Hello-World', 186 | full_name: 'Codertocat/Hello-World' 187 | } 188 | }, 189 | base: { 190 | label: 'Codertocat:master', 191 | ref: 'master', 192 | sha: 'f95f852bd8fca8fcc58a9a2d6c842781e32a215e', 193 | user: { 194 | login: 'Codertocat', 195 | id: 21031067, 196 | node_id: 'MDQ6VXNlcjIxMDMxMDY3' 197 | }, 198 | repo: { 199 | id: 186853002, 200 | node_id: 'MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=', 201 | name: 'Hello-World', 202 | full_name: 'Codertocat/Hello-World' 203 | } 204 | }, 205 | author_association: 'OWNER', 206 | mergeable: null 207 | }, 208 | repository: { 209 | id: 186853002, 210 | node_id: 'MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=', 211 | name: 'Hello-World', 212 | full_name: 'Codertocat/Hello-World' 213 | }, 214 | sender: { 215 | login: 'Codertocat', 216 | id: 21031067, 217 | node_id: 'MDQ6VXNlcjIxMDMxMDY3' 218 | } 219 | } 220 | 221 | describe('for labels', () => { 222 | it('gets a matching label', async () => { 223 | const scope = nock('https://api.github.com', { 224 | reqheaders: { 225 | authorization: 'token justafaketoken' 226 | } 227 | }) 228 | .post('/graphql') 229 | .reply(200, {data: {repository: {labels: {edges: [{node: {id: '1654984416', name: 'expected_label'}}]}}}}) 230 | 231 | const octokit = github.getOctokit('justafaketoken') 232 | const labels = await getLabels(octokit, github.context, 'expected_label') 233 | 234 | expect(labels.repository.labels.edges.length).toBe(1) 235 | expect(labels.repository.labels.edges[0].node.id).toBe('1654984416') 236 | expect(labels.repository.labels.edges[0].node.name).toBe('expected_label') 237 | }) 238 | 239 | it('gets many similar label', async () => { 240 | const scope = nock('https://api.github.com', { 241 | reqheaders: { 242 | authorization: 'token justafaketoken' 243 | } 244 | }) 245 | .post('/graphql') 246 | .reply(200, { 247 | data: { 248 | repository: { 249 | labels: { 250 | edges: [ 251 | {node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'dependencies'}}, 252 | {node: {id: 'MDU6TGFiZWwyNzYwMjEzNzMw', name: 'wontfix'}} 253 | ] 254 | } 255 | } 256 | } 257 | }) 258 | 259 | const octokit = github.getOctokit('justafaketoken') 260 | const labels = await getLabels(octokit, github.context, 'expected_label') 261 | 262 | expect(labels.repository.labels.edges.length).toBe(2) 263 | expect(labels.repository.labels.edges[0].node.id).toBe('MDU6TGFiZWwyNzYwMjE1ODI0') 264 | expect(labels.repository.labels.edges[0].node.name).toBe('dependencies') 265 | expect(labels.repository.labels.edges[1].node.id).toBe('MDU6TGFiZWwyNzYwMjEzNzMw') 266 | expect(labels.repository.labels.edges[1].node.name).toBe('wontfix') 267 | }) 268 | 269 | it('gets many similar label', async () => { 270 | const scope = nock('https://api.github.com', { 271 | reqheaders: { 272 | authorization: 'token justafaketoken' 273 | } 274 | }) 275 | .post('/graphql') 276 | .reply(200, { 277 | data: { 278 | repository: { 279 | labels: { 280 | edges: [ 281 | {node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'dependencies'}}, 282 | {node: {id: 'MDU6TGFiZWwyNzYwMjEzNzMw', name: 'wontfix'}} 283 | ] 284 | } 285 | } 286 | } 287 | }) 288 | 289 | const octokit = github.getOctokit('justafaketoken') 290 | const labels = await getLabels(octokit, github.context, 'expected_label') 291 | 292 | expect(labels.repository.labels.edges.length).toBe(2) 293 | expect(labels.repository.labels.edges[0].node.id).toBe('MDU6TGFiZWwyNzYwMjE1ODI0') 294 | expect(labels.repository.labels.edges[0].node.name).toBe('dependencies') 295 | expect(labels.repository.labels.edges[1].node.id).toBe('MDU6TGFiZWwyNzYwMjEzNzMw') 296 | expect(labels.repository.labels.edges[1].node.name).toBe('wontfix') 297 | }) 298 | 299 | it('throws on error response', async () => { 300 | const scope = nock('https://api.github.com', { 301 | reqheaders: { 302 | authorization: 'token justafaketoken' 303 | } 304 | }) 305 | .post('/graphql') 306 | .reply(400, { 307 | message: 'Body should be a JSON object', 308 | documentation_url: 'https://docs.github.com/graphql' 309 | }) 310 | 311 | const octokit = github.getOctokit('justafaketoken') 312 | const labels = getLabels(octokit, github.context, 'expected_label') 313 | 314 | await expect(labels).rejects.toThrowError() 315 | }) 316 | }) 317 | 318 | describe('for pull requests', () => { 319 | it('gets a pull request', async () => { 320 | const scope = nock('https://api.github.com', { 321 | reqheaders: { 322 | authorization: 'token justafaketoken' 323 | } 324 | }) 325 | .post('/graphql') 326 | .reply(200, { 327 | data: { 328 | repository: { 329 | pullRequests: { 330 | edges: [ 331 | { 332 | node: { 333 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 334 | number: 7, 335 | mergeable: 'MERGEABLE', 336 | labels: {edges: []} 337 | } 338 | } 339 | ], 340 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOIoELkg==', hasNextPage: false} 341 | } 342 | } 343 | } 344 | }) 345 | 346 | const octokit = github.getOctokit('justafaketoken') 347 | const pullRequests = await getPullRequests(octokit, github.context) 348 | 349 | expect(pullRequests.length).toBe(1) 350 | expect(pullRequests[0].node.id).toBe('MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw') 351 | expect(pullRequests[0].node.number).toBe(7) 352 | expect(pullRequests[0].node.mergeable).toBe('MERGEABLE') 353 | expect(pullRequests[0].node.labels.edges.length).toBe(0) 354 | }) 355 | 356 | it('get a specific pull request', async () => { 357 | const scope = nock('https://api.github.com', { 358 | reqheaders: { 359 | authorization: 'token justafaketoken' 360 | } 361 | }) 362 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":49}/) 363 | .reply(200, { 364 | data: { 365 | repository: { 366 | pullRequest: { 367 | id: 'MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4', 368 | number: 49, 369 | mergeable: 'MERGEABLE', 370 | potentialMergeCommit: { 371 | oid: '8b0ec723ab52932bf3476b711df72f762742bede' 372 | }, 373 | labels: { 374 | edges: [ 375 | { 376 | node: { 377 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 378 | name: 'Failed' 379 | } 380 | } 381 | ] 382 | } 383 | } 384 | } 385 | } 386 | }) 387 | 388 | const octokit = github.getOctokit('justafaketoken') 389 | const pullRequests = await getPullRequest(octokit, github.context, 49) 390 | 391 | expect(pullRequests.id).toBe('MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4') 392 | expect(pullRequests.number).toBe(49) 393 | expect(pullRequests.mergeable).toBe('MERGEABLE') 394 | expect(pullRequests.labels.edges.length).toBe(1) 395 | }) 396 | 397 | it('gets pages of pull requests', async () => { 398 | const scope = nock('https://api.github.com', { 399 | reqheaders: { 400 | authorization: 'token justafaketoken' 401 | } 402 | }) 403 | .post('/graphql') 404 | .reply(200, { 405 | data: { 406 | repository: { 407 | pullRequests: { 408 | edges: [ 409 | { 410 | node: { 411 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 412 | number: 7, 413 | mergeable: 'MERGEABLE', 414 | labels: {edges: []} 415 | } 416 | } 417 | ], 418 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOGktShA==', hasNextPage: true} 419 | } 420 | } 421 | } 422 | }) 423 | .post('/graphql', /Y3Vyc29yOnYyOpHOGktShA==/) 424 | .reply(200, { 425 | data: { 426 | repository: { 427 | pullRequests: { 428 | edges: [ 429 | { 430 | node: { 431 | id: 'justsomestring', 432 | number: 64, 433 | mergeable: 'MERGEABLE', 434 | labels: {edges: []} 435 | } 436 | } 437 | ], 438 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOGktShA==', hasNextPage: false} 439 | } 440 | } 441 | } 442 | }) 443 | 444 | const octokit = github.getOctokit('justafaketoken') 445 | const pullRequests = await getPullRequests(octokit, github.context) 446 | 447 | expect(pullRequests.length).toBe(2) 448 | expect(pullRequests[0].node.id).toBe('MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw') 449 | expect(pullRequests[0].node.number).toBe(7) 450 | expect(pullRequests[0].node.mergeable).toBe('MERGEABLE') 451 | expect(pullRequests[0].node.labels.edges.length).toBe(0) 452 | 453 | expect(pullRequests[1].node.id).toBe('justsomestring') 454 | expect(pullRequests[1].node.number).toBe(64) 455 | expect(pullRequests[1].node.mergeable).toBe('MERGEABLE') 456 | expect(pullRequests[1].node.labels.edges.length).toBe(0) 457 | }) 458 | 459 | it('gathers pull requests', async () => { 460 | const scope = nock('https://api.github.com', { 461 | reqheaders: { 462 | authorization: 'token justafaketoken' 463 | } 464 | }) 465 | .post('/graphql') 466 | .reply(200, { 467 | data: { 468 | repository: { 469 | pullRequests: { 470 | edges: [ 471 | { 472 | node: { 473 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 474 | number: 7, 475 | mergeable: 'UNKNOWN', 476 | labels: {edges: []} 477 | } 478 | }, 479 | { 480 | node: { 481 | id: 'justsomestring', 482 | number: 64, 483 | mergeable: 'MERGEABLE', 484 | labels: {edges: []} 485 | } 486 | } 487 | ], 488 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOGktShA==', hasNextPage: false} 489 | } 490 | } 491 | } 492 | }) 493 | .post('/graphql') 494 | .reply(200, { 495 | data: { 496 | repository: { 497 | pullRequests: { 498 | edges: [ 499 | { 500 | node: { 501 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 502 | number: 7, 503 | mergeable: 'MERGEABLE', 504 | labels: {edges: []} 505 | } 506 | }, 507 | { 508 | node: { 509 | id: 'justsomestring', 510 | number: 64, 511 | mergeable: 'MERGEABLE', 512 | labels: {edges: []} 513 | } 514 | } 515 | ], 516 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOGktShA==', hasNextPage: false} 517 | } 518 | } 519 | } 520 | }) 521 | 522 | const octokit = github.getOctokit('justafaketoken') 523 | const pullRequests = await gatherPullRequests(octokit, github.context, 10, 1) 524 | 525 | expect(pullRequests.length).toBe(2) 526 | expect(pullRequests[0].node.id).toBe('MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw') 527 | expect(pullRequests[0].node.number).toBe(7) 528 | expect(pullRequests[0].node.mergeable).toBe('MERGEABLE') 529 | expect(pullRequests[0].node.labels.edges.length).toBe(0) 530 | 531 | expect(pullRequests[1].node.id).toBe('justsomestring') 532 | expect(pullRequests[1].node.number).toBe(64) 533 | expect(pullRequests[1].node.mergeable).toBe('MERGEABLE') 534 | expect(pullRequests[1].node.labels.edges.length).toBe(0) 535 | }) 536 | }) 537 | 538 | it('retries gathering pull requests', async () => { 539 | const scope = nock('https://api.github.com', { 540 | reqheaders: { 541 | authorization: 'token justafaketoken' 542 | } 543 | }) 544 | .post('/graphql') 545 | .times(3) 546 | .reply(200, { 547 | data: { 548 | repository: { 549 | pullRequests: { 550 | edges: [ 551 | { 552 | node: { 553 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 554 | number: 7, 555 | mergeable: 'UNKNOWN', 556 | labels: {edges: []} 557 | } 558 | }, 559 | { 560 | node: { 561 | id: 'justsomestring', 562 | number: 64, 563 | mergeable: 'MERGEABLE', 564 | labels: {edges: []} 565 | } 566 | } 567 | ], 568 | pageInfo: {endCursor: 'Y3Vyc29yOnYyOpHOGktShA==', hasNextPage: false} 569 | } 570 | } 571 | } 572 | }) 573 | 574 | const octokit = github.getOctokit('justafaketoken') 575 | const start = new Date() 576 | const pullRequests = await gatherPullRequests(octokit, github.context, 25, 2) 577 | const end = new Date() 578 | var delta = Math.abs(end.getTime() - start.getTime()) 579 | expect(delta).toBeGreaterThan(45) 580 | 581 | expect(pullRequests.length).toBe(2) 582 | expect(pullRequests[0].node.id).toBe('MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw') 583 | expect(pullRequests[0].node.number).toBe(7) 584 | expect(pullRequests[0].node.mergeable).toBe('UNKNOWN') 585 | expect(pullRequests[0].node.labels.edges.length).toBe(0) 586 | 587 | expect(pullRequests[1].node.id).toBe('justsomestring') 588 | expect(pullRequests[1].node.number).toBe(64) 589 | expect(pullRequests[1].node.mergeable).toBe('MERGEABLE') 590 | expect(pullRequests[1].node.labels.edges.length).toBe(0) 591 | }) 592 | 593 | it('retries gathering a specific pull request', async () => { 594 | const scope = nock('https://api.github.com', { 595 | reqheaders: { 596 | authorization: 'token justafaketoken' 597 | } 598 | }) 599 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":2}/) 600 | .reply(200, { 601 | data: { 602 | repository: { 603 | pullRequest: { 604 | id: 'MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4', 605 | number: mockPullRequestEvent.number, 606 | mergeable: 'UNKNOWN', 607 | potentialMergeCommit: { 608 | oid: '8b0ec723ab52932bf3476b711df72f762742bede' 609 | }, 610 | labels: { 611 | edges: [ 612 | { 613 | node: { 614 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 615 | name: 'Failed' 616 | } 617 | } 618 | ] 619 | } 620 | } 621 | } 622 | } 623 | }) 624 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":2}/) 625 | .reply(200, { 626 | data: { 627 | repository: { 628 | pullRequest: { 629 | id: 'MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4', 630 | number: mockPullRequestEvent.number, 631 | mergeable: 'MERGEABLE', 632 | potentialMergeCommit: { 633 | oid: '8b0ec723ab52932bf3476b711df72f762742bede' 634 | }, 635 | labels: { 636 | edges: [ 637 | { 638 | node: { 639 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 640 | name: 'Failed' 641 | } 642 | } 643 | ] 644 | } 645 | } 646 | } 647 | } 648 | }) 649 | 650 | const octokit = github.getOctokit('justafaketoken') 651 | const start = new Date() 652 | const pullRequest = await gatherPullRequest(octokit, github.context, mockPullRequestEvent as any, 25, 2) 653 | const end = new Date() 654 | var delta = Math.abs(end.getTime() - start.getTime()) 655 | 656 | expect(delta).toBeGreaterThan(45) 657 | expect(delta).toBeLessThan(75) 658 | 659 | expect(pullRequest.id).toBe('MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4') 660 | expect(pullRequest.number).toBe(mockPullRequestEvent.number) 661 | expect(pullRequest.mergeable).toBe('MERGEABLE') 662 | expect(pullRequest.labels.edges.length).toBe(1) 663 | }) 664 | 665 | it('throws when unknown on specific pull request', async () => { 666 | const scope = nock('https://api.github.com', { 667 | reqheaders: { 668 | authorization: 'token justafaketoken' 669 | } 670 | }) 671 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":2}/) 672 | .times(3) 673 | .reply(200, { 674 | data: { 675 | repository: { 676 | pullRequest: { 677 | id: 'MDExOlB1bGxSZXF1ZXN0NTk3NDgzNjg4', 678 | number: mockPullRequestEvent.number, 679 | mergeable: 'UNKNOWN', 680 | potentialMergeCommit: { 681 | oid: '8b0ec723ab52932bf3476b711df72f762742bede' 682 | }, 683 | labels: { 684 | edges: [ 685 | { 686 | node: { 687 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 688 | name: 'Failed' 689 | } 690 | } 691 | ] 692 | } 693 | } 694 | } 695 | } 696 | }) 697 | 698 | const octokit = github.getOctokit('justafaketoken') 699 | const pullRequest = gatherPullRequest(octokit, github.context, mockPullRequestEvent as any, 25, 2) 700 | 701 | await expect(pullRequest).rejects.toThrowError(/Could not determine mergeable status/) 702 | }) 703 | 704 | describe('modifies labels', () => { 705 | describe('add', () => { 706 | it('adds a new label', async () => { 707 | const scope = nock('https://api.github.com', { 708 | reqheaders: { 709 | authorization: 'token justafaketoken' 710 | } 711 | }) 712 | .post( 713 | '/graphql', 714 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 715 | ) 716 | .reply(200, {data: {}}) 717 | 718 | const octokit = github.getOctokit('justafaketoken') 719 | const add = await addLabelToLabelable(octokit, { 720 | labelId: 'MDU6TGFiZWwyNzYwMjE1ODI0', 721 | labelableId: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw' 722 | }) 723 | 724 | expect(add).toBeTruthy() 725 | }) 726 | 727 | it('throws on error response', async () => { 728 | const scope = nock('https://api.github.com', { 729 | reqheaders: { 730 | authorization: 'token justafaketoken' 731 | } 732 | }) 733 | .post('/graphql') 734 | .reply(400, { 735 | message: 'Body should be a JSON object', 736 | documentation_url: 'https://docs.github.com/graphql' 737 | }) 738 | 739 | const octokit = github.getOctokit('justafaketoken') 740 | const labels = addLabelToLabelable(octokit, { 741 | labelId: 'MDU6TGFiZWwyNzYwMjE1ODI0', 742 | labelableId: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw' 743 | }) 744 | 745 | await expect(labels).rejects.toThrowError() 746 | }) 747 | }) 748 | 749 | describe('remove', () => { 750 | it('removes an old label', async () => { 751 | const scope = nock('https://api.github.com', { 752 | reqheaders: { 753 | authorization: 'token justafaketoken' 754 | } 755 | }) 756 | .post( 757 | '/graphql', 758 | /removeLabelsFromLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 759 | ) 760 | .reply(200, {data: {}}) 761 | 762 | const octokit = github.getOctokit('justafaketoken') 763 | const add = await removeLabelFromLabelable(octokit, { 764 | labelId: 'MDU6TGFiZWwyNzYwMjE1ODI0', 765 | labelableId: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw' 766 | }) 767 | 768 | expect(add).toBeTruthy() 769 | }) 770 | 771 | it('throws on error response', async () => { 772 | const scope = nock('https://api.github.com', { 773 | reqheaders: { 774 | authorization: 'token justafaketoken' 775 | } 776 | }) 777 | .post('/graphql') 778 | .reply(400, { 779 | message: 'Body should be a JSON object', 780 | documentation_url: 'https://docs.github.com/graphql' 781 | }) 782 | 783 | const octokit = github.getOctokit('justafaketoken') 784 | const labels = removeLabelFromLabelable(octokit, { 785 | labelId: 'MDU6TGFiZWwyNzYwMjE1ODI0', 786 | labelableId: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw' 787 | }) 788 | 789 | await expect(labels).rejects.toThrowError() 790 | }) 791 | }) 792 | }) 793 | 794 | describe('gathers files changed', () => { 795 | describe('pull request', () => { 796 | it('gets a list', async () => { 797 | const scope = nock('https://api.github.com', { 798 | reqheaders: { 799 | authorization: 'token justafaketoken' 800 | } 801 | }) 802 | .get(`/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/123/files?per_page=300`) 803 | .reply(200, [ 804 | { 805 | sha: 'a8f3b51f97dbe31d1da584262e01b3ac2465d2d8', 806 | filename: 'recipes/protobuf/all/conandata.yml', 807 | patch: 808 | '@@ -20,6 +20,17 @@ patches:\n base_path: "source_subfolder"\n - patch_file: "patches/upstream-issue-7567-no-exp...' 809 | }, 810 | { 811 | sha: 'cb0f93f2eeaa80d2fbddff1d7169e254f89b7ecb', 812 | filename: 'recipes/protobuf/all/conanfile.py', 813 | status: 'modified', 814 | patch: 815 | '@@ -109,7 +109,7 @@ def _patch_sources(self):\n find_protoc = """\n \n # Find the protobuf compiler within t...' 816 | } 817 | ]) 818 | 819 | const octokit = github.getOctokit('justafaketoken') 820 | const prChanges = await getPullRequestChanges(octokit, github.context, 123) 821 | 822 | expect(prChanges).toBeTruthy() 823 | expect(prChanges.length).toBe(2) 824 | expect(prChanges[1].sha).toBe('cb0f93f2eeaa80d2fbddff1d7169e254f89b7ecb') 825 | expect(prChanges[1].filename).toBe('recipes/protobuf/all/conanfile.py') 826 | }) 827 | 828 | it('throws on error response', async () => { 829 | const scope = nock('https://api.github.com', { 830 | reqheaders: { 831 | authorization: 'token justafaketoken' 832 | } 833 | }) 834 | .get(`/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/123/files?per_page=300`) 835 | .reply(404, { 836 | message: 'Not Found', 837 | documentation_url: 'https://docs.github.com/rest/reference/pulls#list-pull-requests-files' 838 | }) 839 | 840 | const octokit = github.getOctokit('justafaketoken') 841 | const prCahnges = getPullRequestChanges(octokit, github.context, 123) 842 | 843 | await expect(prCahnges).rejects.toThrowError(/Not Found/) 844 | }) 845 | }) 846 | 847 | describe('merge commit', () => { 848 | const changes = [ 849 | { 850 | sha: '06ea1fc2136e77e11f43923bd4c446fc8ea5caa3', 851 | filename: 'recipes/graphene/all/conandata.yml', 852 | status: 'added', 853 | patch: 854 | '@@ -0,0 +1,4 @@\n+sources:\n+ "1.10.2":\n+ url: "https://github.com/ebassi/graphene/releases/download/1.10.2/graphene-1.10.2...' 855 | }, 856 | { 857 | sha: '8d9cd557cf27237c1ccc3cd4cf77a3033212d350', 858 | filename: 'recipes/graphene/all/conanfile.py', 859 | status: 'added', 860 | patch: 861 | '@@ -0,0 +1,96 @@\n+from conans import ConanFile, Meson, tools\n+from conans.errors import ConanInvalidConfiguration\n+import os\n+\n+req...' 862 | }, 863 | { 864 | sha: 'f21465c9d35d01b9d27d822dc0efe05f39f1f792', 865 | filename: 'recipes/graphene/config.yml', 866 | status: 'added', 867 | patch: '@@ -0,0 +1,3 @@\n+versions:\n+ "1.10.2":\n+ folder: "all"' 868 | } 869 | ] 870 | it('gets a list', async () => { 871 | const scope = nock('https://api.github.com', { 872 | reqheaders: { 873 | authorization: 'token justafaketoken' 874 | } 875 | }) 876 | .get(`/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${github.context.sha}`) 877 | .reply(200, { 878 | sha: '78db84765bc6de1a254d969c4d6b2f09a9862355', 879 | node_id: 'MDY6Q29tbWl0MjA0NjcxMjMyOjc4ZGI4NDc2NWJjNmRlMWEyNTRkOTY5YzRkNmIyZjA5YTk4NjIzNTU=', 880 | commit: { 881 | author: { 882 | date: '2021-01-07T15:31:36Z' 883 | }, 884 | committer: { 885 | name: 'GitHub', 886 | email: 'noreply@github.com', 887 | date: '2021-01-07T15:31:36Z' 888 | }, 889 | message: 'Generic PR' 890 | }, 891 | committer: { 892 | login: 'web-flow', 893 | id: 19864447, 894 | node_id: 'MDQ6VXNlcjE5ODY0NDQ3' 895 | }, 896 | parents: [ 897 | { 898 | sha: 'b90be7f65a6eb23aa2c402d27d10ef548ac4be4e' 899 | } 900 | ], 901 | files: changes 902 | }) 903 | 904 | const octokit = github.getOctokit('justafaketoken') 905 | const mergeChanges = await getCommitChanges(octokit, github.context, github.context.sha) 906 | 907 | expect(mergeChanges).toBeTruthy() 908 | expect(mergeChanges.length).toBe(3) 909 | expect(mergeChanges[2].sha).toBe('f21465c9d35d01b9d27d822dc0efe05f39f1f792') 910 | expect(mergeChanges[2].filename).toBe('recipes/graphene/config.yml') 911 | }) 912 | 913 | it('throws on error response', async () => { 914 | const scope = nock('https://api.github.com', { 915 | reqheaders: { 916 | authorization: 'token justafaketoken' 917 | } 918 | }) 919 | .get(`/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${github.context.sha}`) 920 | .reply(422, { 921 | message: 'No commit found for SHA: 78db84765bc6de1a254d969c4d6b2f09a62355', 922 | documentation_url: 'https://docs.github.com/rest/reference/repos#get-a-commit' 923 | }) 924 | 925 | const octokit = github.getOctokit('justafaketoken') 926 | 927 | const mergeChanges = getCommitChanges(octokit, github.context, github.context.sha) 928 | expect(mergeChanges).rejects.toThrowError(/No commit found/) 929 | }) 930 | 931 | it('throws with no files', async () => { 932 | const scope = nock('https://api.github.com', { 933 | reqheaders: { 934 | authorization: 'token justafaketoken' 935 | } 936 | }) 937 | .get(`/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${github.context.sha}`) 938 | .reply(200, { 939 | sha: '78db84765bc6de1a254d969c4d6b2f09a9862355', 940 | node_id: 'MDY6Q29tbWl0MjA0NjcxMjMyOjc4ZGI4NDc2NWJjNmRlMWEyNTRkOTY5YzRkNmIyZjA5YTk4NjIzNTU=', 941 | commit: { 942 | author: { 943 | date: '2021-01-07T15:31:36Z' 944 | }, 945 | committer: { 946 | name: 'GitHub', 947 | email: 'noreply@github.com', 948 | date: '2021-01-07T15:31:36Z' 949 | }, 950 | message: 'Some Pull Request' 951 | }, 952 | committer: { 953 | login: 'web-flow', 954 | id: 19864447, 955 | node_id: 'MDQ6VXNlcjE5ODY0NDQ3' 956 | }, 957 | parents: [ 958 | { 959 | sha: 'b90be7f65a6eb23aa2c402d27d10ef548ac4be4e' 960 | } 961 | ] 962 | }) 963 | 964 | const octokit = github.getOctokit('justafaketoken') 965 | 966 | const mergeChanges = getCommitChanges(octokit, github.context, github.context.sha) 967 | expect(mergeChanges).rejects.toThrowError(/unknown diff/) 968 | }) 969 | }) 970 | 971 | describe('determines changes', () => { 972 | const prNode: IGitHubPRNode = { 973 | node: { 974 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 975 | number: 7, 976 | mergeable: 'MERGEABLE', 977 | potentialMergeCommit: { 978 | oid: '5ed0e15d4ca4ce73e847ee1f0369ee85a6e67bc9' 979 | }, 980 | labels: {edges: []} 981 | } 982 | } 983 | 984 | const changes = [ 985 | { 986 | sha: 'a8f3b51f97dbe31d1da584262e01b3ac2465d2d8', 987 | filename: 'recipes/protobuf/all/conandata.yml', 988 | patch: 989 | '@@ -20,6 +20,17 @@ patches:\n base_path: "source_subfolder"\n - patch_file: "patches/upstream-issue-7567-no-exp...' 990 | }, 991 | { 992 | sha: 'cb0f93f2eeaa80d2fbddff1d7169e254f89b7ecb', 993 | filename: 'recipes/protobuf/all/conanfile.py', 994 | status: 'modified', 995 | patch: 996 | '@@ -109,7 +109,7 @@ def _patch_sources(self):\n find_protoc = """\n \n # Find the protobuf compiler within t...' 997 | } 998 | ] 999 | 1000 | const makeCommitPage = (...changes: any[]) => { 1001 | return { 1002 | sha: '5ed0e15d4ca4ce73e847ee1f0369ee85a6e67bc9', 1003 | node_id: 'MDY6Q29tbWl0MjA0NjcxMjMyOjc4ZGI4NDc2NWJjNmRlMWEyNTRkOTY5YzRkNmIyZjA5YTk4NjIzNTU=', 1004 | commit: { 1005 | author: { 1006 | date: '2021-01-07T15:31:36Z' 1007 | }, 1008 | committer: { 1009 | name: 'GitHub', 1010 | email: 'noreply@github.com', 1011 | date: '2021-01-07T15:31:36Z' 1012 | }, 1013 | message: 'Generic PR' 1014 | }, 1015 | committer: { 1016 | login: 'web-flow', 1017 | id: 19864447, 1018 | node_id: 'MDQ6VXNlcjE5ODY0NDQ3' 1019 | }, 1020 | parents: [ 1021 | { 1022 | sha: 'b90be7f65a6eb23aa2c402d27d10ef548ac4be4e' 1023 | } 1024 | ], 1025 | files: [...changes] 1026 | } 1027 | } 1028 | 1029 | it('returns yes when list size is different', async () => { 1030 | const scope = nock('https://api.github.com', { 1031 | reqheaders: { 1032 | authorization: 'token justafaketoken' 1033 | } 1034 | }) 1035 | .get( 1036 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${prNode.node.number}/files?per_page=300` 1037 | ) 1038 | .reply(200, changes) 1039 | .get( 1040 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${prNode.node.potentialMergeCommit.oid}` 1041 | ) 1042 | .reply(200, makeCommitPage(changes[0])) 1043 | 1044 | const octokit = github.getOctokit('justafaketoken') 1045 | const changed = await checkPullRequestForMergeChanges(octokit, github.context, prNode.node) 1046 | 1047 | expect(changed).toBe(true) 1048 | }) 1049 | 1050 | it('returns yes when a sha is different', async () => { 1051 | const scope = nock('https://api.github.com', { 1052 | reqheaders: { 1053 | authorization: 'token justafaketoken' 1054 | } 1055 | }) 1056 | .get( 1057 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${prNode.node.number}/files?per_page=300` 1058 | ) 1059 | .reply(200, [changes[0]]) 1060 | .get( 1061 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${prNode.node.potentialMergeCommit.oid}` 1062 | ) 1063 | .reply(200, makeCommitPage(changes[1])) 1064 | 1065 | const octokit = github.getOctokit('justafaketoken') 1066 | const changed = await checkPullRequestForMergeChanges(octokit, github.context, prNode.node) 1067 | 1068 | expect(changed).toBe(true) 1069 | }) 1070 | 1071 | it('returns no when everythign matches', async () => { 1072 | const scope = nock('https://api.github.com', { 1073 | reqheaders: { 1074 | authorization: 'token justafaketoken' 1075 | } 1076 | }) 1077 | .get( 1078 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${prNode.node.number}/files?per_page=300` 1079 | ) 1080 | .reply(200, changes) 1081 | .get( 1082 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${prNode.node.potentialMergeCommit.oid}` 1083 | ) 1084 | .reply(200, makeCommitPage(...changes)) 1085 | 1086 | const octokit = github.getOctokit('justafaketoken') 1087 | const changed = await checkPullRequestForMergeChanges(octokit, github.context, prNode.node) 1088 | 1089 | expect(changed).toBe(false) 1090 | }) 1091 | }) 1092 | }) 1093 | 1094 | describe('correctly determines labeling', () => { 1095 | const expectedLabel: IGitHubLabelNode = {node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'expected_label'}} 1096 | const makePr = (mergeable: string, ...label: IGitHubLabelNode[]): IGitHubPullRequest => { 1097 | return { 1098 | id: 'MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw', 1099 | number: 7, 1100 | mergeable: mergeable, 1101 | potentialMergeCommit: { 1102 | oid: '5ed0e15d4ca4ce73e847ee1f0369ee85a6e67bc9' 1103 | }, 1104 | labels: {edges: [...label]} 1105 | } 1106 | } 1107 | 1108 | describe('add', () => { 1109 | it('adds a new label', async () => { 1110 | const scope = nock('https://api.github.com', { 1111 | reqheaders: { 1112 | authorization: 'token justafaketoken' 1113 | } 1114 | }) 1115 | .post( 1116 | '/graphql', 1117 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 1118 | ) 1119 | .reply(200, {data: {clientMutationId: 'auniqueid'}}) 1120 | 1121 | const pullRequest = makePr('CONFLICTING') 1122 | const octokit = github.getOctokit('justafaketoken') 1123 | const added = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1124 | 1125 | await expect(added).resolves.toBe(undefined) 1126 | }) 1127 | 1128 | it('throws on error response', async () => { 1129 | const scope = nock('https://api.github.com', { 1130 | reqheaders: { 1131 | authorization: 'token justafaketoken' 1132 | } 1133 | }) 1134 | .post( 1135 | '/graphql', 1136 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 1137 | ) 1138 | .reply(400, { 1139 | message: 'Body should be a JSON object', 1140 | documentation_url: 'https://docs.github.com/graphql' 1141 | }) 1142 | 1143 | const pullRequest = makePr('CONFLICTING') 1144 | const octokit = github.getOctokit('justafaketoken') 1145 | const added = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1146 | 1147 | await expect(added).rejects.toThrowError() 1148 | }) 1149 | 1150 | it('does nothing when already labeled', async () => { 1151 | const pullRequest = makePr('CONFLICTING', expectedLabel) 1152 | 1153 | const octokit = github.getOctokit('justafaketoken') 1154 | const mockFunction = jest.spyOn(octokit, 'graphql').mockImplementation(jest.fn()) 1155 | await updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1156 | 1157 | expect(mockFunction).not.toBeCalled() 1158 | }) 1159 | }) 1160 | 1161 | describe('remove', () => { 1162 | it('removes an old label', async () => { 1163 | const scope = nock('https://api.github.com', { 1164 | reqheaders: { 1165 | authorization: 'token justafaketoken' 1166 | } 1167 | }) 1168 | .post( 1169 | '/graphql', 1170 | /removeLabelsFromLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 1171 | ) 1172 | .reply(200, {data: {}}) 1173 | 1174 | const pullRequest = makePr('MERGEABLE', expectedLabel) 1175 | 1176 | const octokit = github.getOctokit('justafaketoken') 1177 | const removed = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1178 | 1179 | await expect(removed).resolves.toBe(undefined) 1180 | }) 1181 | 1182 | it('throws on error response', async () => { 1183 | const scope = nock('https://api.github.com', { 1184 | reqheaders: { 1185 | authorization: 'token justafaketoken' 1186 | } 1187 | }) 1188 | .post('/graphql') 1189 | .reply(400, { 1190 | message: 'Body should be a JSON object', 1191 | documentation_url: 'https://docs.github.com/graphql' 1192 | }) 1193 | 1194 | const pullRequest = makePr('MERGEABLE', expectedLabel) 1195 | const octokit = github.getOctokit('justafaketoken') 1196 | const removed = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1197 | 1198 | await expect(removed).rejects.toThrowError() 1199 | }) 1200 | 1201 | it('does nothing when no label', async () => { 1202 | const pullRequest = makePr('MERGEABLE') 1203 | 1204 | const octokit = github.getOctokit('justafaketoken') 1205 | const mockFunction = jest.spyOn(octokit, 'graphql').mockImplementation(jest.fn()) 1206 | await updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1207 | 1208 | expect(mockFunction).not.toBeCalled() 1209 | }) 1210 | }) 1211 | 1212 | describe('merge changes', () => { 1213 | it('removes an old label', async () => { 1214 | const pullRequest = makePr('MERGEABLE', expectedLabel) 1215 | const scope = nock('https://api.github.com', { 1216 | reqheaders: { 1217 | authorization: 'token justafaketoken' 1218 | } 1219 | }) 1220 | .get( 1221 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${pullRequest.number}/files?per_page=300` 1222 | ) 1223 | .reply(200, [ 1224 | { 1225 | sha: 'da207b42e77f336db8f7bad825daa71726ebf649', 1226 | filename: 'recipes/pango/all/conanfile.py', 1227 | status: 'modified', 1228 | patch: 1229 | '@@ -60,7 +60,7 @@ def requirements(self):\n self.requires("freetype/2.10.4")\n \n if self.options.with_fontconfi...' 1230 | } 1231 | ]) 1232 | .get( 1233 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${pullRequest.potentialMergeCommit.oid}` 1234 | ) 1235 | .reply(200, { 1236 | sha: '7ac057b641fec3b2b4a0ccdadb2b7476faca8bf0', 1237 | node_id: 'MDY6Q29tbWl0MjA0NjcxMjMyOjdhYzA1N2I2NDFmZWMzYjJiNGEwY2NkYWRiMmI3NDc2ZmFjYThiZjA=', 1238 | commit: { 1239 | author: { 1240 | name: 'SSE4', 1241 | email: 'tomskside@gmail.com', 1242 | date: '2021-03-14T00:37:50Z' 1243 | }, 1244 | committer: { 1245 | name: 'GitHub', 1246 | email: 'noreply@github.com', 1247 | date: '2021-03-14T00:37:50Z' 1248 | }, 1249 | message: 'Merge d66759bedaa040252d0ef66be5655202e324ff6c into c14910196b33ef8b99737078e284171a73418c17' 1250 | }, 1251 | author: { 1252 | login: 'SSE4', 1253 | id: 870236, 1254 | node_id: 'MDQ6VXNlcjg3MDIzNg==' 1255 | }, 1256 | committer: { 1257 | login: 'web-flow', 1258 | id: 19864447, 1259 | node_id: 'MDQ6VXNlcjE5ODY0NDQ3' 1260 | }, 1261 | parents: [ 1262 | { 1263 | sha: 'c14910196b33ef8b99737078e284171a73418c17' 1264 | }, 1265 | { 1266 | sha: 'd66759bedaa040252d0ef66be5655202e324ff6c' 1267 | } 1268 | ], 1269 | files: [ 1270 | { 1271 | sha: 'da207b42e77f336db8f7bad825daa71726ebf649', 1272 | filename: 'recipes/pango/all/conanfile.py', 1273 | status: 'modified', 1274 | patch: 1275 | '@@ -60,7 +60,7 @@ def requirements(self):\n self.requires("freetype/2.10.4")\n \n if self.options.with_fontconf...' 1276 | } 1277 | ] 1278 | }) 1279 | .post( 1280 | '/graphql', 1281 | /removeLabelsFromLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NTc4ODgyNDUw.*/ 1282 | ) 1283 | .reply(200, {data: {}}) 1284 | 1285 | const octokit = github.getOctokit('justafaketoken') 1286 | const removed = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, true) 1287 | 1288 | await expect(removed).resolves.toBe(undefined) 1289 | }) 1290 | 1291 | it('removes an old label', async () => { 1292 | const pullRequest = makePr('MERGEABLE', expectedLabel) 1293 | const scope = nock('https://api.github.com', { 1294 | reqheaders: { 1295 | authorization: 'token justafaketoken' 1296 | } 1297 | }) 1298 | .get( 1299 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${pullRequest.number}/files?per_page=300` 1300 | ) 1301 | .reply(200, [ 1302 | { 1303 | sha: 'e1dde8f65c711ea3bd2a66557650a3606bf37c7f', 1304 | filename: 'recipes/libwebp/all/conandata.yml', 1305 | status: 'modified', 1306 | patch: 1307 | '@@ -5,6 +5,9 @@ sources:\n "1.1.0":\n url: "https://github.com/webmproject/libwebp/archive/v1.1.0.ta...' 1308 | }, 1309 | { 1310 | sha: '6c1a86ff50796a44a635a5267ae7322f1c3252d6', 1311 | filename: 'recipes/libwebp/config.yml', 1312 | status: 'modified', 1313 | patch: 1314 | '@@ -3,3 +3,5 @@ versions:\n folder: all\n "1.1.0":\n folder: all\n+ "1.2.0":\n+ folder: all' 1315 | } 1316 | ]) 1317 | .get( 1318 | `/repos/${github.context.repo.owner}/${github.context.repo.repo}/commits/${pullRequest.potentialMergeCommit.oid}` 1319 | ) 1320 | .reply(200, { 1321 | sha: 'd98404b1b9ebbc0397da93b81244511ab11867fe', 1322 | node_id: 'MDY6Q29tbWl0MjA0NjcxMjMyOmQ5ODQwNGIxYjllYmJjMDM5N2RhOTNiODEyNDQ1MTFhYjExODY3ZmU=', 1323 | commit: { 1324 | author: { 1325 | name: 'SpaceIm', 1326 | email: '30052553+SpaceIm@users.noreply.github.com', 1327 | date: '2021-03-13T20:07:06Z' 1328 | }, 1329 | committer: { 1330 | name: 'GitHub', 1331 | email: 'noreply@github.com', 1332 | date: '2021-03-13T20:07:06Z' 1333 | }, 1334 | message: 'Merge 4e3af1d3e958c8ad18c374d5254a52501980432d into c14910196b33ef8b99737078e284171a73418c17' 1335 | }, 1336 | author: { 1337 | login: 'SpaceIm', 1338 | id: 30052553, 1339 | node_id: 'MDQ6VXNlcjMwMDUyNTUz' 1340 | }, 1341 | committer: { 1342 | login: 'web-flow', 1343 | id: 19864447, 1344 | node_id: 'MDQ6VXNlcjE5ODY0NDQ3' 1345 | }, 1346 | parents: [ 1347 | { 1348 | sha: 'c14910196b33ef8b99737078e284171a73418c17' 1349 | }, 1350 | { 1351 | sha: '4e3af1d3e958c8ad18c374d5254a52501980432d' 1352 | } 1353 | ], 1354 | files: [ 1355 | { 1356 | sha: 'e1dde8f65c711ea3bd2a66557650a3606bf37c7f', 1357 | filename: 'recipes/libwebp/all/conandata.yml', 1358 | status: 'modified', 1359 | patch: 1360 | '@@ -5,6 +5,9 @@ sources:\n "1.1.0":\n url: "https://github.com/webmproject/libwebp/archive/v1.1.0.ta...' 1361 | }, 1362 | { 1363 | sha: '6c1a86ff50796a44b635a5267ae7322f1c3252d6', 1364 | filename: 'recipes/libwebp/config.yml', 1365 | status: 'modified', 1366 | patch: 1367 | '@@ -3,3 +3,5 @@ versions:\n folder: all\n "1.1.0":\n folder: all\n+ "1.2.0":\n+ folder: all' 1368 | } 1369 | ] 1370 | }) 1371 | .post( 1372 | '/graphql', 1373 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1.*/ 1374 | ) 1375 | .reply(200, {data: {}}) 1376 | 1377 | const octokit = github.getOctokit('justafaketoken') 1378 | const add = updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, true) 1379 | 1380 | await expect(add).resolves.toBe(undefined) 1381 | }) 1382 | }) 1383 | 1384 | it('does nothing when mergeable is unknown', async () => { 1385 | const pullRequest = makePr('UNKNOWN') 1386 | 1387 | const octokit = github.getOctokit('justafaketoken') 1388 | const mockFunction = jest.spyOn(octokit, 'graphql').mockImplementation(jest.fn()) 1389 | await updatePullRequestConflictLabel(octokit, github.context, pullRequest, expectedLabel, false) 1390 | 1391 | expect(mockFunction).not.toBeCalled() 1392 | }) 1393 | }) 1394 | 1395 | describe('the whole sequence', () => { 1396 | test('push event works', async () => { 1397 | github.context.eventName = 'push' 1398 | 1399 | const scope = nock('https://api.github.com', { 1400 | reqheaders: { 1401 | authorization: 'token justafaketoken' 1402 | } 1403 | }) 1404 | .post('/graphql') 1405 | .reply(200, { 1406 | data: {repository: {labels: {edges: [{node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'expected_label'}}]}}} 1407 | }) 1408 | .post('/graphql') 1409 | .reply(200, { 1410 | data: { 1411 | repository: { 1412 | pullRequests: { 1413 | edges: [ 1414 | { 1415 | node: { 1416 | id: 'MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1', 1417 | number: 2109, 1418 | mergeable: 'UNKNOWN', 1419 | potentialMergeCommit: { 1420 | oid: 'dbe715994ec0bd51813f9e2b3e250c3e6b7dcf30' 1421 | }, 1422 | labels: { 1423 | edges: [ 1424 | { 1425 | node: { 1426 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1427 | name: 'Failed' 1428 | } 1429 | } 1430 | ] 1431 | } 1432 | } 1433 | }, 1434 | { 1435 | node: { 1436 | id: 'MDExOlB1bGxSZXF1ZXN0NDYxODY4OTkz', 1437 | number: 2370, 1438 | mergeable: 'MERGEABLE', 1439 | potentialMergeCommit: { 1440 | oid: 'cdb96fa3e8b19bb280fec137bd26a8144fdabeac' 1441 | }, 1442 | labels: { 1443 | edges: [ 1444 | { 1445 | node: { 1446 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1447 | name: 'Failed' 1448 | } 1449 | }, 1450 | { 1451 | node: { 1452 | id: 'MDU6TGFiZWwxNjMxNDkxOTY1', 1453 | name: 'blocked' 1454 | } 1455 | } 1456 | ] 1457 | } 1458 | } 1459 | } 1460 | ], 1461 | pageInfo: { 1462 | endCursor: 'Y3Vyc29yOnYyOpHOG4ePwQ==', 1463 | hasNextPage: false 1464 | } 1465 | } 1466 | } 1467 | } 1468 | }) 1469 | .post('/graphql') 1470 | .reply(200, { 1471 | data: { 1472 | repository: { 1473 | pullRequests: { 1474 | edges: [ 1475 | { 1476 | node: { 1477 | id: 'MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1', 1478 | number: 2109, 1479 | mergeable: 'CONFLICTING', 1480 | potentialMergeCommit: { 1481 | oid: 'dbe715994ec0bd51813f9e2b3e250c3e6b7dcf30' 1482 | }, 1483 | labels: { 1484 | edges: [ 1485 | { 1486 | node: { 1487 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1488 | name: 'Failed' 1489 | } 1490 | } 1491 | ] 1492 | } 1493 | } 1494 | }, 1495 | { 1496 | node: { 1497 | id: 'MDExOlB1bGxSZXF1ZXN0NDYxODY4OTkz', 1498 | number: 2370, 1499 | mergeable: 'MERGEABLE', 1500 | potentialMergeCommit: { 1501 | oid: 'cdb96fa3e8b19bb280fec137bd26a8144fdabeac' 1502 | }, 1503 | labels: { 1504 | edges: [ 1505 | { 1506 | node: { 1507 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1508 | name: 'Failed' 1509 | } 1510 | }, 1511 | { 1512 | node: { 1513 | id: 'MDU6TGFiZWwxNjMxNDkxOTY1', 1514 | name: 'blocked' 1515 | } 1516 | } 1517 | ] 1518 | } 1519 | } 1520 | } 1521 | ], 1522 | pageInfo: { 1523 | endCursor: 'Y3Vyc29yOnYyOpHOG4ePwQ==', 1524 | hasNextPage: false 1525 | } 1526 | } 1527 | } 1528 | } 1529 | }) 1530 | .post( 1531 | '/graphql', 1532 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1.*/ 1533 | ) 1534 | .reply(200, {data: {}}) 1535 | 1536 | const mock = jest.spyOn(core, 'setFailed').mockImplementation(jest.fn()) 1537 | 1538 | inputs['conflict_label_name'] = 'expected_label' 1539 | inputs['github_token'] = 'justafaketoken' 1540 | // inputs['max_retries'] = '1' 1541 | inputs['wait_ms'] = '25' 1542 | 1543 | expect(github.context.eventName).toBe('push') 1544 | 1545 | await run() 1546 | 1547 | expect(mock).not.toBeCalled() 1548 | }) 1549 | 1550 | test('pull_request event works', async () => { 1551 | github.context.eventName = 'pull_request' 1552 | github.context.payload = mockPullRequestEvent as any 1553 | 1554 | const scope = nock('https://api.github.com', { 1555 | reqheaders: { 1556 | authorization: 'token justafaketoken' 1557 | } 1558 | }) 1559 | .post('/graphql') 1560 | .reply(200, { 1561 | data: {repository: {labels: {edges: [{node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'expected_label'}}]}}} 1562 | }) 1563 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":2}/) 1564 | .reply(200, { 1565 | data: { 1566 | repository: { 1567 | pullRequest: { 1568 | id: 'MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1', 1569 | number: mockPullRequestEvent.number, 1570 | mergeable: 'UNKNOWN', 1571 | potentialMergeCommit: { 1572 | oid: 'dbe715994ec0bd51813f9e2b3e250c3e6b7dcf30' 1573 | }, 1574 | labels: { 1575 | edges: [ 1576 | { 1577 | node: { 1578 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1579 | name: 'Failed' 1580 | } 1581 | } 1582 | ] 1583 | } 1584 | } 1585 | } 1586 | } 1587 | }) 1588 | .post('/graphql', /\"variables\":{\"owner\":\"some-owner\",\"repo\":\"some-repo\",\"number\":2}/) 1589 | .reply(200, { 1590 | data: { 1591 | repository: { 1592 | pullRequest: { 1593 | id: 'MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1', 1594 | number: mockPullRequestEvent.number, 1595 | mergeable: 'CONFLICTING', 1596 | potentialMergeCommit: { 1597 | oid: 'dbe715994ec0bd51813f9e2b3e250c3e6b7dcf30' 1598 | }, 1599 | labels: { 1600 | edges: [ 1601 | { 1602 | node: { 1603 | id: 'MDU6TGFiZWwxNTI3NTYzMTMy', 1604 | name: 'Failed' 1605 | } 1606 | } 1607 | ] 1608 | } 1609 | } 1610 | } 1611 | } 1612 | }) 1613 | .post( 1614 | '/graphql', 1615 | /addLabelsToLabelable.*variables.*MDU6TGFiZWwyNzYwMjE1ODI0.*MDExOlB1bGxSZXF1ZXN0NDQzNTg3NjI1.*/ 1616 | ) 1617 | .reply(200, {data: {}}) 1618 | 1619 | const mock = jest.spyOn(core, 'setFailed').mockImplementation(jest.fn()) 1620 | 1621 | inputs['conflict_label_name'] = 'expected_label' 1622 | inputs['github_token'] = 'justafaketoken' 1623 | // inputs['max_retries'] = '1' 1624 | inputs['wait_ms'] = '25' 1625 | await run() 1626 | 1627 | expect(mock).not.toBeCalled() 1628 | }) 1629 | 1630 | test('fails when label does not exist', async () => { 1631 | const scope = nock('https://api.github.com', { 1632 | reqheaders: { 1633 | authorization: 'token justafaketoken' 1634 | } 1635 | }) 1636 | .post('/graphql') 1637 | .reply(200, { 1638 | data: {repository: {labels: {edges: [{node: {id: 'MDU6TGFiZWwyNzYwMjE1ODI0', name: 'expected_label'}}]}}} 1639 | }) 1640 | 1641 | const mock = jest.spyOn(core, 'setFailed').mockImplementation(jest.fn()) 1642 | 1643 | inputs['conflict_label_name'] = 'this will not match' 1644 | inputs['github_token'] = 'justafaketoken' 1645 | // inputs['max_retries'] = '1' 1646 | inputs['wait_ms'] = '25' 1647 | await run() 1648 | 1649 | expect(mock).toBeCalledWith('The label "this will not match" was not found in your repository!') 1650 | }) 1651 | }) 1652 | }) 1653 | --------------------------------------------------------------------------------