├── .node-version ├── .github ├── CODEOWNERS └── workflows │ ├── test.yml │ ├── lint.yml │ ├── codeql-analysis.yml │ └── package-check.yml ├── .eslintignore ├── .prettierignore ├── .gitattributes ├── docs ├── assets │ ├── example.png │ ├── new-github-app-1.png │ ├── new-github-app-2.png │ ├── new-github-app-3.png │ ├── new-github-app-4.png │ ├── new-github-app-5.png │ └── actions-permissions.png └── github-app-setup.md ├── .babelrc ├── .prettierrc.json ├── .eslintrc.json ├── script └── release ├── badges └── coverage.svg ├── LICENSE ├── src ├── functions │ ├── check-labels.js │ └── check-status.js └── main.js ├── package.json ├── .gitignore ├── action.yml ├── README.md ├── dist ├── licenses.txt └── sourcemap-register.js └── __tests__ └── main.test.js /.node-version: -------------------------------------------------------------------------------- 1 | 20.9.0 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @GrantBirki 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | dist/** -diff linguist-generated=true 2 | -------------------------------------------------------------------------------- /docs/assets/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/example.png -------------------------------------------------------------------------------- /docs/assets/new-github-app-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/new-github-app-1.png -------------------------------------------------------------------------------- /docs/assets/new-github-app-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/new-github-app-2.png -------------------------------------------------------------------------------- /docs/assets/new-github-app-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/new-github-app-3.png -------------------------------------------------------------------------------- /docs/assets/new-github-app-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/new-github-app-4.png -------------------------------------------------------------------------------- /docs/assets/new-github-app-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/new-github-app-5.png -------------------------------------------------------------------------------- /docs/assets/actions-permissions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/combine-prs/main/docs/assets/actions-permissions.png -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "plugins": [ 5 | "@babel/plugin-transform-modules-commonjs" 6 | ] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "arrowParens": "avoid" 10 | } 11 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "commonjs": true, 4 | "es6": true, 5 | "jest": true, 6 | "node": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "globals": { 10 | "Atomics": "readonly", 11 | "SharedArrayBuffer": "readonly" 12 | }, 13 | "parserOptions": { 14 | "ecmaVersion": 2020, 15 | "sourceType": "module" 16 | }, 17 | "rules": {} 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - main 7 | - 'releases/*' 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: setup node 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version-file: .node-version 22 | cache: 'npm' 23 | 24 | - name: install dependencies 25 | run: npm ci 26 | 27 | - name: test 28 | run: npm run ci-test 29 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: lint 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - main 7 | - 'releases/*' 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: setup node 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version-file: .node-version 22 | cache: 'npm' 23 | 24 | - name: install dependencies 25 | run: npm ci 26 | 27 | - name: lint 28 | run: | 29 | npm run format-check 30 | npm run lint 31 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: 4 | # script/release 5 | 6 | # COLORS 7 | OFF='\033[0m' 8 | RED='\033[0;31m' 9 | GREEN='\033[0;32m' 10 | BLUE='\033[0;34m' 11 | 12 | latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1)) 13 | echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}" 14 | read -p 'New Release Tag (vX.X.X format): ' new_tag 15 | 16 | tag_regex='^v\d\.\d\.\d$' 17 | echo "$new_tag" | grep -P -q $tag_regex 18 | 19 | if [[ $? -ne 0 ]]; then 20 | echo "Tag: $new_tag is valid" 21 | fi 22 | 23 | git tag -a $new_tag -m "$new_tag Release" 24 | 25 | echo -e "${GREEN}OK${OFF} - Tagged: $new_tag" 26 | 27 | git push --tags 28 | 29 | echo -e "${GREEN}OK${OFF} - Tags pushed to remote!" 30 | echo -e "${GREEN}DONE${OFF}" 31 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: CodeQL 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | # Disable on PR for now to speed up testing 7 | # pull_request: 8 | # # The branches below must be a subset of the branches above 9 | # branches: [ main ] 10 | schedule: 11 | - cron: '45 3 * * 5' 12 | 13 | jobs: 14 | analyze: 15 | name: Analyze 16 | runs-on: ubuntu-latest 17 | permissions: 18 | actions: read 19 | contents: read 20 | security-events: write 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | language: [ 'javascript' ] 26 | 27 | steps: 28 | - uses: actions/checkout@v4 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v2 33 | with: 34 | languages: ${{ matrix.language }} 35 | 36 | - name: Autobuild 37 | uses: github/codeql-action/autobuild@v2 38 | 39 | - name: Perform CodeQL Analysis 40 | uses: github/codeql-action/analyze@v2 41 | -------------------------------------------------------------------------------- /badges/coverage.svg: -------------------------------------------------------------------------------- 1 | Coverage: 100%Coverage100% -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GitHub 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/functions/check-labels.js: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | 3 | export async function checkLabels(pull, branch, selectLabel, ignoreLabel) { 4 | core.info('Checking labels: ' + branch) 5 | const labels = pull['labels'] 6 | 7 | if (selectLabel) { 8 | let matchesSelectLabel = false 9 | for (const label of labels) { 10 | const labelName = label['name'] 11 | core.info('Checking select_label for: ' + labelName) 12 | if (labelName == selectLabel) { 13 | matchesSelectLabel = true 14 | break 15 | } 16 | } 17 | if (!matchesSelectLabel) { 18 | core.info( 19 | 'Discarding ' + branch + ' because it does not match select_label' 20 | ) 21 | return false 22 | } 23 | } 24 | 25 | if (ignoreLabel) { 26 | for (const label of labels) { 27 | const labelName = label['name'] 28 | core.info('Checking ignore_label for: ' + labelName) 29 | if (labelName == ignoreLabel) { 30 | core.info( 31 | 'Discarding ' + 32 | branch + 33 | ' with label ' + 34 | labelName + 35 | ' because it matches ignore_label' 36 | ) 37 | return false 38 | } 39 | } 40 | } 41 | 42 | return true 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/package-check.yml: -------------------------------------------------------------------------------- 1 | name: package-check 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | package-check: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - name: setup node 21 | uses: actions/setup-node@v4 22 | with: 23 | node-version-file: .node-version 24 | cache: 'npm' 25 | 26 | - name: install dependencies 27 | run: npm ci 28 | 29 | - name: rebuild the dist/ directory 30 | run: npm run bundle 31 | 32 | - name: compare the expected and actual dist/ directories 33 | run: | 34 | if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then 35 | echo "Detected uncommitted changes after build. See status below:" 36 | git diff 37 | exit 1 38 | fi 39 | id: diff 40 | 41 | # If index.js was different than expected, upload the expected version as an artifact 42 | - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # pin@v3.1.2 43 | if: ${{ failure() && steps.diff.conclusion == 'failure' }} 44 | with: 45 | name: dist 46 | path: dist/ 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Combine multiple PRs into a single PR", 3 | "main": "lib/main.js", 4 | "scripts": { 5 | "format": "prettier --write '**/*.js'", 6 | "format-check": "prettier --check '**/*.js'", 7 | "lint": "eslint src/**/*.js", 8 | "package": "ncc build src/main.js -o dist --source-map --license licenses.txt", 9 | "test": "(COMBINE_PRS_TEST=true jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg", 10 | "ci-test": "COMBINE_PRS_TEST=true jest", 11 | "all": "npm run format && npm run lint && npm run package", 12 | "bundle": "npm run format && npm run package" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/github/combine-prs.git" 17 | }, 18 | "keywords": [ 19 | "actions", 20 | "dependencies", 21 | "dependabot", 22 | "github", 23 | "pull requests", 24 | "automation" 25 | ], 26 | "author": "Grant Birkinbine", 27 | "license": "MIT", 28 | "dependencies": { 29 | "@actions/core": "^1.10.1", 30 | "@actions/github": "^6.0.0" 31 | }, 32 | "jest": { 33 | "coverageReporters": [ 34 | "json-summary", 35 | "text", 36 | "lcov" 37 | ], 38 | "collectCoverage": true, 39 | "collectCoverageFrom": [ 40 | "./src/**" 41 | ], 42 | "coverageThreshold": { 43 | "global": { 44 | "lines": 100, 45 | "functions": 100 46 | } 47 | } 48 | }, 49 | "devDependencies": { 50 | "@babel/plugin-transform-modules-commonjs": "^7.25.7", 51 | "@octokit/rest": "^21.0.2", 52 | "@types/node": "^22.7.5", 53 | "@vercel/ncc": "^0.38.2", 54 | "eslint": "^8.52.0", 55 | "eslint-plugin-jest": "^28.8.3", 56 | "jest": "^29.7.0", 57 | "make-coverage-badge": "^1.2.0", 58 | "prettier": "3.3.3" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.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 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | .env.test 68 | 69 | # parcel-bundler cache (https://parceljs.org/) 70 | .cache 71 | 72 | # next.js build output 73 | .next 74 | 75 | # nuxt.js build output 76 | .nuxt 77 | 78 | # vuepress build output 79 | .vuepress/dist 80 | 81 | # Serverless directories 82 | .serverless/ 83 | 84 | # FuseBox cache 85 | .fusebox/ 86 | 87 | # DynamoDB Local files 88 | .dynamodb/ 89 | 90 | # OS metadata 91 | .DS_Store 92 | Thumbs.db 93 | 94 | # Ignore built ts files 95 | __tests__/runner/* 96 | lib/**/* 97 | 98 | # Extra 99 | tmp 100 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "combine-prs" 2 | description: "Combine multiple PRs into a single PR" 3 | author: "Grant Birkinbine" 4 | branding: 5 | icon: 'git-branch' 6 | color: 'gray-dark' 7 | inputs: 8 | github_token: 9 | description: The GitHub token used to create an authenticated client - Provided for you by default! 10 | default: ${{ github.token }} 11 | required: true 12 | branch_prefix: 13 | description: The prefix of the branches to combine 14 | required: true 15 | default: dependabot 16 | pr_title: 17 | description: The title of the pull request to create 18 | required: true 19 | default: "Combined PRs" 20 | pr_body_header: 21 | description: The header of the pull request body 22 | required: true 23 | default: "# Combined PRs ➡️📦⬅️" 24 | min_combine_number: 25 | description: The minimum number of PRs that have to match criteria in order to create a combined PR 26 | required: true 27 | default: "2" 28 | branch_regex: 29 | description: The regex to match the branches to combine - more control than branch_prefix 30 | required: false 31 | default: "" 32 | ci_required: 33 | description: Whether or not CI should be passing to combine the PR 34 | required: true 35 | default: "true" 36 | review_required: 37 | description: Whether or not a review should be required to combine the PR 38 | required: false 39 | default: "false" 40 | combine_branch_name: 41 | description: The name of the branch to combine the PRs into 42 | required: true 43 | default: "combined-prs-branch" 44 | ignore_label: 45 | description: The label to ignore when combining PRs 46 | required: true 47 | default: "nocombine" 48 | select_label: 49 | description: The label marking PRs that should be combined 50 | required: false 51 | default: "" 52 | labels: 53 | description: A comma seperated list of labels to add to the combined PR 54 | required: false 55 | default: "" 56 | assignees: 57 | description: A comma seperated list of assignees to add to the combined PR 58 | required: false 59 | default: "" 60 | autoclose: 61 | description: Whether or not to close combined PRs if the combined PR is merged 62 | required: false 63 | default: "true" 64 | update_branch: 65 | description: Whether or not to update the combined branch with the latest changes from the base branch after creating the combined pull request 66 | default: "true" 67 | required: false 68 | create_from_scratch: 69 | description: Whether or not to start from a clean base branch when (re)creating the combined PR 70 | default: "false" 71 | required: false 72 | outputs: 73 | pr_url: 74 | description: The pull request URL if a PR was created 75 | pr_number: 76 | description: The pull request number if a PR was created 77 | runs: 78 | using: "node20" 79 | main: "dist/index.js" 80 | -------------------------------------------------------------------------------- /src/functions/check-status.js: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import {context} from '@actions/github' 3 | 4 | export async function checkStatus( 5 | pull, 6 | branch, 7 | octokit, 8 | mustBeGreen, 9 | mustBeApproved 10 | ) { 11 | let statusOK = true 12 | 13 | // If we are running in a mode that checks for passing CI or approved PRs, then we need to check the status of the PR 14 | if (mustBeGreen || mustBeApproved) { 15 | core.info('Checking green status: ' + branch) 16 | const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) { 17 | repository(owner: $owner, name: $repo) { 18 | pullRequest(number:$pull_number) { 19 | reviewDecision 20 | commits(last: 1) { 21 | nodes { 22 | commit { 23 | statusCheckRollup { 24 | state 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | }` 32 | const vars = { 33 | owner: context.repo.owner, 34 | repo: context.repo.repo, 35 | pull_number: pull['number'] 36 | } 37 | const result = await octokit.graphql(stateQuery, vars) 38 | 39 | // Check for CI status 40 | if (mustBeGreen) { 41 | const [{commit}] = result?.repository?.pullRequest?.commits?.nodes ?? null 42 | 43 | // If CI checks have been defined for the given pull request / commit 44 | if (commit?.statusCheckRollup) { 45 | const state = commit?.statusCheckRollup?.state 46 | core.info('Validating status: ' + state) 47 | if (state !== 'SUCCESS') { 48 | core.info('Discarding ' + branch + ' with status ' + state) 49 | statusOK = false 50 | } 51 | 52 | // If no CI checks have been defined for the given pull request / commit 53 | } else { 54 | core.info('No status check(s) associated with branch: ' + branch) 55 | } 56 | } 57 | 58 | // Check for review approval 59 | if (mustBeApproved) { 60 | const reviewDecision = result.repository.pullRequest.reviewDecision 61 | core.info('Validating review decision: ' + reviewDecision) 62 | if (reviewDecision === 'APPROVED') { 63 | core.info('Branch ' + branch + ' is approved') 64 | } else if (reviewDecision === null) { 65 | // In this case, reviewDecision will be null if no reviews are required 66 | core.info('Branch ' + branch + ' has no required reviewers - OK') 67 | } else { 68 | core.info( 69 | 'Discarding ' + branch + ' with review decision ' + reviewDecision 70 | ) 71 | statusOK = false 72 | } 73 | } 74 | } 75 | 76 | return statusOK 77 | } 78 | -------------------------------------------------------------------------------- /docs/github-app-setup.md: -------------------------------------------------------------------------------- 1 | # GitHub App Setup 2 | 3 | This section goes into detail on how to use a [GitHub App](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps) to generate a token that can be used to run the `combine-prs` Action. 4 | 5 | ## Why use a GitHub App? 6 | 7 | GitHub Apps are more scalable than personal access tokens. They also have a higher rate limit than personal access tokens. 8 | 9 | ## Security Considerations 10 | 11 | Using private keys from one GitHub App across multiple repositories carries inherent risk, especially if the GitHub App has `write` permissions for repository `contents`. This is because each repository where the app is installed can use the private key to perform actions as the GitHub App on any other repository where the app is installed. Another risk is that if one repository has weak security controls and the key is exposed, all repositories that have installed the app are at risk as well. Even if the private keys are different on each repository, all private keys allow the same access and are intended for redundancy rather than segregating access. 12 | 13 | The exact same risks apply when using a GitHub (classic) PAT with `write` permissions for repository `contents`. The difference is that the PAT is tied to a user account, and the user account is likely to have access to many more repositories than the GitHub App (making it even less secure). 14 | 15 | The ideal approach would be to use a fine-grained personal access token (tied to a bot/service account). Each PAT would then be scoped to a single repository. This would be more secure, but would also be more cumbersome to manage at scale. 16 | 17 | ## Setting up a GitHub App 18 | 19 | Before we can write up the `combine-prs` Action, we need to create a GitHub App. You can do this by going to `Settings` > `Developer settings` > `GitHub Apps` > `New GitHub App`. 20 | 21 | Follow along with the screenshots below to create a new GitHub App: 22 | 23 | ![new-github-app-1](assets/new-github-app-1.png) 24 | 25 | Enter a unique name for your GitHub App, a meaningful description, and any link you want. Ensure you expire user authorization tokens. 26 | 27 | ![new-github-app-2](assets/new-github-app-2.png) 28 | 29 | Keep all the defaults in the next section as indicated by the screenshot. The only thing you will want to do in this section is disable the `Webhook` option. Ensure `Active` is "unchecked". 30 | 31 | ![new-github-app-3](assets/new-github-app-3.png) 32 | 33 | In this section, you will want to enable the following repository permissions: 34 | 35 | - Commit statuses: `Read-only` 36 | - Contents: `Read and write` 37 | - Metadata: `Read-only` 38 | - Pull requests: `Read and write` 39 | 40 | Also ensure that you select `Only on this account` for the installation option. 41 | 42 | Now you can go ahead and create your GitHub App! 43 | 44 | ## Configuring Secrets 45 | 46 | In order for your `combine-prs` Action workflow to properly run, you will need to configure two secrets for your workflow using credentials from the GitHub App you just created. 47 | 48 | ### `APP_ID` 49 | 50 | You can find your applications ID on the `General` page of your GitHub App. It will be listed as `App ID`. 51 | 52 | ![new-github-app-4](assets/new-github-app-4.png) 53 | 54 | Make note of your `APP_ID` as we will use it shortly 55 | 56 | ### `PRIVATE_KEY` 57 | 58 | You will now need to generate a private key for your GitHub App. This section will also be located on the `General` page of your GitHub App. 59 | 60 | ![new-github-app-5](assets/new-github-app-5.png) 61 | 62 | > Note: When you generate a private key, it will download a `.pem` file. You will need to copy the contents of this file and paste it into your secret. 63 | 64 | Make note of your `PRIVATE_KEY` as we will use it shortly. 65 | 66 | ### Setting Secrets 67 | 68 | Now that you have the values of both your `APP_ID` and `PRIVATE_KEY`, you can go ahead and set them as secrets in your repository. Where you wish to run the `combine-prs` Action, go to `Settings` > `Secrets` > `New repository secret`. Create the following two secrets: 69 | 70 | - `APP_ID`: The ID of your GitHub App 71 | - `PRIVATE_KEY`: The private key of your GitHub App 72 | 73 | ## Setting up the `combine-prs` Action 74 | 75 | Now that the GitHub App is set up and the secrets are configured, we can go ahead and set up the `combine-prs` Action. *Finally*! 76 | 77 | The following open source [Action](https://github.com/marketplace/actions/use-app-token) helps to generate a GitHub App token for you which can then be passed into the `combine-prs` Action. 78 | 79 | Here is the example workflow that you can use to run the `combine-prs` Action with a GitHub App: 80 | 81 | ```yaml 82 | name: Combine PRs 83 | 84 | on: 85 | schedule: 86 | - cron: '0 1 * * 3' # Wednesday at 01:00 87 | workflow_dispatch: 88 | 89 | # The minimum permissions to run this workflow 90 | permissions: 91 | contents: write 92 | pull-requests: write 93 | checks: read 94 | 95 | jobs: 96 | combine-prs: 97 | runs-on: ubuntu-latest 98 | 99 | steps: 100 | - name: Use GitHub App Token 101 | uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e # pin@v1.5.1 102 | id: app-token 103 | with: 104 | app-id: ${{ secrets.APP_ID }} # The ID of the GitHub App 105 | private-key: ${{ secrets.PRIVATE_KEY }} # The private key of the GitHub App 106 | 107 | - name: combine-prs 108 | uses: github/combine-prs@vX.X.X # where X.X.X is the latest version 109 | with: 110 | github_token: ${{ steps.app-token.outputs.token }} # A GitHub app token generated by the previous step 111 | labels: combined-pr 112 | ``` 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # combine-prs ➡️📦⬅️ 2 | 3 | [![test](https://github.com/github/combine-prs/actions/workflows/test.yml/badge.svg)](https://github.com/github/combine-prs/actions/workflows/test.yml) [![lint](https://github.com/github/combine-prs/actions/workflows/lint.yml/badge.svg)](https://github.com/github/combine-prs/actions/workflows/lint.yml) [![CodeQL](https://github.com/github/combine-prs/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/github/combine-prs/actions/workflows/codeql-analysis.yml) [![package-check](https://github.com/github/combine-prs/actions/workflows/package-check.yml/badge.svg)](https://github.com/github/combine-prs/actions/workflows/package-check.yml) [![coverage](./badges/coverage.svg)](./badges/coverage.svg) 4 | 5 | GitHub Action to combine multiple PRs into a single one 6 | 7 | ## About 💡 8 | 9 | GitHub uses this Action to combine multiple dependabot PRs into a single one. Rather than having to deploy each PR individually, we can run this Action on a `cron` or `workflow_dispatch` to combine all the PRs into a single one to make dependency management just a little bit easier. 10 | 11 | This Action is customizable so you can use it for your own purposes and it doesn't have to be specific to dependabot PRs. 12 | 13 | ## Notice 📢 14 | 15 | > [!NOTE] 16 | > A notice around the [Dependabot Grouped Version Updates feature](https://github.blog/changelog/2023-06-30-grouped-version-updates-for-dependabot-public-beta/) 17 | 18 | As mentioned above is this README, a core reason why this Action exists is to "combine multiple Dependabot PRs into one". Work for this Action was completed before the [GitHub Blog Post](https://github.blog/changelog/2023-06-30-grouped-version-updates-for-dependabot-public-beta/) was published and the Dependabot Grouped Version Updates feature was released. While it may seem like this Action is no longer needed due to this feature, there are actually still quite a few use cases for this Action. The first one that is front of mind is that the PRs which Dependabot opens are grouped by package manager. This means that if you have a project that uses multiple package managers, you'll still end up with multiple PRs. This Action can be used to combine those PRs into a single one. You may also want to combine pull requests that are not related to Dependabot in anyway, which this Action can also do. 19 | 20 | ## Inputs 📝 21 | 22 | | Name | Description | Default | Required | 23 | | ---- | ----------- | ------- | -------- | 24 | | `github_token` | GitHub token to use for authentication within this Action. Provided for you by default! | `${{ github.token }}` | `true` | 25 | | `branch_prefix` | Prefix for the branch name to use for the combined PR | `dependabot` | `true` | 26 | | `combine_branch_name` | The branch name to use for the combined PR | `combined-prs-branch` | `false` | 27 | | `pr_title` | The title of the pull request to create | `Combined PRs` | `true` | 28 | | `pr_body_header` | The header of the pull request body | `# Combined PRs ➡️📦⬅️` | `true` | 29 | | `min_combine_number` | The minimum number of PRs that have to match criteria in order to create a combined PR | `"2"` | `true` | 30 | | `branch_regex` | The regex to match the branches to combine - more control than branch_prefix | `""` | `false` | 31 | | `ci_required` | Whether or not CI should be passing to combine the PR - can be `"true"` or `"false"` | `"true"` | `true` | 32 | | `review_required` | Whether or not reviews should be passing to combine the PR - can be `"true"` or `"false"` | `"false"` | `false` | 33 | | `ignore_label` | The label to ignore when combining PRs | `"nocombine"` | `true` | 34 | | `select_label` | The label which marks PRs that should be combined. Leave empty to consider all PRs. | `""` | `false` | 35 | | `labels` | A comma separated list of labels to add to the combined PR - Example: `dependencies,combined-pr,etc` | `""` | `false` | 36 | | `assignees` | A comma separated list of assignees the combined PR is assigned to - Example: `octocat` | `""` | `false` | 37 | | `autoclose` | Whether or not to close combined PRs if the combined PR is merged - can be `"true"` or `"false"` | `"true"` | `false` | 38 | | `update_branch` | Whether or not to update the combined branch with the latest changes from the base branch after creating the combined pull request | `"true"` | `false` | 39 | | `create_from_scratch` | Whether or not to start from a clean base branch when (re)creating the combined PR | `"false"` | `false` | 40 | 41 | ## Outputs 📤 42 | 43 | | Name | Description | 44 | | ---- | ----------- | 45 | | `pr_url` | The pull request URL if a PR was created | 46 | | `pr_number` | The pull request number if a PR was created | 47 | 48 | ## Example 📸 49 | 50 | Here is a PR example of this Action: 51 | 52 | ![example](docs/assets/example.png) 53 | 54 | The Action ran on a cron, looked for all branches that had the `dependabot` prefix and then combined them into a single PR. Three pull requests were successfully combined and one was left out due to merge conflicts. 55 | 56 | This allows us to deploy all the dependency updates at once rather than having to deploy each one individually. 57 | 58 | ## Usage 💻 59 | 60 | Here is a brief example of how to use this Action in a workflow: 61 | 62 | ```yaml 63 | name: Combine PRs 64 | 65 | on: 66 | schedule: 67 | - cron: '0 1 * * 3' # Wednesday at 01:00 68 | workflow_dispatch: # allows you to manually trigger the workflow 69 | 70 | # The minimum permissions required to run this Action 71 | permissions: 72 | contents: write 73 | pull-requests: write 74 | checks: read 75 | 76 | jobs: 77 | combine-prs: 78 | runs-on: ubuntu-latest 79 | 80 | steps: 81 | - name: combine-prs 82 | id: combine-prs 83 | uses: github/combine-prs@vX.X.X # where X.X.X is the latest version 84 | with: 85 | labels: combined-pr # Optional: add a label to the combined PR 86 | ``` 87 | 88 | ## Permissions 89 | 90 | This Action requires the following permissions: 91 | 92 | ```yaml 93 | # The minimum permissions required to run this Action 94 | permissions: 95 | contents: write # to create a new branch and merge other branches together 96 | pull-requests: write # to create a new PR with the combined changes 97 | checks: read # to check if CI is passing or not before combining PRs 98 | ``` 99 | 100 | This Action also requires that GitHub Action's has permissions to create new pull requests. You can read more about this feature here: [GitHub Blog Post](https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/) 101 | 102 | To enable this setting, go to `Actions` > `General` > `Workflow permissions` in your repository settings. Check the following box and click save: 103 | 104 | ![permissions](docs/assets/actions-permissions.png) 105 | 106 | ## Regex Branch Patterns 107 | 108 | By default, this Action uses the `branch_prefix` option set to `dependabot` to match the branches to combine. However, you can also use the `branch_regex` option to match branches using a regex pattern. This is useful if you want to match branches that don't have a specific prefix. 109 | 110 | `branch_regex` is a string representing a regex pattern 111 | 112 | If `branch_regex` is set, `branch_prefix` will be ignored. 113 | 114 | ## CI and Action's Token 🤖 115 | 116 | If you need CI to re-run on your newly created "combined" PR, you'll need to use a token that has write access to your repository. This is because the default `github.token` that is provided to Actions prevents CI from running on new commits to prevent recursive workflows. You can use a personal access token or a GitHub App token to get around this. 117 | 118 | ```yaml 119 | - name: combine-prs 120 | id: combine-prs 121 | uses: github/combine-prs@vX.X.X # where X.X.X is the latest version 122 | with: 123 | github_token: ${{ secrets.PAT }} # where PAT is a GitHub Action's secret containing a personal access token 124 | ``` 125 | 126 | ### GitHub App Setup 127 | 128 | Alternatively, you can use a GitHub App token. This is the **recommended** approach as it is **more secure** than a personal access token and a lot more scalable for large organizations. 129 | 130 | Checkout the dedicated [documentation here](docs/github-app-setup.md) for more information on how to set this up. 131 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as github from '@actions/github' 3 | import {context} from '@actions/github' 4 | import {checkLabels} from './functions/check-labels' 5 | import {checkStatus} from './functions/check-status' 6 | 7 | const repoName = 'github/combine-prs' 8 | const repoUrl = 'https://github.com/github/combine-prs' 9 | 10 | export async function run() { 11 | // Get configuration inputs 12 | const branchPrefix = core.getInput('branch_prefix') 13 | const branchRegex = core.getInput('branch_regex') 14 | const mustBeGreen = core.getInput('ci_required') === 'true' 15 | const mustBeApproved = core.getInput('review_required') === 'true' 16 | const combineBranchName = core.getInput('combine_branch_name') 17 | const ignoreLabel = core.getInput('ignore_label') 18 | const selectLabel = core.getInput('select_label') 19 | const labels = core.getInput('labels').trim() 20 | const assignees = core.getInput('assignees').trim() 21 | const token = core.getInput('github_token', {required: true}) 22 | const prTitle = core.getInput('pr_title', {required: true}) 23 | const prBodyHeader = core.getInput('pr_body_header', {required: true}) 24 | const minCombineNumber = parseInt( 25 | core.getInput('min_combine_number', {required: true}) 26 | ) 27 | const autoclose = core.getInput('autoclose') === 'true' 28 | const updateBranch = core.getBooleanInput('update_branch') 29 | const createFromScratch = core.getBooleanInput('create_from_scratch') 30 | 31 | // check for either prefix or regex 32 | if (branchPrefix === '' && branchRegex === '') { 33 | core.setFailed('Must specify either branch_prefix or branch_regex') 34 | return 'Must specify either branch_prefix or branch_regex' 35 | } 36 | 37 | // check valid label config 38 | if (ignoreLabel && selectLabel && ignoreLabel == selectLabel) { 39 | core.setFailed('ignore_label and select_label cannot have the same value') 40 | return 'ignore_label and select_label cannot have the same value' 41 | } 42 | 43 | // Create a octokit GitHub client 44 | const octokit = github.getOctokit(token) 45 | 46 | // Get all open pull requests in the repository 47 | const pulls = await octokit.paginate('GET /repos/:owner/:repo/pulls', { 48 | owner: context.repo.owner, 49 | repo: context.repo.repo 50 | }) 51 | 52 | // Filter the pull requests by branch prefix and CI status 53 | let branchesAndPRStrings = [] 54 | let baseBranch = null 55 | let baseBranchSHA = null 56 | for (const pull of pulls) { 57 | const branch = pull['head']['ref'] 58 | core.info('Pull for branch: ' + branch) 59 | 60 | // Check branch with branch_regex 61 | if (branchRegex !== '') { 62 | const regex = new RegExp(branchRegex) 63 | if (regex.test(branch)) { 64 | core.info('Branch matched regex: ' + branch) 65 | } else { 66 | core.info('Branch did not match regex: ' + branch) 67 | continue 68 | } 69 | } else { 70 | // If no regex, check branch with branch_prefix 71 | if (branch.startsWith(branchPrefix)) { 72 | core.info('Branch matched prefix: ' + branch) 73 | } else { 74 | continue 75 | } 76 | } 77 | 78 | // Check labels 79 | let statusOK = await checkLabels(pull, branch, selectLabel, ignoreLabel) 80 | 81 | // Check CI status or review status if required 82 | statusOK = 83 | statusOK && 84 | (await checkStatus(pull, branch, octokit, mustBeGreen, mustBeApproved)) 85 | 86 | if (statusOK) { 87 | core.info('Adding branch to array: ' + branch) 88 | const prString = `${autoclose ? 'Closes ' : ''}#${pull['number']} ${ 89 | pull['title'] 90 | }` 91 | branchesAndPRStrings.push({branch, prString}) 92 | baseBranch = pull['base']['ref'] 93 | baseBranchSHA = pull['base']['sha'] 94 | } 95 | } 96 | 97 | // If no branches match, exit 98 | if (branchesAndPRStrings.length === 0) { 99 | core.info('No PRs/branches matched criteria') 100 | return 'No PRs/branches matched criteria' 101 | } 102 | 103 | // If not enough branches match given min_combine_number, exit 104 | if (branchesAndPRStrings.length < minCombineNumber) { 105 | core.info( 106 | `Not enough PRs/branches matched criteria to create a combined PR - matched ${branchesAndPRStrings.length} branches/PRs but need ${minCombineNumber} branches/PRs` 107 | ) 108 | return 'not enough PRs/branches matched criteria to create a combined PR' 109 | } 110 | 111 | let workingRef = combineBranchName 112 | if (createFromScratch) { 113 | workingRef = combineBranchName + '-working' 114 | 115 | // delete any pre-existing working branch 116 | try { 117 | await octokit.rest.git.deleteRef({ 118 | owner: context.repo.owner, 119 | repo: context.repo.repo, 120 | ref: 'heads/' + workingRef 121 | }) 122 | } catch (error) { 123 | // If the branch doesn't exist, that's fine 124 | // istanbul ignore next 125 | core.debug(`branch ${workingRef} not found - OK`) 126 | } 127 | 128 | // create our working branch 129 | try { 130 | await octokit.rest.git.createRef({ 131 | owner: context.repo.owner, 132 | repo: context.repo.repo, 133 | ref: 'refs/heads/' + workingRef, 134 | sha: baseBranchSHA 135 | }) 136 | } catch (error) { 137 | // Otherwise, fail the Action 138 | core.error(error) 139 | core.setFailed('Failed to create working branch') 140 | return 'Failed to create working branch' 141 | } 142 | } 143 | 144 | // Create a new branch 145 | try { 146 | await octokit.rest.git.createRef({ 147 | owner: context.repo.owner, 148 | repo: context.repo.repo, 149 | ref: 'refs/heads/' + combineBranchName, 150 | sha: baseBranchSHA 151 | }) 152 | } catch (error) { 153 | // If the branch already exists, we'll try to merge into it 154 | if (error.status == 422) { 155 | core.warning('Branch already exists - will try to merge into it') 156 | } else { 157 | // Otherwise, fail the Action 158 | core.error(error) 159 | core.setFailed('Failed to create combined branch') 160 | return 'Failed to create combined branch' 161 | } 162 | } 163 | 164 | // Merge all branches into the new branch 165 | let combinedPRs = [] 166 | let mergeFailedPRs = [] 167 | for (const {branch, prString} of branchesAndPRStrings) { 168 | try { 169 | await octokit.rest.repos.merge({ 170 | owner: context.repo.owner, 171 | repo: context.repo.repo, 172 | base: workingRef, 173 | head: branch 174 | }) 175 | core.info('Merged branch ' + branch) 176 | combinedPRs.push(prString) 177 | } catch (error) { 178 | core.warning('Failed to merge branch ' + branch) 179 | mergeFailedPRs.push(prString.replace('Closes ', '')) 180 | } 181 | } 182 | 183 | if (createFromScratch) { 184 | // Get the updated ref of the working branch 185 | const { 186 | data: {object: workingRefObject} 187 | } = await octokit.rest.git.getRef({ 188 | owner: context.repo.owner, 189 | repo: context.repo.repo, 190 | ref: 'heads/' + workingRef 191 | }) 192 | 193 | // Update the PR branch to the latest commit of the working branch 194 | await octokit.rest.git.updateRef({ 195 | owner: context.repo.owner, 196 | repo: context.repo.repo, 197 | ref: 'heads/' + combineBranchName, 198 | sha: workingRefObject.sha, 199 | force: true 200 | }) 201 | 202 | // Delete the temp working branch 203 | await octokit.rest.git.deleteRef({ 204 | owner: context.repo.owner, 205 | repo: context.repo.repo, 206 | ref: 'heads/' + workingRef 207 | }) 208 | } 209 | 210 | // Create a new PR with the combined branch 211 | core.info('Creating combined PR') 212 | const combinedPRsString = `- ${combinedPRs.join('\n- ')}` 213 | let body = `${prBodyHeader}\n\n✅ The following pull requests have been successfully combined on this PR:\n${combinedPRsString}` 214 | if (mergeFailedPRs.length > 0) { 215 | const mergeFailedPRsString = `- ${mergeFailedPRs.join('\n- ')}` 216 | body += 217 | '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + 218 | mergeFailedPRsString 219 | } 220 | 221 | body += `\n\n> This PR was created by the [\`${repoName}\`](${repoUrl}) action` 222 | 223 | core.debug('PR body: ' + body) 224 | 225 | var pullRequest 226 | try { 227 | pullRequest = await octokit.rest.pulls.create({ 228 | owner: context.repo.owner, 229 | repo: context.repo.repo, 230 | title: prTitle, 231 | head: combineBranchName, 232 | base: baseBranch, 233 | body: body 234 | }) 235 | } catch (error) { 236 | if (error?.status === 422) { 237 | core.warning('Combined PR already exists') 238 | // update the PR body 239 | const prs = await octokit.rest.pulls.list({ 240 | owner: context.repo.owner, 241 | repo: context.repo.repo, 242 | head: context.repo.owner + ':' + combineBranchName, 243 | base: baseBranch, 244 | state: 'open' 245 | }) 246 | const pr = prs.data[0] 247 | core.info('Updating PR body') 248 | await octokit.rest.pulls.update({ 249 | owner: context.repo.owner, 250 | repo: context.repo.repo, 251 | pull_number: pr.number, 252 | body: body 253 | }) 254 | pullRequest = {data: pr} 255 | } else { 256 | if ( 257 | error?.message?.includes( 258 | 'GitHub Actions is not permitted to create or approve pull requests' 259 | ) 260 | ) { 261 | core.warning( 262 | 'https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/' 263 | ) 264 | } 265 | 266 | core.setFailed(`Failed to create combined PR - ${error}`) 267 | return 'failure' 268 | } 269 | } 270 | 271 | // check the combined PR's state to see if it is closed 272 | const combinedPRState = pullRequest.data.state 273 | if (combinedPRState === 'closed') { 274 | core.info('Combined PR is closed - attempting to reopen') 275 | await octokit.rest.pulls.update({ 276 | owner: context.repo.owner, 277 | repo: context.repo.repo, 278 | pull_number: pullRequest.data.number, 279 | state: 'open' 280 | }) 281 | } 282 | 283 | if (labels !== '') { 284 | // split and trim labels 285 | const labelsArray = labels.split(',').map(label => label.trim()) 286 | 287 | // add labels to the combined PR if specified 288 | if (labelsArray.length > 0) { 289 | core.info(`Adding labels to combined PR: ${labelsArray}`) 290 | await octokit.rest.issues.addLabels({ 291 | owner: context.repo.owner, 292 | repo: context.repo.repo, 293 | issue_number: pullRequest.data.number, 294 | labels: labelsArray 295 | }) 296 | } 297 | } 298 | 299 | if (assignees !== '') { 300 | // split and trim assignees 301 | const assigneesArray = assignees.split(',').map(assignee => assignee.trim()) 302 | 303 | // add assignees to the combined PR if specified 304 | if (assigneesArray.length > 0) { 305 | core.info(`Adding assignees to combined PR: ${assigneesArray}`) 306 | await octokit.rest.issues.addAssignees({ 307 | owner: context.repo.owner, 308 | repo: context.repo.repo, 309 | issue_number: pullRequest.data.number, 310 | assignees: assigneesArray 311 | }) 312 | } 313 | } 314 | 315 | // lastly, if the pull request's branch can be updated cleanly, update it 316 | if (updateBranch === true) { 317 | core.info('Attempting to update branch') 318 | try { 319 | const result = await octokit.rest.pulls.updateBranch({ 320 | owner: context.repo.owner, 321 | repo: context.repo.repo, 322 | pull_number: pullRequest.data.number 323 | }) 324 | 325 | // If the result is not a 202, return an error message and exit 326 | if (result.status !== 202) { 327 | throw new Error( 328 | `Failed to update combined pr branch with the base branch - ${result}` 329 | ) 330 | } 331 | 332 | core.info('Branch updated') 333 | } catch (error) { 334 | core.warning('Failed to update combined pr branch with the base branch') 335 | core.warning(error) 336 | } 337 | } 338 | 339 | // output pull request url 340 | core.info('Combined PR url: ' + pullRequest.data.html_url) 341 | core.setOutput('pr_url', pullRequest.data.html_url) 342 | 343 | // output pull request number 344 | core.info('Combined PR number: ' + pullRequest.data.number) 345 | core.setOutput('pr_number', pullRequest.data.number) 346 | 347 | return 'success' 348 | } 349 | 350 | // Do not run if this is a test 351 | if (process.env.COMBINE_PRS_TEST !== 'true') { 352 | /* istanbul ignore next */ 353 | run() 354 | } 355 | -------------------------------------------------------------------------------- /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/exec 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/github 26 | MIT 27 | The MIT License (MIT) 28 | 29 | Copyright 2019 GitHub 30 | 31 | 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: 32 | 33 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 34 | 35 | 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. 36 | 37 | @actions/http-client 38 | MIT 39 | Actions Http Client for Node.js 40 | 41 | Copyright (c) GitHub, Inc. 42 | 43 | All rights reserved. 44 | 45 | MIT License 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 48 | associated documentation files (the "Software"), to deal in the Software without restriction, 49 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 50 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 51 | subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 56 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 57 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 58 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 59 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 60 | 61 | 62 | @actions/io 63 | MIT 64 | The MIT License (MIT) 65 | 66 | Copyright 2019 GitHub 67 | 68 | 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: 69 | 70 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 71 | 72 | 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. 73 | 74 | @fastify/busboy 75 | MIT 76 | Copyright Brian White. All rights reserved. 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to 80 | deal in the Software without restriction, including without limitation the 81 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 82 | sell copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in 86 | all copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 93 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 94 | IN THE SOFTWARE. 95 | 96 | @octokit/auth-token 97 | MIT 98 | The MIT License 99 | 100 | Copyright (c) 2019 Octokit contributors 101 | 102 | Permission is hereby granted, free of charge, to any person obtaining a copy 103 | of this software and associated documentation files (the "Software"), to deal 104 | in the Software without restriction, including without limitation the rights 105 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 106 | copies of the Software, and to permit persons to whom the Software is 107 | furnished to do so, subject to the following conditions: 108 | 109 | The above copyright notice and this permission notice shall be included in 110 | all copies or substantial portions of the Software. 111 | 112 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 113 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 114 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 115 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 116 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 117 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 118 | THE SOFTWARE. 119 | 120 | 121 | @octokit/core 122 | MIT 123 | The MIT License 124 | 125 | Copyright (c) 2019 Octokit contributors 126 | 127 | Permission is hereby granted, free of charge, to any person obtaining a copy 128 | of this software and associated documentation files (the "Software"), to deal 129 | in the Software without restriction, including without limitation the rights 130 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 131 | copies of the Software, and to permit persons to whom the Software is 132 | furnished to do so, subject to the following conditions: 133 | 134 | The above copyright notice and this permission notice shall be included in 135 | all copies or substantial portions of the Software. 136 | 137 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 138 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 139 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 140 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 141 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 142 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 143 | THE SOFTWARE. 144 | 145 | 146 | @octokit/endpoint 147 | MIT 148 | The MIT License 149 | 150 | Copyright (c) 2018 Octokit contributors 151 | 152 | Permission is hereby granted, free of charge, to any person obtaining a copy 153 | of this software and associated documentation files (the "Software"), to deal 154 | in the Software without restriction, including without limitation the rights 155 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 156 | copies of the Software, and to permit persons to whom the Software is 157 | furnished to do so, subject to the following conditions: 158 | 159 | The above copyright notice and this permission notice shall be included in 160 | all copies or substantial portions of the Software. 161 | 162 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 163 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 164 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 165 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 166 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 167 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 168 | THE SOFTWARE. 169 | 170 | 171 | @octokit/graphql 172 | MIT 173 | The MIT License 174 | 175 | Copyright (c) 2018 Octokit contributors 176 | 177 | Permission is hereby granted, free of charge, to any person obtaining a copy 178 | of this software and associated documentation files (the "Software"), to deal 179 | in the Software without restriction, including without limitation the rights 180 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 181 | copies of the Software, and to permit persons to whom the Software is 182 | furnished to do so, subject to the following conditions: 183 | 184 | The above copyright notice and this permission notice shall be included in 185 | all copies or substantial portions of the Software. 186 | 187 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 188 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 189 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 190 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 192 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 193 | THE SOFTWARE. 194 | 195 | 196 | @octokit/plugin-paginate-rest 197 | MIT 198 | MIT License Copyright (c) 2019 Octokit contributors 199 | 200 | 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: 201 | 202 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 203 | 204 | 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. 205 | 206 | 207 | @octokit/plugin-rest-endpoint-methods 208 | MIT 209 | MIT License Copyright (c) 2019 Octokit contributors 210 | 211 | 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: 212 | 213 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 214 | 215 | 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. 216 | 217 | 218 | @octokit/request 219 | MIT 220 | The MIT License 221 | 222 | Copyright (c) 2018 Octokit contributors 223 | 224 | Permission is hereby granted, free of charge, to any person obtaining a copy 225 | of this software and associated documentation files (the "Software"), to deal 226 | in the Software without restriction, including without limitation the rights 227 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 228 | copies of the Software, and to permit persons to whom the Software is 229 | furnished to do so, subject to the following conditions: 230 | 231 | The above copyright notice and this permission notice shall be included in 232 | all copies or substantial portions of the Software. 233 | 234 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 235 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 236 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 237 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 238 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 239 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 240 | THE SOFTWARE. 241 | 242 | 243 | @octokit/request-error 244 | MIT 245 | The MIT License 246 | 247 | Copyright (c) 2019 Octokit contributors 248 | 249 | Permission is hereby granted, free of charge, to any person obtaining a copy 250 | of this software and associated documentation files (the "Software"), to deal 251 | in the Software without restriction, including without limitation the rights 252 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 253 | copies of the Software, and to permit persons to whom the Software is 254 | furnished to do so, subject to the following conditions: 255 | 256 | The above copyright notice and this permission notice shall be included in 257 | all copies or substantial portions of the Software. 258 | 259 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 260 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 261 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 262 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 263 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 264 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 265 | THE SOFTWARE. 266 | 267 | 268 | before-after-hook 269 | Apache-2.0 270 | Apache License 271 | Version 2.0, January 2004 272 | http://www.apache.org/licenses/ 273 | 274 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 275 | 276 | 1. Definitions. 277 | 278 | "License" shall mean the terms and conditions for use, reproduction, 279 | and distribution as defined by Sections 1 through 9 of this document. 280 | 281 | "Licensor" shall mean the copyright owner or entity authorized by 282 | the copyright owner that is granting the License. 283 | 284 | "Legal Entity" shall mean the union of the acting entity and all 285 | other entities that control, are controlled by, or are under common 286 | control with that entity. For the purposes of this definition, 287 | "control" means (i) the power, direct or indirect, to cause the 288 | direction or management of such entity, whether by contract or 289 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 290 | outstanding shares, or (iii) beneficial ownership of such entity. 291 | 292 | "You" (or "Your") shall mean an individual or Legal Entity 293 | exercising permissions granted by this License. 294 | 295 | "Source" form shall mean the preferred form for making modifications, 296 | including but not limited to software source code, documentation 297 | source, and configuration files. 298 | 299 | "Object" form shall mean any form resulting from mechanical 300 | transformation or translation of a Source form, including but 301 | not limited to compiled object code, generated documentation, 302 | and conversions to other media types. 303 | 304 | "Work" shall mean the work of authorship, whether in Source or 305 | Object form, made available under the License, as indicated by a 306 | copyright notice that is included in or attached to the work 307 | (an example is provided in the Appendix below). 308 | 309 | "Derivative Works" shall mean any work, whether in Source or Object 310 | form, that is based on (or derived from) the Work and for which the 311 | editorial revisions, annotations, elaborations, or other modifications 312 | represent, as a whole, an original work of authorship. For the purposes 313 | of this License, Derivative Works shall not include works that remain 314 | separable from, or merely link (or bind by name) to the interfaces of, 315 | the Work and Derivative Works thereof. 316 | 317 | "Contribution" shall mean any work of authorship, including 318 | the original version of the Work and any modifications or additions 319 | to that Work or Derivative Works thereof, that is intentionally 320 | submitted to Licensor for inclusion in the Work by the copyright owner 321 | or by an individual or Legal Entity authorized to submit on behalf of 322 | the copyright owner. For the purposes of this definition, "submitted" 323 | means any form of electronic, verbal, or written communication sent 324 | to the Licensor or its representatives, including but not limited to 325 | communication on electronic mailing lists, source code control systems, 326 | and issue tracking systems that are managed by, or on behalf of, the 327 | Licensor for the purpose of discussing and improving the Work, but 328 | excluding communication that is conspicuously marked or otherwise 329 | designated in writing by the copyright owner as "Not a Contribution." 330 | 331 | "Contributor" shall mean Licensor and any individual or Legal Entity 332 | on behalf of whom a Contribution has been received by Licensor and 333 | subsequently incorporated within the Work. 334 | 335 | 2. Grant of Copyright License. Subject to the terms and conditions of 336 | this License, each Contributor hereby grants to You a perpetual, 337 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 338 | copyright license to reproduce, prepare Derivative Works of, 339 | publicly display, publicly perform, sublicense, and distribute the 340 | Work and such Derivative Works in Source or Object form. 341 | 342 | 3. Grant of Patent License. Subject to the terms and conditions of 343 | this License, each Contributor hereby grants to You a perpetual, 344 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 345 | (except as stated in this section) patent license to make, have made, 346 | use, offer to sell, sell, import, and otherwise transfer the Work, 347 | where such license applies only to those patent claims licensable 348 | by such Contributor that are necessarily infringed by their 349 | Contribution(s) alone or by combination of their Contribution(s) 350 | with the Work to which such Contribution(s) was submitted. If You 351 | institute patent litigation against any entity (including a 352 | cross-claim or counterclaim in a lawsuit) alleging that the Work 353 | or a Contribution incorporated within the Work constitutes direct 354 | or contributory patent infringement, then any patent licenses 355 | granted to You under this License for that Work shall terminate 356 | as of the date such litigation is filed. 357 | 358 | 4. Redistribution. You may reproduce and distribute copies of the 359 | Work or Derivative Works thereof in any medium, with or without 360 | modifications, and in Source or Object form, provided that You 361 | meet the following conditions: 362 | 363 | (a) You must give any other recipients of the Work or 364 | Derivative Works a copy of this License; and 365 | 366 | (b) You must cause any modified files to carry prominent notices 367 | stating that You changed the files; and 368 | 369 | (c) You must retain, in the Source form of any Derivative Works 370 | that You distribute, all copyright, patent, trademark, and 371 | attribution notices from the Source form of the Work, 372 | excluding those notices that do not pertain to any part of 373 | the Derivative Works; and 374 | 375 | (d) If the Work includes a "NOTICE" text file as part of its 376 | distribution, then any Derivative Works that You distribute must 377 | include a readable copy of the attribution notices contained 378 | within such NOTICE file, excluding those notices that do not 379 | pertain to any part of the Derivative Works, in at least one 380 | of the following places: within a NOTICE text file distributed 381 | as part of the Derivative Works; within the Source form or 382 | documentation, if provided along with the Derivative Works; or, 383 | within a display generated by the Derivative Works, if and 384 | wherever such third-party notices normally appear. The contents 385 | of the NOTICE file are for informational purposes only and 386 | do not modify the License. You may add Your own attribution 387 | notices within Derivative Works that You distribute, alongside 388 | or as an addendum to the NOTICE text from the Work, provided 389 | that such additional attribution notices cannot be construed 390 | as modifying the License. 391 | 392 | You may add Your own copyright statement to Your modifications and 393 | may provide additional or different license terms and conditions 394 | for use, reproduction, or distribution of Your modifications, or 395 | for any such Derivative Works as a whole, provided Your use, 396 | reproduction, and distribution of the Work otherwise complies with 397 | the conditions stated in this License. 398 | 399 | 5. Submission of Contributions. Unless You explicitly state otherwise, 400 | any Contribution intentionally submitted for inclusion in the Work 401 | by You to the Licensor shall be under the terms and conditions of 402 | this License, without any additional terms or conditions. 403 | Notwithstanding the above, nothing herein shall supersede or modify 404 | the terms of any separate license agreement you may have executed 405 | with Licensor regarding such Contributions. 406 | 407 | 6. Trademarks. This License does not grant permission to use the trade 408 | names, trademarks, service marks, or product names of the Licensor, 409 | except as required for reasonable and customary use in describing the 410 | origin of the Work and reproducing the content of the NOTICE file. 411 | 412 | 7. Disclaimer of Warranty. Unless required by applicable law or 413 | agreed to in writing, Licensor provides the Work (and each 414 | Contributor provides its Contributions) on an "AS IS" BASIS, 415 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 416 | implied, including, without limitation, any warranties or conditions 417 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 418 | PARTICULAR PURPOSE. You are solely responsible for determining the 419 | appropriateness of using or redistributing the Work and assume any 420 | risks associated with Your exercise of permissions under this License. 421 | 422 | 8. Limitation of Liability. In no event and under no legal theory, 423 | whether in tort (including negligence), contract, or otherwise, 424 | unless required by applicable law (such as deliberate and grossly 425 | negligent acts) or agreed to in writing, shall any Contributor be 426 | liable to You for damages, including any direct, indirect, special, 427 | incidental, or consequential damages of any character arising as a 428 | result of this License or out of the use or inability to use the 429 | Work (including but not limited to damages for loss of goodwill, 430 | work stoppage, computer failure or malfunction, or any and all 431 | other commercial damages or losses), even if such Contributor 432 | has been advised of the possibility of such damages. 433 | 434 | 9. Accepting Warranty or Additional Liability. While redistributing 435 | the Work or Derivative Works thereof, You may choose to offer, 436 | and charge a fee for, acceptance of support, warranty, indemnity, 437 | or other liability obligations and/or rights consistent with this 438 | License. However, in accepting such obligations, You may act only 439 | on Your own behalf and on Your sole responsibility, not on behalf 440 | of any other Contributor, and only if You agree to indemnify, 441 | defend, and hold each Contributor harmless for any liability 442 | incurred by, or claims asserted against, such Contributor by reason 443 | of your accepting any such warranty or additional liability. 444 | 445 | END OF TERMS AND CONDITIONS 446 | 447 | APPENDIX: How to apply the Apache License to your work. 448 | 449 | To apply the Apache License to your work, attach the following 450 | boilerplate notice, with the fields enclosed by brackets "{}" 451 | replaced with your own identifying information. (Don't include 452 | the brackets!) The text should be enclosed in the appropriate 453 | comment syntax for the file format. We also recommend that a 454 | file or class name and description of purpose be included on the 455 | same "printed page" as the copyright notice for easier 456 | identification within third-party archives. 457 | 458 | Copyright 2018 Gregor Martynus and other contributors. 459 | 460 | Licensed under the Apache License, Version 2.0 (the "License"); 461 | you may not use this file except in compliance with the License. 462 | You may obtain a copy of the License at 463 | 464 | http://www.apache.org/licenses/LICENSE-2.0 465 | 466 | Unless required by applicable law or agreed to in writing, software 467 | distributed under the License is distributed on an "AS IS" BASIS, 468 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 469 | See the License for the specific language governing permissions and 470 | limitations under the License. 471 | 472 | 473 | deprecation 474 | ISC 475 | The ISC License 476 | 477 | Copyright (c) Gregor Martynus and contributors 478 | 479 | Permission to use, copy, modify, and/or distribute this software for any 480 | purpose with or without fee is hereby granted, provided that the above 481 | copyright notice and this permission notice appear in all copies. 482 | 483 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 484 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 485 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 486 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 487 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 488 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 489 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 490 | 491 | 492 | once 493 | ISC 494 | The ISC License 495 | 496 | Copyright (c) Isaac Z. Schlueter and Contributors 497 | 498 | Permission to use, copy, modify, and/or distribute this software for any 499 | purpose with or without fee is hereby granted, provided that the above 500 | copyright notice and this permission notice appear in all copies. 501 | 502 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 503 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 504 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 505 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 506 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 507 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 508 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 509 | 510 | 511 | tunnel 512 | MIT 513 | The MIT License (MIT) 514 | 515 | Copyright (c) 2012 Koichi Kobayashi 516 | 517 | Permission is hereby granted, free of charge, to any person obtaining a copy 518 | of this software and associated documentation files (the "Software"), to deal 519 | in the Software without restriction, including without limitation the rights 520 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 521 | copies of the Software, and to permit persons to whom the Software is 522 | furnished to do so, subject to the following conditions: 523 | 524 | The above copyright notice and this permission notice shall be included in 525 | all copies or substantial portions of the Software. 526 | 527 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 528 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 529 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 530 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 531 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 532 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 533 | THE SOFTWARE. 534 | 535 | 536 | undici 537 | MIT 538 | MIT License 539 | 540 | Copyright (c) Matteo Collina and Undici contributors 541 | 542 | Permission is hereby granted, free of charge, to any person obtaining a copy 543 | of this software and associated documentation files (the "Software"), to deal 544 | in the Software without restriction, including without limitation the rights 545 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 546 | copies of the Software, and to permit persons to whom the Software is 547 | furnished to do so, subject to the following conditions: 548 | 549 | The above copyright notice and this permission notice shall be included in all 550 | copies or substantial portions of the Software. 551 | 552 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 553 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 554 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 555 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 556 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 557 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 558 | SOFTWARE. 559 | 560 | 561 | universal-user-agent 562 | ISC 563 | # [ISC License](https://spdx.org/licenses/ISC) 564 | 565 | Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m) 566 | 567 | 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. 568 | 569 | 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. 570 | 571 | 572 | wrappy 573 | ISC 574 | The ISC License 575 | 576 | Copyright (c) Isaac Z. Schlueter and Contributors 577 | 578 | Permission to use, copy, modify, and/or distribute this software for any 579 | purpose with or without fee is hereby granted, provided that the above 580 | copyright notice and this permission notice appear in all copies. 581 | 582 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 583 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 584 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 585 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 586 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 587 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 588 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 589 | -------------------------------------------------------------------------------- /dist/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={296:e=>{var r=Object.prototype.toString;var n=typeof Buffer!=="undefined"&&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},599:(e,r,n)=>{e=n.nmd(e);var t=n(927).SourceMapConsumer;var o=n(928);var i;try{i=n(896);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(296);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var d=[];var h=[];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 globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}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 a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){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(u){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;a=false}if(a){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,r){if(r===undefined){r={nextPosition:null,curPosition:null}}if(e.isNative()){r.curPosition=null;return e}var n=e.getFileName()||e.getScriptNameOrSourceURL();if(n){var t=e.getLineNumber();var o=e.getColumnNumber()-1;var i=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;var a=i.test(globalProcessVersion())?0:62;if(t===1&&o>a&&!isInBrowser()&&!e.isEval()){o-=a}var u=mapSourcePosition({source:n,line:t,column:o});r.curPosition=u;e=cloneCallSite(e);var s=e.getFunctionName;e.getFunctionName=function(){if(r.nextPosition==null){return s()}return r.nextPosition.name||s()};e.getFileName=function(){return u.source};e.getLineNumber=function(){return u.line};e.getColumnNumber=function(){return u.column+1};e.getScriptNameOrSourceURL=function(){return u.source};return e}var l=e.isEval()&&e.getEvalOrigin();if(l){l=mapEvalOrigin(l);e=cloneCallSite(e);e.getEvalOrigin=function(){return l};return e}return e}function prepareStackTrace(e,r){if(l){p={};f={}}var n=e.name||"Error";var t=e.message||"";var o=n+": "+t;var i={nextPosition:null,curPosition:null};var a=[];for(var u=r.length-1;u>=0;u--){a.push("\n at "+wrapCallSite(r[u],i));i.nextPosition=i.curPosition}i.curPosition=i.nextPosition=null;return o+a.reverse().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 a=p[n];if(!a&&i&&i.existsSync(n)){try{a=i.readFileSync(n,"utf8")}catch(e){a=""}}if(a){var u=a.split(/(?:\r\n|\r|\n)/)[t-1];if(u){return n+":"+t+"\n"+u+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);var n=globalProcessStderr();if(n&&n._handle&&n._handle.setBlocking){n._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);globalProcessExit(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=d.slice(0);var _=h.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=v;r.install=function(r){r=r||{};if(r.environment){c=r.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(r.retrieveFile){if(r.overrideRetrieveFile){d.length=0}d.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){h.length=0}h.unshift(r.retrieveSourceMap)}if(r.hookRequire&&!isInBrowser()){var n=dynamicRequire(e,"module");var t=n.prototype._compile;if(!t.__sourceMapSupport){n.prototype._compile=function(e,r){p[r]=e;f[r]=undefined;return t.call(this,e,r)};n.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in r?r.emptyCacheBetweenOperations:false}if(!u){u=true;Error.prepareStackTrace=prepareStackTrace}if(!s){var o="handleUncaughtExceptions"in r?r.handleUncaughtExceptions:true;try{var i=dynamicRequire(e,"worker_threads");if(i.isMainThread===false){o=false}}catch(e){}if(o&&hasGlobalProcessEventEmitter()){s=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){d.length=0;h.length=0;d=S.slice(0);h=_.slice(0);v=handlerExec(h);m=handlerExec(d)}},517:(e,r,n)=>{var t=n(297);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(158);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&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{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,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}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}},24:(e,r,n)=>{var t=n(297);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=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.P=MappingList},299:(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(297);var i=n(197);var a=n(517).C;var u=n(818);var s=n(299).g;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 a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,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 a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}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 u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}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){v.source=l+_[1];l+=_[1];v.originalLine=i+_[2];i=v.originalLine;v.originalLine+=1;v.originalColumn=a+_[3];a=v.originalColumn;if(_.length>4){v.name=c+_[4];c+=_[4]}}m.push(v);if(typeof v.originalLine==="number"){h.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(h,o.compareByOriginalPositions);this.__originalMappings=h};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){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,a)};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 a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}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 a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}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 a;this._names=new a;var u={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(818);var o=n(297);var i=n(517).C;var a=n(24).P;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 a;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 a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));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 a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=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(a!=null){r.source=o.relative(a,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&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,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 a=0;var u=0;var s="";var l;var c;var p;var f;var g=this._mappings.toArray();for(var d=0,h=g.length;d0){if(!o.compareByGeneratedPositionsInflated(c,g[d-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);l+=t.encode(f-u);u=f;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};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.x=SourceMapGenerator},565:(e,r,n)=>{var t;var o=n(163).x;var i=n(297);var a=/(\r?\n)/;var u=10;var s="$$$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[s]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(a);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[s]||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 a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}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},927:(e,r,n)=>{n(163).x;r.SourceMapConsumer=n(684).SourceMapConsumer;n(565)},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={id:n,loaded:false,exports:{}};var i=true;try{e[n](o,o.exports,__webpack_require__);i=false}finally{if(i)delete r[n]}o.loaded=true;return o.exports}(()=>{__webpack_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __webpack_require__!=="undefined")__webpack_require__.ab=__dirname+"/";var n={};__webpack_require__(599).install();module.exports=n})(); -------------------------------------------------------------------------------- /__tests__/main.test.js: -------------------------------------------------------------------------------- 1 | import {run} from '../src/main' 2 | import * as github from '@actions/github' 3 | import * as core from '@actions/core' 4 | 5 | class BigBadError extends Error { 6 | constructor(message) { 7 | super(message) 8 | this.status = 500 9 | } 10 | } 11 | 12 | class AlreadyExistsError extends Error { 13 | constructor(message) { 14 | super(message) 15 | this.status = 422 16 | } 17 | } 18 | 19 | function randomSha1() { 20 | return Array.from({length: 40}, () => 21 | Math.floor(Math.random() * 16).toString(16) 22 | ).join('') 23 | } 24 | 25 | const setOutputMock = jest.spyOn(core, 'setOutput') 26 | const infoMock = jest.spyOn(core, 'info') 27 | const warningMock = jest.spyOn(core, 'warning') 28 | const setFailedMock = jest.spyOn(core, 'setFailed') 29 | const debugMock = jest.spyOn(core, 'debug') 30 | 31 | beforeEach(() => { 32 | jest.clearAllMocks() 33 | jest.spyOn(core, 'setOutput').mockImplementation(() => {}) 34 | jest.spyOn(core, 'setFailed').mockImplementation(() => {}) 35 | jest.spyOn(core, 'saveState').mockImplementation(() => {}) 36 | jest.spyOn(core, 'info').mockImplementation(() => {}) 37 | jest.spyOn(core, 'debug').mockImplementation(() => {}) 38 | jest.spyOn(core, 'warning').mockImplementation(() => {}) 39 | jest.spyOn(core, 'error').mockImplementation(() => {}) 40 | process.env.INPUT_GITHUB_TOKEN = 'faketoken' 41 | process.env.INPUT_CI_REQUIRED = 'true' 42 | process.env.INPUT_PR_TITLE = 'Combined PRs' 43 | process.env.INPUT_PR_BODY_HEADER = '# Combined PRs ➡️📦⬅️' 44 | process.env.INPUT_REVIEW_REQUIRED = 'false' 45 | process.env.INPUT_COMBINE_BRANCH_NAME = 'combined-prs-branch' 46 | process.env.INPUT_BRANCH_PREFIX = 'dependabot' 47 | process.env.INPUT_IGNORE_LABEL = 'nocombine' 48 | process.env.INPUT_SELECT_LABEL = '' 49 | process.env.GITHUB_REPOSITORY = 'test-owner/test-repo' 50 | process.env.INPUT_MIN_COMBINE_NUMBER = '2' 51 | process.env.INPUT_LABELS = '' 52 | process.env.INPUT_ASSIGNEES = '' 53 | process.env.INPUT_AUTOCLOSE = 'true' 54 | process.env.INPUT_UPDATE_BRANCH = 'true' 55 | process.env.INPUT_CREATE_FROM_SCRATCH = 'false' 56 | 57 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 58 | return { 59 | paginate: jest.fn().mockImplementation(() => { 60 | return [ 61 | buildPR(1, 'dependabot-1', ['question']), 62 | buildPR(2, 'dependabot-2'), 63 | buildPR(3, 'dependabot-3', ['nocombine']), 64 | buildPR(4, 'dependabot-4'), 65 | buildPR(5, 'dependabot-5'), 66 | buildPR(6, 'dependabot-6'), 67 | buildPR(7, 'dependabot-7'), 68 | buildPR(8, 'fix-package') 69 | ] 70 | }), 71 | graphql: jest.fn().mockImplementation((_query, params) => { 72 | switch (params.pull_number) { 73 | case 1: 74 | case 2: 75 | case 3: 76 | return buildStatusResponse('APPROVED', 'SUCCESS') 77 | case 4: 78 | return buildStatusResponse('APPROVED', 'FAILURE') 79 | case 5: 80 | return buildStatusResponse(null, 'SUCCESS') 81 | case 6: 82 | return buildStatusResponse('REVIEW_REQUIRED', 'SUCCESS') 83 | case 7: 84 | return buildStatusResponse(null, null) 85 | default: 86 | throw new Error( 87 | `params.pull_number of ${params.pull_number} is not configured.` 88 | ) 89 | } 90 | }), 91 | rest: { 92 | git: { 93 | createRef: jest.fn().mockReturnValueOnce({ 94 | data: {} 95 | }), 96 | updateRef: jest.fn().mockReturnValueOnce({ 97 | data: {} 98 | }), 99 | getRef: jest.fn().mockReturnValueOnce({ 100 | data: { 101 | object: { 102 | sha: randomSha1() 103 | } 104 | } 105 | }) 106 | }, 107 | repos: { 108 | // mock the first value of merge to be a success and the second to be an exception 109 | merge: jest 110 | .fn() 111 | .mockReturnValueOnce({ 112 | data: { 113 | merged: true 114 | } 115 | }) 116 | .mockImplementationOnce(() => { 117 | throw new Error('merge error') 118 | }) 119 | }, 120 | pulls: { 121 | create: jest.fn().mockReturnValueOnce({ 122 | data: { 123 | number: 100, 124 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 125 | } 126 | }) 127 | } 128 | } 129 | } 130 | }) 131 | }) 132 | 133 | test('successfully runs the action', async () => { 134 | process.env.INPUT_REVIEW_REQUIRED = 'true' 135 | expect(await run()).toBe('success') 136 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-1') 137 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-1') 138 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-1') 139 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 140 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 141 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-1 is approved') 142 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-2') 143 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-2') 144 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-2') 145 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 146 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 147 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-2 is approved') 148 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-3') 149 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-3') 150 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-4') 151 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-4') 152 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-4') 153 | expect(infoMock).toHaveBeenCalledWith('Validating status: FAILURE') 154 | expect(infoMock).toHaveBeenCalledWith( 155 | 'Discarding dependabot-4 with status FAILURE' 156 | ) 157 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-5') 158 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-5') 159 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 160 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: null') 161 | expect(infoMock).toHaveBeenCalledWith( 162 | 'Branch dependabot-5 has no required reviewers - OK' 163 | ) 164 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-1') 165 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: question') 166 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-1') 167 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-2') 168 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-2') 169 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-3') 170 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: nocombine') 171 | expect(infoMock).toHaveBeenCalledWith( 172 | 'Discarding dependabot-3 with label nocombine because it matches ignore_label' 173 | ) 174 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-4') 175 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-5') 176 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-6') 177 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 178 | expect(warningMock).toHaveBeenCalledWith( 179 | 'Failed to merge branch dependabot-2' 180 | ) 181 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-5') 182 | expect(infoMock).toHaveBeenCalledWith('Creating combined PR') 183 | expect(debugMock).toHaveBeenCalledWith( 184 | 'PR body: # Combined PRs ➡️📦⬅️\n\n✅ The following pull requests have been successfully combined on this PR:\n- Closes #1 Update dependency 1\n- Closes #5 Update dependency 5\n\n⚠️ The following PRs were left out due to merge conflicts:\n- #2 Update dependency 2\n\n> This PR was created by the [`github/combine-prs`](https://github.com/github/combine-prs) action' 185 | ) 186 | expect(infoMock).toHaveBeenCalledWith( 187 | 'Combined PR url: https://github.com/test-owner/test-repo/pull/100' 188 | ) 189 | expect(infoMock).toHaveBeenCalledWith('Combined PR number: 100') 190 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 191 | expect(setOutputMock).toHaveBeenCalledWith( 192 | 'pr_url', 193 | 'https://github.com/test-owner/test-repo/pull/100' 194 | ) 195 | }) 196 | 197 | test('successfully runs the action when autoclose is disabled', async () => { 198 | process.env.INPUT_REVIEW_REQUIRED = 'true' 199 | process.env.INPUT_AUTOCLOSE = 'false' 200 | expect(await run()).toBe('success') 201 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-1') 202 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-1') 203 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-1') 204 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 205 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 206 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-1 is approved') 207 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-2') 208 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-2') 209 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-2') 210 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 211 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 212 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-2 is approved') 213 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-3') 214 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-3') 215 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-4') 216 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-4') 217 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-4') 218 | expect(infoMock).toHaveBeenCalledWith('Validating status: FAILURE') 219 | expect(infoMock).toHaveBeenCalledWith( 220 | 'Discarding dependabot-4 with status FAILURE' 221 | ) 222 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-5') 223 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-5') 224 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 225 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: null') 226 | expect(infoMock).toHaveBeenCalledWith( 227 | 'Branch dependabot-5 has no required reviewers - OK' 228 | ) 229 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-1') 230 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: question') 231 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-1') 232 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-2') 233 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-2') 234 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-3') 235 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: nocombine') 236 | expect(infoMock).toHaveBeenCalledWith( 237 | 'Discarding dependabot-3 with label nocombine because it matches ignore_label' 238 | ) 239 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-4') 240 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-5') 241 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-6') 242 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 243 | expect(warningMock).toHaveBeenCalledWith( 244 | 'Failed to merge branch dependabot-2' 245 | ) 246 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-5') 247 | expect(infoMock).toHaveBeenCalledWith('Creating combined PR') 248 | expect(debugMock).toHaveBeenCalledWith( 249 | 'PR body: # Combined PRs ➡️📦⬅️\n\n✅ The following pull requests have been successfully combined on this PR:\n- #1 Update dependency 1\n- #5 Update dependency 5\n\n⚠️ The following PRs were left out due to merge conflicts:\n- #2 Update dependency 2\n\n> This PR was created by the [`github/combine-prs`](https://github.com/github/combine-prs) action' 250 | ) 251 | expect(infoMock).toHaveBeenCalledWith( 252 | 'Combined PR url: https://github.com/test-owner/test-repo/pull/100' 253 | ) 254 | expect(infoMock).toHaveBeenCalledWith('Combined PR number: 100') 255 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 256 | expect(setOutputMock).toHaveBeenCalledWith( 257 | 'pr_url', 258 | 'https://github.com/test-owner/test-repo/pull/100' 259 | ) 260 | }) 261 | 262 | test('successfully runs the action with the branch_regex option', async () => { 263 | process.env.INPUT_REVIEW_REQUIRED = 'true' 264 | process.env.INPUT_BRANCH_REGEX = '.*penda.*' // match dependabot branches 265 | expect(await run()).toBe('success') 266 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-1') 267 | expect(infoMock).toHaveBeenCalledWith('Branch matched regex: dependabot-1') 268 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-1') 269 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 270 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 271 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-1 is approved') 272 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-2') 273 | expect(infoMock).toHaveBeenCalledWith('Branch matched regex: dependabot-2') 274 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-2') 275 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 276 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 277 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-2 is approved') 278 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-3') 279 | expect(infoMock).toHaveBeenCalledWith('Branch matched regex: dependabot-3') 280 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 281 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 282 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-4') 283 | expect(infoMock).toHaveBeenCalledWith('Branch matched regex: dependabot-4') 284 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-4') 285 | expect(infoMock).toHaveBeenCalledWith('Validating status: FAILURE') 286 | expect(infoMock).toHaveBeenCalledWith( 287 | 'Discarding dependabot-4 with status FAILURE' 288 | ) 289 | expect(infoMock).toHaveBeenCalledWith('Branch matched regex: dependabot-5') 290 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-5') 291 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 292 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: null') 293 | expect(infoMock).toHaveBeenCalledWith( 294 | 'Branch dependabot-5 has no required reviewers - OK' 295 | ) 296 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-1') 297 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: question') 298 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-1') 299 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-2') 300 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-2') 301 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-3') 302 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: nocombine') 303 | expect(infoMock).toHaveBeenCalledWith( 304 | 'Discarding dependabot-3 with label nocombine because it matches ignore_label' 305 | ) 306 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-4') 307 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-5') 308 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-6') 309 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 310 | expect(warningMock).toHaveBeenCalledWith( 311 | 'Failed to merge branch dependabot-2' 312 | ) 313 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-5') 314 | expect(infoMock).toHaveBeenCalledWith('Creating combined PR') 315 | expect(debugMock).toHaveBeenCalledWith( 316 | 'PR body: # Combined PRs ➡️📦⬅️\n\n✅ The following pull requests have been successfully combined on this PR:\n- Closes #1 Update dependency 1\n- Closes #5 Update dependency 5\n\n⚠️ The following PRs were left out due to merge conflicts:\n- #2 Update dependency 2\n\n> This PR was created by the [`github/combine-prs`](https://github.com/github/combine-prs) action' 317 | ) 318 | expect(infoMock).toHaveBeenCalledWith( 319 | 'Combined PR url: https://github.com/test-owner/test-repo/pull/100' 320 | ) 321 | expect(infoMock).toHaveBeenCalledWith('Combined PR number: 100') 322 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 323 | expect(setOutputMock).toHaveBeenCalledWith( 324 | 'pr_url', 325 | 'https://github.com/test-owner/test-repo/pull/100' 326 | ) 327 | }) 328 | 329 | test('label check does not override CI or review status', async () => { 330 | process.env.INPUT_SELECT_LABEL = 'please-combine' 331 | process.env.INPUT_CI_REQUIRED = 'true' 332 | process.env.INPUT_REVIEW_REQUIRED = 'true' 333 | 334 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 335 | return { 336 | paginate: jest.fn().mockImplementation(() => { 337 | return [ 338 | buildPR(1, 'dependabot-failed-ci', ['please-combine']), 339 | buildPR(2, 'dependabot-awaiting-review', ['please-combine']) 340 | ] 341 | }), 342 | graphql: jest.fn().mockImplementation((_query, params) => { 343 | switch (params.pull_number) { 344 | case 1: 345 | return buildStatusResponse('APPROVED', 'FAILURE') 346 | case 2: 347 | return buildStatusResponse('REVIEW_REQUIRED', 'SUCCESS') 348 | default: 349 | throw new Error( 350 | `params.pull_number of ${params.pull_number} is not configured.` 351 | ) 352 | } 353 | }), 354 | rest: { 355 | git: { 356 | createRef: jest.fn().mockReturnValueOnce({ 357 | data: {} 358 | }), 359 | updateRef: jest.fn().mockReturnValueOnce({ 360 | data: {} 361 | }), 362 | getRef: jest.fn().mockReturnValueOnce({ 363 | data: { 364 | object: { 365 | sha: randomSha1() 366 | } 367 | } 368 | }) 369 | }, 370 | repos: { 371 | merge: jest.fn().mockReturnValueOnce({ 372 | data: {} 373 | }) 374 | }, 375 | pulls: { 376 | create: jest.fn().mockReturnValueOnce({ 377 | data: {} 378 | }) 379 | } 380 | } 381 | } 382 | }) 383 | 384 | expect(await run()).toBe('No PRs/branches matched criteria') 385 | }) 386 | 387 | test('successfully runs the action with the select_label option', async () => { 388 | process.env.INPUT_CI_REQUIRED = false // just to reduce needed mocks 389 | process.env.INPUT_IGNORE_LABEL = 'no-combine' 390 | process.env.INPUT_SELECT_LABEL = 'please-combine' 391 | 392 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 393 | return { 394 | paginate: jest.fn().mockImplementation(() => { 395 | return [ 396 | buildPR(1, 'dependabot-random-label', ['some-random-label']), 397 | buildPR(2, 'dependabot-select-label', [ 398 | 'some-random-label', 399 | 'please-combine', 400 | 'another-label' 401 | ]), 402 | buildPR(3, 'dependabot-no-labels', []), 403 | buildPR(4, 'dependabot-both-ignore-and-select', [ 404 | 'no-combine', 405 | 'please-combine' 406 | ]), 407 | buildPR(5, 'dependabot-only-select', ['please-combine']) 408 | ] 409 | }), 410 | rest: { 411 | git: { 412 | createRef: jest.fn().mockReturnValueOnce({ 413 | data: {} 414 | }), 415 | updateRef: jest.fn().mockReturnValueOnce({ 416 | data: {} 417 | }), 418 | getRef: jest.fn().mockReturnValueOnce({ 419 | data: { 420 | object: { 421 | sha: randomSha1() 422 | } 423 | } 424 | }) 425 | }, 426 | repos: { 427 | merge: jest.fn().mockReturnValueOnce({ 428 | data: {} 429 | }) 430 | }, 431 | pulls: { 432 | create: jest.fn().mockReturnValueOnce({ 433 | data: {} 434 | }) 435 | } 436 | } 437 | } 438 | }) 439 | 440 | expect(await run()).toBe('success') 441 | 442 | expect(infoMock).toHaveBeenCalledWith( 443 | 'Checking labels: dependabot-random-label' 444 | ) 445 | expect(infoMock).toHaveBeenCalledWith( 446 | 'Checking select_label for: some-random-label' 447 | ) 448 | expect(infoMock).toHaveBeenCalledWith( 449 | 'Discarding dependabot-random-label because it does not match select_label' 450 | ) 451 | 452 | expect(infoMock).toHaveBeenCalledWith( 453 | 'Checking labels: dependabot-select-label' 454 | ) 455 | expect(infoMock).toHaveBeenCalledWith( 456 | 'Checking select_label for: some-random-label' 457 | ) 458 | expect(infoMock).toHaveBeenCalledWith( 459 | 'Checking select_label for: please-combine' 460 | ) 461 | expect(infoMock).toHaveBeenCalledWith( 462 | 'Checking ignore_label for: some-random-label' 463 | ) 464 | expect(infoMock).toHaveBeenCalledWith( 465 | 'Checking ignore_label for: please-combine' 466 | ) 467 | expect(infoMock).toHaveBeenCalledWith( 468 | 'Checking ignore_label for: another-label' 469 | ) 470 | expect(infoMock).toHaveBeenCalledWith( 471 | 'Adding branch to array: dependabot-select-label' 472 | ) 473 | 474 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-no-labels') 475 | expect(infoMock).toHaveBeenCalledWith( 476 | 'Discarding dependabot-no-labels because it does not match select_label' 477 | ) 478 | 479 | expect(infoMock).toHaveBeenCalledWith( 480 | 'Checking labels: dependabot-both-ignore-and-select' 481 | ) 482 | expect(infoMock).toHaveBeenCalledWith('Checking select_label for: no-combine') 483 | expect(infoMock).toHaveBeenCalledWith( 484 | 'Checking select_label for: please-combine' 485 | ) 486 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: no-combine') 487 | expect(infoMock).toHaveBeenCalledWith( 488 | 'Discarding dependabot-both-ignore-and-select with label no-combine because it matches ignore_label' 489 | ) 490 | }) 491 | 492 | test('runs the action and fails to create the combine branch', async () => { 493 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 494 | return { 495 | paginate: jest.fn().mockImplementation(() => { 496 | return [buildPR(1, 'dependabot-1'), buildPR(2, 'dependabot-2')] 497 | }), 498 | graphql: jest.fn().mockImplementation(() => { 499 | return buildStatusResponse('APPROVED', 'SUCCESS') 500 | }), 501 | rest: { 502 | issues: { 503 | createComment: jest.fn().mockReturnValueOnce({ 504 | data: {} 505 | }) 506 | }, 507 | git: { 508 | createRef: jest.fn().mockRejectedValueOnce(new BigBadError('Oh no!')) 509 | }, 510 | repos: { 511 | merge: jest.fn().mockReturnValueOnce({ 512 | data: {} 513 | }) 514 | }, 515 | pulls: { 516 | create: jest.fn().mockReturnValueOnce({ 517 | data: {} 518 | }) 519 | } 520 | } 521 | } 522 | }) 523 | 524 | expect(await run()).toBe('Failed to create combined branch') 525 | expect(setFailedMock).toHaveBeenCalledWith('Failed to create combined branch') 526 | }) 527 | 528 | test('runs the action and finds the combine branch already exists and the PR also exists', async () => { 529 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 530 | return { 531 | paginate: jest.fn().mockImplementation(() => { 532 | return [buildPR(1, 'dependabot-1'), buildPR(2, 'dependabot-2')] 533 | }), 534 | graphql: jest.fn().mockImplementation(() => { 535 | return buildStatusResponse('APPROVED', 'SUCCESS') 536 | }), 537 | rest: { 538 | issues: { 539 | createComment: jest.fn().mockReturnValueOnce({ 540 | data: {} 541 | }) 542 | }, 543 | git: { 544 | createRef: jest 545 | .fn() 546 | .mockRejectedValueOnce( 547 | new AlreadyExistsError('Reference already exists') 548 | ), 549 | updateRef: jest.fn().mockReturnValueOnce({ 550 | data: {} 551 | }), 552 | getRef: jest.fn().mockReturnValueOnce({ 553 | data: { 554 | object: { 555 | sha: randomSha1() 556 | } 557 | } 558 | }) 559 | }, 560 | repos: { 561 | merge: jest.fn().mockReturnValueOnce({ 562 | data: {} 563 | }) 564 | }, 565 | pulls: { 566 | create: jest 567 | .fn() 568 | .mockRejectedValueOnce(new AlreadyExistsError('PR already exists')), 569 | list: jest.fn().mockReturnValueOnce({ 570 | data: [ 571 | { 572 | number: 100 573 | } 574 | ] 575 | }), 576 | update: jest.fn().mockReturnValueOnce({ 577 | data: {} 578 | }) 579 | } 580 | } 581 | } 582 | }) 583 | 584 | expect(await run()).toBe('success') 585 | expect(warningMock).toHaveBeenCalledWith( 586 | 'Branch already exists - will try to merge into it' 587 | ) 588 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 589 | }) 590 | 591 | test('runs the action and fails to create a pull request', async () => { 592 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 593 | return { 594 | paginate: jest.fn().mockImplementation(() => { 595 | return [buildPR(1, 'dependabot-1'), buildPR(2, 'dependabot-2')] 596 | }), 597 | graphql: jest.fn().mockImplementation(() => { 598 | return buildStatusResponse('APPROVED', 'SUCCESS') 599 | }), 600 | rest: { 601 | issues: { 602 | createComment: jest.fn().mockReturnValueOnce({ 603 | data: {} 604 | }) 605 | }, 606 | git: { 607 | createRef: jest.fn().mockReturnValueOnce({ 608 | data: {} 609 | }), 610 | updateRef: jest.fn().mockReturnValueOnce({ 611 | data: {} 612 | }), 613 | getRef: jest.fn().mockReturnValueOnce({ 614 | data: { 615 | object: { 616 | sha: randomSha1() 617 | } 618 | } 619 | }) 620 | }, 621 | repos: { 622 | merge: jest.fn().mockReturnValueOnce({ 623 | data: {} 624 | }) 625 | }, 626 | pulls: { 627 | create: jest 628 | .fn() 629 | .mockRejectedValueOnce( 630 | new BigBadError( 631 | 'GitHub Actions is not permitted to create or approve pull requests' 632 | ) 633 | ), 634 | list: jest.fn().mockReturnValueOnce({ 635 | data: [ 636 | { 637 | number: 100 638 | } 639 | ] 640 | }), 641 | update: jest.fn().mockReturnValueOnce({ 642 | data: {} 643 | }) 644 | } 645 | } 646 | } 647 | }) 648 | 649 | expect(await run()).toBe('failure') 650 | 651 | expect(warningMock).toHaveBeenCalledWith( 652 | 'https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/' 653 | ) 654 | 655 | expect(setFailedMock).toHaveBeenCalledWith( 656 | 'Failed to create combined PR - Error: GitHub Actions is not permitted to create or approve pull requests' 657 | ) 658 | }) 659 | 660 | test('runs the action and finds the combine branch already exists and the PR also exists and the PR is in a closed state', async () => { 661 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 662 | return { 663 | paginate: jest.fn().mockImplementation(() => { 664 | return [buildPR(1, 'dependabot-1'), buildPR(2, 'dependabot-2')] 665 | }), 666 | graphql: jest.fn().mockImplementation(() => { 667 | return buildStatusResponse('APPROVED', 'SUCCESS') 668 | }), 669 | rest: { 670 | issues: { 671 | createComment: jest.fn().mockReturnValueOnce({ 672 | data: {} 673 | }) 674 | }, 675 | git: { 676 | createRef: jest 677 | .fn() 678 | .mockRejectedValueOnce( 679 | new AlreadyExistsError('Reference already exists') 680 | ), 681 | updateRef: jest.fn().mockReturnValueOnce({ 682 | data: {} 683 | }), 684 | getRef: jest.fn().mockReturnValueOnce({ 685 | data: { 686 | object: { 687 | sha: randomSha1() 688 | } 689 | } 690 | }) 691 | }, 692 | repos: { 693 | merge: jest.fn().mockReturnValueOnce({ 694 | data: {} 695 | }) 696 | }, 697 | pulls: { 698 | create: jest 699 | .fn() 700 | .mockRejectedValueOnce(new AlreadyExistsError('PR already exists')), 701 | list: jest.fn().mockReturnValueOnce({ 702 | data: [ 703 | { 704 | number: 100, 705 | state: 'closed' 706 | } 707 | ] 708 | }), 709 | update: jest.fn().mockReturnValue({ 710 | data: {} 711 | }) 712 | } 713 | } 714 | } 715 | }) 716 | 717 | expect(await run()).toBe('success') 718 | expect(warningMock).toHaveBeenCalledWith( 719 | 'Branch already exists - will try to merge into it' 720 | ) 721 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 722 | }) 723 | 724 | test('runs the action and only one branch matches criteria', async () => { 725 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 726 | return { 727 | paginate: jest.fn().mockImplementation(() => { 728 | return [buildPR(1, 'dependabot-only-branch')] 729 | }), 730 | graphql: jest.fn().mockImplementation(() => { 731 | return buildStatusResponse('APPROVED', 'SUCCESS') 732 | }) 733 | } 734 | }) 735 | expect(await run()).toBe( 736 | 'not enough PRs/branches matched criteria to create a combined PR' 737 | ) 738 | }) 739 | 740 | test('runs the action and does not find any branches to merge together', async () => { 741 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 742 | return { 743 | paginate: jest.fn().mockImplementation(() => { 744 | return [ 745 | { 746 | number: 1, 747 | head: { 748 | ref: 'test-ref' 749 | } 750 | } 751 | ] 752 | }), 753 | graphql: jest.fn().mockImplementation(() => { 754 | return buildStatusResponse('APPROVED', 'SUCCESS') 755 | }), 756 | rest: { 757 | issues: { 758 | createComment: jest.fn().mockReturnValueOnce({ 759 | data: {} 760 | }) 761 | }, 762 | repos: { 763 | createRef: jest.fn().mockReturnValueOnce({ 764 | data: {} 765 | }), 766 | updateRef: jest.fn().mockReturnValueOnce({ 767 | data: {} 768 | }), 769 | getRef: jest.fn().mockReturnValueOnce({ 770 | data: { 771 | object: { 772 | sha: randomSha1() 773 | } 774 | } 775 | }), 776 | merge: jest.fn().mockReturnValueOnce({ 777 | data: {} 778 | }) 779 | }, 780 | pulls: { 781 | create: jest.fn().mockReturnValueOnce({ 782 | data: {} 783 | }) 784 | } 785 | } 786 | } 787 | }) 788 | 789 | expect(await run()).toBe('No PRs/branches matched criteria') 790 | }) 791 | 792 | test('runs the action with no prefix or regex set', async () => { 793 | process.env.INPUT_BRANCH_PREFIX = '' 794 | process.env.INPUT_BRANCH_REGEX = '' 795 | expect(await run()).toBe('Must specify either branch_prefix or branch_regex') 796 | }) 797 | 798 | test('runs the action when select_label and ignore_label have the same value', async () => { 799 | process.env.INPUT_IGNORE_LABEL = 'some-label' 800 | process.env.INPUT_SELECT_LABEL = 'some-label' 801 | expect(await run()).toBe( 802 | 'ignore_label and select_label cannot have the same value' 803 | ) 804 | }) 805 | 806 | test('ignore_label and select_label can both be empty', async () => { 807 | process.env.INPUT_IGNORE_LABEL = '' 808 | process.env.INPUT_SELECT_LABEL = '' 809 | expect(await run()).toBe('success') 810 | }) 811 | 812 | test('successfully runs the action and sets labels', async () => { 813 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 814 | return { 815 | paginate: jest.fn().mockImplementation(() => { 816 | return [ 817 | buildPR(1, 'dependabot-1', ['question']), 818 | buildPR(2, 'dependabot-2'), 819 | buildPR(3, 'dependabot-3', ['nocombine']), 820 | buildPR(4, 'dependabot-4'), 821 | buildPR(5, 'dependabot-5'), 822 | buildPR(6, 'dependabot-6'), 823 | buildPR(7, 'fix-package') 824 | ] 825 | }), 826 | graphql: jest.fn().mockImplementation((_query, params) => { 827 | switch (params.pull_number) { 828 | case 1: 829 | case 2: 830 | case 3: 831 | return buildStatusResponse('APPROVED', 'SUCCESS') 832 | case 4: 833 | return buildStatusResponse('APPROVED', 'FAILURE') 834 | case 5: 835 | return buildStatusResponse(null, 'SUCCESS') 836 | case 6: 837 | return buildStatusResponse('REVIEW_REQUIRED', 'SUCCESS') 838 | default: 839 | throw new Error( 840 | `params.pull_number of ${params.pull_number} is not configured.` 841 | ) 842 | } 843 | }), 844 | rest: { 845 | issues: { 846 | addLabels: jest.fn().mockReturnValueOnce({ 847 | data: {} 848 | }) 849 | }, 850 | git: { 851 | createRef: jest.fn().mockReturnValueOnce({ 852 | data: {} 853 | }), 854 | updateRef: jest.fn().mockReturnValueOnce({ 855 | data: {} 856 | }), 857 | getRef: jest.fn().mockReturnValueOnce({ 858 | data: { 859 | object: { 860 | sha: randomSha1() 861 | } 862 | } 863 | }) 864 | }, 865 | repos: { 866 | // mock the first value of merge to be a success and the second to be an exception 867 | merge: jest 868 | .fn() 869 | .mockReturnValueOnce({ 870 | data: { 871 | merged: true 872 | } 873 | }) 874 | .mockImplementationOnce(() => { 875 | throw new Error('merge error') 876 | }) 877 | }, 878 | pulls: { 879 | create: jest.fn().mockReturnValueOnce({ 880 | data: { 881 | number: 100, 882 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 883 | } 884 | }) 885 | } 886 | } 887 | } 888 | }) 889 | 890 | process.env.INPUT_REVIEW_REQUIRED = 'true' 891 | process.env.INPUT_LABELS = 'label1,label2, label3' 892 | expect(await run()).toBe('success') 893 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-1') 894 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-1') 895 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-1') 896 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 897 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 898 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-1 is approved') 899 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-2') 900 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-2') 901 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-2') 902 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 903 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 904 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-2 is approved') 905 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-3') 906 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-3') 907 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-4') 908 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-4') 909 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-4') 910 | expect(infoMock).toHaveBeenCalledWith('Validating status: FAILURE') 911 | expect(infoMock).toHaveBeenCalledWith( 912 | 'Discarding dependabot-4 with status FAILURE' 913 | ) 914 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-5') 915 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-5') 916 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 917 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: null') 918 | expect(infoMock).toHaveBeenCalledWith( 919 | 'Branch dependabot-5 has no required reviewers - OK' 920 | ) 921 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-1') 922 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: question') 923 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-1') 924 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-2') 925 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-2') 926 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-3') 927 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: nocombine') 928 | expect(infoMock).toHaveBeenCalledWith( 929 | 'Discarding dependabot-3 with label nocombine because it matches ignore_label' 930 | ) 931 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-4') 932 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-5') 933 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-6') 934 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 935 | expect(warningMock).toHaveBeenCalledWith( 936 | 'Failed to merge branch dependabot-2' 937 | ) 938 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-5') 939 | expect(infoMock).toHaveBeenCalledWith('Creating combined PR') 940 | expect(debugMock).toHaveBeenCalledWith( 941 | 'PR body: # Combined PRs ➡️📦⬅️\n\n✅ The following pull requests have been successfully combined on this PR:\n- Closes #1 Update dependency 1\n- Closes #5 Update dependency 5\n\n⚠️ The following PRs were left out due to merge conflicts:\n- #2 Update dependency 2\n\n> This PR was created by the [`github/combine-prs`](https://github.com/github/combine-prs) action' 942 | ) 943 | 944 | expect(infoMock).toHaveBeenCalledWith( 945 | `Adding labels to combined PR: label1,label2,label3` 946 | ) 947 | 948 | expect(infoMock).toHaveBeenCalledWith( 949 | 'Combined PR url: https://github.com/test-owner/test-repo/pull/100' 950 | ) 951 | expect(infoMock).toHaveBeenCalledWith('Combined PR number: 100') 952 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 953 | expect(setOutputMock).toHaveBeenCalledWith( 954 | 'pr_url', 955 | 'https://github.com/test-owner/test-repo/pull/100' 956 | ) 957 | }) 958 | 959 | test('successfully runs the action and sets labels when one PR has no CI defined', async () => { 960 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 961 | return { 962 | paginate: jest.fn().mockImplementation(() => { 963 | return [ 964 | buildPR(1, 'dependabot-1', ['question']), 965 | buildPR(2, 'dependabot-2'), 966 | buildPR(3, 'dependabot-3', ['nocombine']), 967 | buildPR(4, 'dependabot-4'), 968 | buildPR(5, 'dependabot-5'), 969 | buildPR(6, 'dependabot-6'), 970 | buildPR(7, 'fix-package') 971 | ] 972 | }), 973 | graphql: jest.fn().mockImplementation((_query, params) => { 974 | switch (params.pull_number) { 975 | case 1: 976 | case 2: 977 | case 3: 978 | return buildStatusResponse('APPROVED', 'SUCCESS') 979 | case 4: 980 | return buildStatusResponse('APPROVED', 'FAILURE') 981 | case 5: 982 | return buildStatusResponse(null, 'SUCCESS') 983 | case 6: 984 | return { 985 | repository: { 986 | pullRequest: { 987 | reviewDecision: null, 988 | commits: { 989 | nodes: [ 990 | { 991 | commit: { 992 | statusCheckRollup: null 993 | } 994 | } 995 | ] 996 | } 997 | } 998 | } 999 | } 1000 | default: 1001 | throw new Error( 1002 | `params.pull_number of ${params.pull_number} is not configured.` 1003 | ) 1004 | } 1005 | }), 1006 | rest: { 1007 | issues: { 1008 | addLabels: jest.fn().mockReturnValueOnce({ 1009 | data: {} 1010 | }) 1011 | }, 1012 | git: { 1013 | createRef: jest.fn().mockReturnValueOnce({ 1014 | data: {} 1015 | }), 1016 | updateRef: jest.fn().mockReturnValueOnce({ 1017 | data: {} 1018 | }), 1019 | getRef: jest.fn().mockReturnValueOnce({ 1020 | data: { 1021 | object: { 1022 | sha: randomSha1() 1023 | } 1024 | } 1025 | }) 1026 | }, 1027 | repos: { 1028 | // mock the first value of merge to be a success and the second to be an exception 1029 | merge: jest 1030 | .fn() 1031 | .mockReturnValueOnce({ 1032 | data: { 1033 | merged: true 1034 | } 1035 | }) 1036 | .mockImplementationOnce(() => { 1037 | throw new Error('merge error') 1038 | }) 1039 | }, 1040 | pulls: { 1041 | create: jest.fn().mockReturnValueOnce({ 1042 | data: { 1043 | number: 100, 1044 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1045 | } 1046 | }) 1047 | } 1048 | } 1049 | } 1050 | }) 1051 | 1052 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1053 | process.env.INPUT_LABELS = 'label1,label2, label3' 1054 | expect(await run()).toBe('success') 1055 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-1') 1056 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-1') 1057 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-1') 1058 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 1059 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 1060 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-1 is approved') 1061 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-2') 1062 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-2') 1063 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-2') 1064 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 1065 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: APPROVED') 1066 | expect(infoMock).toHaveBeenCalledWith('Branch dependabot-2 is approved') 1067 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-3') 1068 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-3') 1069 | expect(infoMock).toHaveBeenCalledWith('Pull for branch: dependabot-4') 1070 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-4') 1071 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-4') 1072 | expect(infoMock).toHaveBeenCalledWith('Validating status: FAILURE') 1073 | expect(infoMock).toHaveBeenCalledWith( 1074 | 'Discarding dependabot-4 with status FAILURE' 1075 | ) 1076 | expect(infoMock).toHaveBeenCalledWith('Branch matched prefix: dependabot-5') 1077 | expect(infoMock).toHaveBeenCalledWith('Checking green status: dependabot-5') 1078 | expect(infoMock).toHaveBeenCalledWith('Validating status: SUCCESS') 1079 | expect(infoMock).toHaveBeenCalledWith('Validating review decision: null') 1080 | expect(infoMock).toHaveBeenCalledWith( 1081 | 'Branch dependabot-5 has no required reviewers - OK' 1082 | ) 1083 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-1') 1084 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: question') 1085 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-1') 1086 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-2') 1087 | expect(infoMock).toHaveBeenCalledWith('Adding branch to array: dependabot-2') 1088 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-3') 1089 | expect(infoMock).toHaveBeenCalledWith('Checking ignore_label for: nocombine') 1090 | expect(infoMock).toHaveBeenCalledWith( 1091 | 'Discarding dependabot-3 with label nocombine because it matches ignore_label' 1092 | ) 1093 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-4') 1094 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-5') 1095 | expect(infoMock).toHaveBeenCalledWith('Checking labels: dependabot-6') 1096 | expect(infoMock).toHaveBeenCalledWith( 1097 | 'No status check(s) associated with branch: dependabot-6' 1098 | ) 1099 | 1100 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1101 | expect(warningMock).toHaveBeenCalledWith( 1102 | 'Failed to merge branch dependabot-2' 1103 | ) 1104 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-5') 1105 | expect(infoMock).toHaveBeenCalledWith('Creating combined PR') 1106 | expect(debugMock).toHaveBeenCalledWith( 1107 | 'PR body: # Combined PRs ➡️📦⬅️\n\n✅ The following pull requests have been successfully combined on this PR:\n- Closes #1 Update dependency 1\n- Closes #5 Update dependency 5\n- Closes #6 Update dependency 6\n\n⚠️ The following PRs were left out due to merge conflicts:\n- #2 Update dependency 2\n\n> This PR was created by the [`github/combine-prs`](https://github.com/github/combine-prs) action' 1108 | ) 1109 | 1110 | expect(infoMock).toHaveBeenCalledWith( 1111 | `Adding labels to combined PR: label1,label2,label3` 1112 | ) 1113 | 1114 | expect(infoMock).toHaveBeenCalledWith( 1115 | 'Combined PR url: https://github.com/test-owner/test-repo/pull/100' 1116 | ) 1117 | expect(infoMock).toHaveBeenCalledWith('Combined PR number: 100') 1118 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1119 | expect(setOutputMock).toHaveBeenCalledWith( 1120 | 'pr_url', 1121 | 'https://github.com/test-owner/test-repo/pull/100' 1122 | ) 1123 | }) 1124 | 1125 | test('successfully runs the action and sets labels when one PR has no CI defined and the update_branch logic fails', async () => { 1126 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1127 | return { 1128 | paginate: jest.fn().mockImplementation(() => { 1129 | return [ 1130 | buildPR(1, 'dependabot-1', ['question']), 1131 | buildPR(2, 'dependabot-2'), 1132 | buildPR(3, 'dependabot-3', ['nocombine']), 1133 | buildPR(4, 'dependabot-4'), 1134 | buildPR(5, 'dependabot-5'), 1135 | buildPR(6, 'dependabot-6'), 1136 | buildPR(7, 'fix-package') 1137 | ] 1138 | }), 1139 | graphql: jest.fn().mockImplementation((_query, params) => { 1140 | switch (params.pull_number) { 1141 | case 1: 1142 | case 2: 1143 | case 3: 1144 | return buildStatusResponse('APPROVED', 'SUCCESS') 1145 | case 4: 1146 | return buildStatusResponse('APPROVED', 'FAILURE') 1147 | case 5: 1148 | return buildStatusResponse(null, 'SUCCESS') 1149 | case 6: 1150 | return { 1151 | repository: { 1152 | pullRequest: { 1153 | reviewDecision: null, 1154 | commits: { 1155 | nodes: [ 1156 | { 1157 | commit: { 1158 | statusCheckRollup: null 1159 | } 1160 | } 1161 | ] 1162 | } 1163 | } 1164 | } 1165 | } 1166 | default: 1167 | throw new Error( 1168 | `params.pull_number of ${params.pull_number} is not configured.` 1169 | ) 1170 | } 1171 | }), 1172 | rest: { 1173 | issues: { 1174 | addLabels: jest.fn().mockReturnValueOnce({ 1175 | data: {} 1176 | }) 1177 | }, 1178 | git: { 1179 | createRef: jest.fn().mockReturnValueOnce({ 1180 | data: {} 1181 | }), 1182 | updateRef: jest.fn().mockReturnValueOnce({ 1183 | data: {} 1184 | }), 1185 | getRef: jest.fn().mockReturnValueOnce({ 1186 | data: { 1187 | object: { 1188 | sha: randomSha1() 1189 | } 1190 | } 1191 | }) 1192 | }, 1193 | repos: { 1194 | // mock the first value of merge to be a success and the second to be an exception 1195 | merge: jest 1196 | .fn() 1197 | .mockReturnValueOnce({ 1198 | data: { 1199 | merged: true 1200 | } 1201 | }) 1202 | .mockImplementation(() => { 1203 | throw new Error('merge error') 1204 | }) 1205 | }, 1206 | pulls: { 1207 | create: jest.fn().mockReturnValueOnce({ 1208 | data: { 1209 | number: 100, 1210 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1211 | } 1212 | }), 1213 | updateBranch: jest.fn().mockImplementation(() => { 1214 | throw new Error('updateBranch error') 1215 | }) 1216 | } 1217 | } 1218 | } 1219 | }) 1220 | 1221 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1222 | process.env.INPUT_LABELS = 'label1,label2, label3' 1223 | expect(await run()).toBe('success') 1224 | 1225 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1226 | expect(warningMock).toHaveBeenCalledWith( 1227 | 'Failed to merge branch dependabot-2' 1228 | ) 1229 | expect(warningMock).toHaveBeenCalledWith( 1230 | 'Failed to update combined pr branch with the base branch' 1231 | ) 1232 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1233 | expect(setOutputMock).toHaveBeenCalledWith( 1234 | 'pr_url', 1235 | 'https://github.com/test-owner/test-repo/pull/100' 1236 | ) 1237 | }) 1238 | 1239 | test('successfully runs the action and sets labels when one PR has no CI defined and the update_branch logic fails due to a non 202 status code', async () => { 1240 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1241 | return { 1242 | paginate: jest.fn().mockImplementation(() => { 1243 | return [ 1244 | buildPR(1, 'dependabot-1', ['question']), 1245 | buildPR(2, 'dependabot-2'), 1246 | buildPR(3, 'dependabot-3', ['nocombine']), 1247 | buildPR(4, 'dependabot-4'), 1248 | buildPR(5, 'dependabot-5'), 1249 | buildPR(6, 'dependabot-6'), 1250 | buildPR(7, 'fix-package') 1251 | ] 1252 | }), 1253 | graphql: jest.fn().mockImplementation((_query, params) => { 1254 | switch (params.pull_number) { 1255 | case 1: 1256 | case 2: 1257 | case 3: 1258 | return buildStatusResponse('APPROVED', 'SUCCESS') 1259 | case 4: 1260 | return buildStatusResponse('APPROVED', 'FAILURE') 1261 | case 5: 1262 | return buildStatusResponse(null, 'SUCCESS') 1263 | case 6: 1264 | return { 1265 | repository: { 1266 | pullRequest: { 1267 | reviewDecision: null, 1268 | commits: { 1269 | nodes: [ 1270 | { 1271 | commit: { 1272 | statusCheckRollup: null 1273 | } 1274 | } 1275 | ] 1276 | } 1277 | } 1278 | } 1279 | } 1280 | default: 1281 | throw new Error( 1282 | `params.pull_number of ${params.pull_number} is not configured.` 1283 | ) 1284 | } 1285 | }), 1286 | rest: { 1287 | issues: { 1288 | addLabels: jest.fn().mockReturnValueOnce({ 1289 | data: {} 1290 | }) 1291 | }, 1292 | git: { 1293 | createRef: jest.fn().mockReturnValueOnce({ 1294 | data: {} 1295 | }), 1296 | updateRef: jest.fn().mockReturnValueOnce({ 1297 | data: {} 1298 | }), 1299 | getRef: jest.fn().mockReturnValueOnce({ 1300 | data: { 1301 | object: { 1302 | sha: randomSha1() 1303 | } 1304 | } 1305 | }) 1306 | }, 1307 | repos: { 1308 | // mock the first value of merge to be a success and the second to be an exception 1309 | merge: jest 1310 | .fn() 1311 | .mockReturnValueOnce({ 1312 | data: { 1313 | merged: true 1314 | } 1315 | }) 1316 | .mockImplementation(() => { 1317 | throw new Error('merge error') 1318 | }) 1319 | }, 1320 | pulls: { 1321 | create: jest.fn().mockReturnValueOnce({ 1322 | data: { 1323 | number: 100, 1324 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1325 | } 1326 | }), 1327 | updateBranch: jest.fn().mockReturnValueOnce({ 1328 | status: 500 1329 | }) 1330 | } 1331 | } 1332 | } 1333 | }) 1334 | 1335 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1336 | process.env.INPUT_LABELS = 'label1,label2, label3' 1337 | expect(await run()).toBe('success') 1338 | 1339 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1340 | expect(warningMock).toHaveBeenCalledWith( 1341 | 'Failed to merge branch dependabot-2' 1342 | ) 1343 | expect(warningMock).toHaveBeenCalledWith( 1344 | 'Failed to update combined pr branch with the base branch' 1345 | ) 1346 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1347 | expect(setOutputMock).toHaveBeenCalledWith( 1348 | 'pr_url', 1349 | 'https://github.com/test-owner/test-repo/pull/100' 1350 | ) 1351 | }) 1352 | 1353 | test('successfully runs the action and updates the pull request branch', async () => { 1354 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1355 | return { 1356 | paginate: jest.fn().mockImplementation(() => { 1357 | return [ 1358 | buildPR(1, 'dependabot-1', ['question']), 1359 | buildPR(2, 'dependabot-2'), 1360 | buildPR(3, 'dependabot-3', ['nocombine']), 1361 | buildPR(4, 'dependabot-4'), 1362 | buildPR(5, 'dependabot-5'), 1363 | buildPR(6, 'dependabot-6'), 1364 | buildPR(7, 'fix-package') 1365 | ] 1366 | }), 1367 | graphql: jest.fn().mockImplementation((_query, params) => { 1368 | switch (params.pull_number) { 1369 | case 1: 1370 | case 2: 1371 | case 3: 1372 | return buildStatusResponse('APPROVED', 'SUCCESS') 1373 | case 4: 1374 | return buildStatusResponse('APPROVED', 'FAILURE') 1375 | case 5: 1376 | return buildStatusResponse(null, 'SUCCESS') 1377 | case 6: 1378 | return { 1379 | repository: { 1380 | pullRequest: { 1381 | reviewDecision: null, 1382 | commits: { 1383 | nodes: [ 1384 | { 1385 | commit: { 1386 | statusCheckRollup: null 1387 | } 1388 | } 1389 | ] 1390 | } 1391 | } 1392 | } 1393 | } 1394 | default: 1395 | throw new Error( 1396 | `params.pull_number of ${params.pull_number} is not configured.` 1397 | ) 1398 | } 1399 | }), 1400 | rest: { 1401 | issues: { 1402 | addLabels: jest.fn().mockReturnValueOnce({ 1403 | data: {} 1404 | }) 1405 | }, 1406 | git: { 1407 | createRef: jest.fn().mockReturnValueOnce({ 1408 | data: {} 1409 | }), 1410 | updateRef: jest.fn().mockReturnValueOnce({ 1411 | data: {} 1412 | }), 1413 | getRef: jest.fn().mockReturnValueOnce({ 1414 | data: { 1415 | object: { 1416 | sha: randomSha1() 1417 | } 1418 | } 1419 | }) 1420 | }, 1421 | repos: { 1422 | // mock the first value of merge to be a success and the second to be an exception 1423 | merge: jest 1424 | .fn() 1425 | .mockReturnValueOnce({ 1426 | data: { 1427 | merged: true 1428 | } 1429 | }) 1430 | .mockImplementation(() => { 1431 | throw new Error('merge error') 1432 | }) 1433 | }, 1434 | pulls: { 1435 | create: jest.fn().mockReturnValueOnce({ 1436 | data: { 1437 | number: 100, 1438 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1439 | } 1440 | }), 1441 | updateBranch: jest.fn().mockReturnValueOnce({ 1442 | status: 202 1443 | }) 1444 | } 1445 | } 1446 | } 1447 | }) 1448 | 1449 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1450 | process.env.INPUT_LABELS = 'label1,label2, label3' 1451 | expect(await run()).toBe('success') 1452 | 1453 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1454 | expect(warningMock).toHaveBeenCalledWith( 1455 | 'Failed to merge branch dependabot-2' 1456 | ) 1457 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1458 | expect(setOutputMock).toHaveBeenCalledWith( 1459 | 'pr_url', 1460 | 'https://github.com/test-owner/test-repo/pull/100' 1461 | ) 1462 | }) 1463 | 1464 | test('successfully runs the action and uses a fresh pull request branch', async () => { 1465 | const createRef = jest.fn().mockReturnValueOnce({ 1466 | data: {} 1467 | }) 1468 | const updateRef = jest.fn().mockReturnValueOnce({ 1469 | data: {} 1470 | }) 1471 | const sha = randomSha1() 1472 | const getRef = jest.fn().mockReturnValueOnce({ 1473 | data: { 1474 | object: { 1475 | sha 1476 | } 1477 | } 1478 | }) 1479 | const deleteRef = jest.fn().mockReturnValueOnce({ 1480 | data: {} 1481 | }) 1482 | 1483 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1484 | return { 1485 | paginate: jest.fn().mockImplementation(() => { 1486 | return [ 1487 | buildPR(1, 'dependabot-1', ['question']), 1488 | buildPR(2, 'dependabot-2'), 1489 | buildPR(3, 'dependabot-3', ['nocombine']), 1490 | buildPR(4, 'dependabot-4'), 1491 | buildPR(5, 'dependabot-5'), 1492 | buildPR(6, 'dependabot-6'), 1493 | buildPR(7, 'fix-package') 1494 | ] 1495 | }), 1496 | graphql: jest.fn().mockImplementation((_query, params) => { 1497 | switch (params.pull_number) { 1498 | case 1: 1499 | case 2: 1500 | case 3: 1501 | return buildStatusResponse('APPROVED', 'SUCCESS') 1502 | case 4: 1503 | return buildStatusResponse('APPROVED', 'FAILURE') 1504 | case 5: 1505 | return buildStatusResponse(null, 'SUCCESS') 1506 | case 6: 1507 | return { 1508 | repository: { 1509 | pullRequest: { 1510 | reviewDecision: null, 1511 | commits: { 1512 | nodes: [ 1513 | { 1514 | commit: { 1515 | statusCheckRollup: null 1516 | } 1517 | } 1518 | ] 1519 | } 1520 | } 1521 | } 1522 | } 1523 | default: 1524 | throw new Error( 1525 | `params.pull_number of ${params.pull_number} is not configured.` 1526 | ) 1527 | } 1528 | }), 1529 | rest: { 1530 | issues: { 1531 | addLabels: jest.fn().mockReturnValueOnce({ 1532 | data: {} 1533 | }) 1534 | }, 1535 | git: { 1536 | createRef, 1537 | updateRef, 1538 | getRef, 1539 | deleteRef 1540 | }, 1541 | repos: { 1542 | // mock the first value of merge to be a success and the second to be an exception 1543 | merge: jest 1544 | .fn() 1545 | .mockReturnValueOnce({ 1546 | data: { 1547 | merged: true 1548 | } 1549 | }) 1550 | .mockImplementation(() => { 1551 | throw new Error('merge error') 1552 | }) 1553 | }, 1554 | pulls: { 1555 | create: jest.fn().mockReturnValueOnce({ 1556 | data: { 1557 | number: 100, 1558 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1559 | } 1560 | }), 1561 | updateBranch: jest.fn().mockReturnValueOnce({ 1562 | status: 202 1563 | }) 1564 | } 1565 | } 1566 | } 1567 | }) 1568 | 1569 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1570 | process.env.INPUT_CREATE_FROM_SCRATCH = 'true' 1571 | process.env.INPUT_LABELS = 'label1,label2, label3' 1572 | expect(await run()).toBe('success') 1573 | 1574 | expect(createRef).toHaveBeenCalledWith( 1575 | expect.objectContaining({ 1576 | ref: expect.stringContaining('refs/heads/combined-prs-branch-working') 1577 | }) 1578 | ) 1579 | expect(getRef).toHaveBeenCalledWith( 1580 | expect.objectContaining({ 1581 | ref: expect.stringContaining('heads/combined-prs-branch-working') 1582 | }) 1583 | ) 1584 | expect(updateRef).toHaveBeenCalledWith( 1585 | expect.objectContaining({ 1586 | ref: expect.stringContaining('heads/combined-prs-branch'), 1587 | sha 1588 | }) 1589 | ) 1590 | expect(deleteRef).toHaveBeenCalledWith( 1591 | expect.objectContaining({ 1592 | ref: expect.stringContaining('heads/combined-prs-branch-working') 1593 | }) 1594 | ) 1595 | 1596 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1597 | expect(warningMock).toHaveBeenCalledWith( 1598 | 'Failed to merge branch dependabot-2' 1599 | ) 1600 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1601 | expect(setOutputMock).toHaveBeenCalledWith( 1602 | 'pr_url', 1603 | 'https://github.com/test-owner/test-repo/pull/100' 1604 | ) 1605 | }) 1606 | 1607 | test('successfully runs the action and uses the existing pull request branch', async () => { 1608 | const createRef = jest.fn().mockReturnValueOnce({ 1609 | data: {} 1610 | }) 1611 | const updateRef = jest.fn().mockReturnValueOnce({ 1612 | data: {} 1613 | }) 1614 | const sha = randomSha1() 1615 | const getRef = jest.fn().mockReturnValueOnce({ 1616 | data: { 1617 | object: { 1618 | sha 1619 | } 1620 | } 1621 | }) 1622 | const deleteRef = jest.fn().mockReturnValueOnce({ 1623 | data: {} 1624 | }) 1625 | 1626 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1627 | return { 1628 | paginate: jest.fn().mockImplementation(() => { 1629 | return [ 1630 | buildPR(1, 'dependabot-1', ['question']), 1631 | buildPR(2, 'dependabot-2'), 1632 | buildPR(3, 'dependabot-3', ['nocombine']), 1633 | buildPR(4, 'dependabot-4'), 1634 | buildPR(5, 'dependabot-5'), 1635 | buildPR(6, 'dependabot-6'), 1636 | buildPR(7, 'fix-package') 1637 | ] 1638 | }), 1639 | graphql: jest.fn().mockImplementation((_query, params) => { 1640 | switch (params.pull_number) { 1641 | case 1: 1642 | case 2: 1643 | case 3: 1644 | return buildStatusResponse('APPROVED', 'SUCCESS') 1645 | case 4: 1646 | return buildStatusResponse('APPROVED', 'FAILURE') 1647 | case 5: 1648 | return buildStatusResponse(null, 'SUCCESS') 1649 | case 6: 1650 | return { 1651 | repository: { 1652 | pullRequest: { 1653 | reviewDecision: null, 1654 | commits: { 1655 | nodes: [ 1656 | { 1657 | commit: { 1658 | statusCheckRollup: null 1659 | } 1660 | } 1661 | ] 1662 | } 1663 | } 1664 | } 1665 | } 1666 | default: 1667 | throw new Error( 1668 | `params.pull_number of ${params.pull_number} is not configured.` 1669 | ) 1670 | } 1671 | }), 1672 | rest: { 1673 | issues: { 1674 | addLabels: jest.fn().mockReturnValueOnce({ 1675 | data: {} 1676 | }) 1677 | }, 1678 | git: { 1679 | createRef, 1680 | updateRef, 1681 | getRef, 1682 | deleteRef 1683 | }, 1684 | repos: { 1685 | // mock the first value of merge to be a success and the second to be an exception 1686 | merge: jest 1687 | .fn() 1688 | .mockReturnValueOnce({ 1689 | data: { 1690 | merged: true 1691 | } 1692 | }) 1693 | .mockImplementation(() => { 1694 | throw new Error('merge error') 1695 | }) 1696 | }, 1697 | pulls: { 1698 | create: jest.fn().mockReturnValueOnce({ 1699 | data: { 1700 | number: 100, 1701 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1702 | } 1703 | }), 1704 | updateBranch: jest.fn().mockReturnValueOnce({ 1705 | status: 202 1706 | }) 1707 | } 1708 | } 1709 | } 1710 | }) 1711 | 1712 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1713 | process.env.INPUT_CREATE_FROM_SCRATCH = 'false' 1714 | process.env.INPUT_LABELS = 'label1,label2, label3' 1715 | expect(await run()).toBe('success') 1716 | 1717 | expect(createRef).toHaveBeenCalledWith( 1718 | expect.objectContaining({ 1719 | ref: expect.stringContaining('refs/heads/combined-prs-branch') 1720 | }) 1721 | ) 1722 | expect(getRef).not.toHaveBeenCalled() 1723 | expect(updateRef).not.toHaveBeenCalled() 1724 | expect(deleteRef).not.toHaveBeenCalled() 1725 | 1726 | expect(infoMock).toHaveBeenCalledWith('Merged branch dependabot-1') 1727 | expect(warningMock).toHaveBeenCalledWith( 1728 | 'Failed to merge branch dependabot-2' 1729 | ) 1730 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1731 | expect(setOutputMock).toHaveBeenCalledWith( 1732 | 'pr_url', 1733 | 'https://github.com/test-owner/test-repo/pull/100' 1734 | ) 1735 | }) 1736 | 1737 | test('runs the action and fails to create a working branch', async () => { 1738 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1739 | return { 1740 | paginate: jest.fn().mockImplementation(() => { 1741 | return [buildPR(1, 'dependabot-1'), buildPR(2, 'dependabot-2')] 1742 | }), 1743 | graphql: jest.fn().mockImplementation(() => { 1744 | return buildStatusResponse('APPROVED', 'SUCCESS') 1745 | }), 1746 | rest: { 1747 | issues: { 1748 | createComment: jest.fn().mockReturnValueOnce({ 1749 | data: {} 1750 | }) 1751 | }, 1752 | git: { 1753 | deleteRef: jest.fn().mockReturnValueOnce({ 1754 | data: {} 1755 | }), 1756 | createRef: jest.fn().mockRejectedValueOnce(new BigBadError('Oh no!')) 1757 | }, 1758 | repos: { 1759 | merge: jest.fn().mockReturnValueOnce({ 1760 | data: {} 1761 | }) 1762 | }, 1763 | pulls: { 1764 | create: jest.fn().mockReturnValueOnce({ 1765 | data: {} 1766 | }) 1767 | } 1768 | } 1769 | } 1770 | }) 1771 | process.env.INPUT_CREATE_FROM_SCRATCH = 'true' 1772 | 1773 | expect(await run()).toBe('Failed to create working branch') 1774 | expect(setFailedMock).toHaveBeenCalledWith('Failed to create working branch') 1775 | }) 1776 | 1777 | test('successfully runs the action and sets assignees', async () => { 1778 | jest.spyOn(github, 'getOctokit').mockImplementation(() => { 1779 | return { 1780 | paginate: jest.fn().mockImplementation(() => { 1781 | return [ 1782 | buildPR(1, 'dependabot-1', ['question']), 1783 | buildPR(2, 'dependabot-2') 1784 | ] 1785 | }), 1786 | graphql: jest.fn().mockImplementation((_query, params) => { 1787 | switch (params.pull_number) { 1788 | case 1: 1789 | case 2: 1790 | case 3: 1791 | return buildStatusResponse('APPROVED', 'SUCCESS') 1792 | case 4: 1793 | return buildStatusResponse('APPROVED', 'FAILURE') 1794 | case 5: 1795 | return buildStatusResponse(null, 'SUCCESS') 1796 | case 6: 1797 | return buildStatusResponse('REVIEW_REQUIRED', 'SUCCESS') 1798 | default: 1799 | throw new Error( 1800 | `params.pull_number of ${params.pull_number} is not configured.` 1801 | ) 1802 | } 1803 | }), 1804 | rest: { 1805 | issues: { 1806 | addAssignees: jest.fn().mockReturnValueOnce({ 1807 | data: {} 1808 | }), 1809 | addLabels: jest.fn().mockReturnValueOnce({ 1810 | data: {} 1811 | }) 1812 | }, 1813 | git: { 1814 | createRef: jest.fn().mockReturnValueOnce({ 1815 | data: {} 1816 | }), 1817 | updateRef: jest.fn().mockReturnValueOnce({ 1818 | data: {} 1819 | }), 1820 | getRef: jest.fn().mockReturnValueOnce({ 1821 | data: { 1822 | object: { 1823 | sha: randomSha1() 1824 | } 1825 | } 1826 | }) 1827 | }, 1828 | repos: { 1829 | // mock the first value of merge to be a success and the second to be an exception 1830 | merge: jest.fn().mockReturnValueOnce({ 1831 | data: { 1832 | merged: true 1833 | } 1834 | }) 1835 | }, 1836 | pulls: { 1837 | create: jest.fn().mockReturnValueOnce({ 1838 | data: { 1839 | number: 100, 1840 | html_url: 'https://github.com/test-owner/test-repo/pull/100' 1841 | } 1842 | }) 1843 | } 1844 | } 1845 | } 1846 | }) 1847 | 1848 | process.env.INPUT_REVIEW_REQUIRED = 'true' 1849 | process.env.INPUT_ASSIGNEES = 'octocat ,another-user, kolossal' 1850 | expect(await run()).toBe('success') 1851 | 1852 | expect(infoMock).toHaveBeenCalledWith( 1853 | `Adding assignees to combined PR: octocat,another-user,kolossal` 1854 | ) 1855 | 1856 | expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100) 1857 | }) 1858 | 1859 | function buildStatusResponse(reviewDecision, ciStatus) { 1860 | return { 1861 | repository: { 1862 | pullRequest: { 1863 | reviewDecision: reviewDecision, 1864 | commits: { 1865 | nodes: [ 1866 | { 1867 | commit: { 1868 | statusCheckRollup: { 1869 | state: ciStatus 1870 | } 1871 | } 1872 | } 1873 | ] 1874 | } 1875 | } 1876 | } 1877 | } 1878 | } 1879 | 1880 | function buildPR(number, head, labels = [], base = null) { 1881 | return { 1882 | number: number, 1883 | title: `Update dependency ${number}`, 1884 | head: { 1885 | ref: head 1886 | }, 1887 | base: { 1888 | ref: base ?? 'main' 1889 | }, 1890 | labels: labels.map(labelName => { 1891 | return {name: labelName} 1892 | }) 1893 | } 1894 | } 1895 | --------------------------------------------------------------------------------