forked from kiegroup/git-backporting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: backport still open pull requests
- Loading branch information
0 parents
commit b3936e0
Showing
53 changed files
with
48,467 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": "off", | ||
"@typescript-eslint/semi": [ | ||
"error", | ||
"always" | ||
], | ||
"@typescript-eslint/no-explicit-any": [ | ||
"error", | ||
{ | ||
"fixToUnknown": true | ||
} | ||
], | ||
"curly": "error", | ||
"no-empty": "error", | ||
"no-console": "error", | ||
"no-alert": "error", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"warn", | ||
{ | ||
"varsIgnorePattern": "^_", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"no-fallthrough": "off", | ||
"arrow-parens": [ | ||
"error", | ||
"as-needed" | ||
] | ||
}, | ||
"env": { | ||
"node": true, | ||
"es2020": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
# Enable version updates for npm | ||
- package-ecosystem: 'npm' | ||
# Look for `package.json` and `lock` files in the `root` directory | ||
directory: '/' | ||
# Check the npm registry for updates every day (weekdays) | ||
schedule: | ||
interval: 'daily' | ||
# consider only security updates | ||
open-pull-requests-limit: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
**Thank you for submitting this pull request** | ||
|
||
fix _(please add the issue ID if it exists)_ | ||
|
||
### Referenced pull requests | ||
|
||
<!-- Add URLs of all referenced pull requests if they exist. This is only required when making | ||
changes that span multiple kiegroup repositories and depend on each other. --> | ||
<!-- Example: | ||
- https://github.com/kiegroup/droolsjbpm-build-bootstrap/pull/1234 | ||
- https://github.com/kiegroup/drools/pull/3000 | ||
- https://github.com/kiegroup/optaplanner/pull/899 | ||
- etc. | ||
--> | ||
|
||
### Checklist | ||
- [ ] Tests added if applicable. | ||
- [ ] Documentation updated if applicable. | ||
|
||
> **Note:** `dist/cli/index.js` and `dist/gha/index.js` are automatically generated by git hooks and gh workflows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: "Main CI" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
strategy: | ||
matrix: | ||
node-version: [16] | ||
os: [ubuntu-latest] | ||
fail-fast: true | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: "Pull Request Checks" | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
node-version: [16] | ||
os: [ubuntu-latest] | ||
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: release-please | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
with: | ||
release-type: node | ||
package-name: "@lampajr/bper" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This workflow create a new tag and then publish it to NPM. | ||
|
||
name: "Publish Package" | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
publish: | ||
name: "Publish" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install && npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.env | ||
node_modules/ | ||
*.code-workspace | ||
locally_execution/**/* | ||
test/**/_temp/**/* | ||
yarn.lock | ||
coverage/ | ||
test-report.xml | ||
.idea/ | ||
.vscode/ | ||
build/ | ||
# dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lint && npm run build && git add dist && rm -rf build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lint && npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 GitHub, Inc. and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<h1 align="center"> | ||
BPER: Git Backporter </br> | ||
:outbox_tray: :inbox_tray: | ||
</h1> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/lampajr/backporting"> | ||
<img alt="CI Checks Status" src="https://github.com/lampajr/backporting/actions/workflows/ci.yml/badge.svg"> | ||
</a> | ||
</p> | ||
|
||
--- | ||
|
||
**BPer** is a [NodeJS](https://nodejs.org/) command line tool that provides capabilities to *backport* [1] pull requests in an automated way. This tool also comes with a predefined GitHub action in order to make CI/CD integration easier for all users. | ||
|
||
[1] *backporting* is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another. | ||
|
||
Table of content | ||
---------------- | ||
|
||
* **[Usage](#usage)** | ||
* **[GitHub Action](#github-action)** | ||
* **[Limitations](#limitations)** | ||
* **[Contributions](#contributing)** | ||
* **[License](#license)** | ||
|
||
|
||
## Usage | ||
|
||
This tool is released on the [public npm registry](https://www.npmjs.com/), therefore it can be easily installed using `npm`: | ||
|
||
```bash | ||
$ npm install -g @lampajr/bper | ||
``` | ||
|
||
Then it can be used as any other command line tool: | ||
|
||
```bash | ||
$ bper -tb <branch> -pr <pull-request-url> -a <github-token> [-f <your-folder>] | ||
``` | ||
|
||
### Inputs | ||
|
||
This toold comes with some inputs that allow users to override the default behavior, here the full list of available inputs: | ||
|
||
| **Name** | **Command** | **Required** | **Description** | **Default** | | ||
|---------------|----------------------|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| | ||
| Version | -V, --version | - | Current version of the tool | | | ||
| Help | -h, --help | - | Display the help message | | | ||
| Target Branch | -tb, --target-branch | Y | Branch where the changes must be backported to | | | ||
| Pull Request | -pr, --pull-request | Y | Original pull request url, the one that must be backported, e.g., https://github.com/lampajr/backporting/pull/1 | | | ||
| Auth | -a, --auth | N | `GITHUB_TOKEN` or a `repo` scoped [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) | "" | | ||
| Folder | -f, --folder | N | Local folder where the repo will be checked out, e.g., /tmp/folder | {cwd}/bp | | ||
| Dry Run | -d, --dry-run | N | If enabled the tool does not push nor create anything remotely, use this to skip PR creation | false | | ||
|
||
## GitHub Action | ||
|
||
This action can be used in any GitHub workflow, below you can find a simple example of manually triggered workflow backporting a specific pull request (provided as input). | ||
|
||
```yml | ||
name: Pull Request Backporting using BPer | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
targetBranch: | ||
description: 'Target branch' | ||
required: true | ||
type: string | ||
pullRequest: | ||
description: 'Pull request' | ||
required: true | ||
type: string | ||
dryRun: | ||
description: 'Dry run' | ||
required: false | ||
default: "true" | ||
type: string | ||
|
||
jobs: | ||
backporting: | ||
name: "Backporting" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Backporting | ||
uses: lampajr/backporting@main | ||
with: | ||
target-branch: ${{ inputs.targetBranch }} | ||
pull-request: ${{ inputs.pullRequest }} | ||
auth: ${{ secrets.GITHUB_TOKEN }} | ||
dry-run: ${{ inputs.dryRun }} | ||
``` | ||
You can also use this action with other events - you'll just need to specify `target-branch` and `pull-request` params. | ||
|
||
For a complete description of all inputs see [Inputs section](#inputs). | ||
|
||
## Limitations | ||
|
||
**BPer** is in development mode, this means that it has many limitations right now. I'll try to summarize the most importan ones: | ||
|
||
- No way to override backporting pull request fields like body, reviewers and so on. | ||
- You can backport pull requests only. | ||
- It only works for [GitHub](https://github.com/). | ||
- Integrated in GitHub Actions CI/CD only. | ||
|
||
Based on these limitations, the next **Future Works** could be the following: | ||
- Give users the possibility to override/customize the backporting pull request. | ||
- Provide a way to backport single commit too (or a set of them), even if no original pull request is present. | ||
- Integrate this tool with other git management services (like GitLab and Bitbucket) to make it as generic as possible. | ||
- Provide some reusable GitHub workflows. | ||
|
||
## Contributing | ||
|
||
This is an open source project, and you are more than welcome to contribute :heart:! | ||
|
||
Every change must be submitted through a GitHub pull request (PR). Backporting uses continuous integration (CI). The CI runs checks against your branch after you submit the PR to ensure that your PR doesn’t introduce errors. If the CI identifies a potential problem, our friendly PR maintainers will help you resolve it. | ||
|
||
> **Note**: this project follows [git-conventional-commits](https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13) standards, thanks to the [commit-msg hook](./.husky/commit-msg) you are not allowed to use commits that do not follow those standards. | ||
|
||
1. Fork it (https://github.com/lampajr/backporting). | ||
|
||
2. Create your feature branch: (git checkout -b feature). | ||
|
||
3. Commit your changes with a comment: (git commit -am 'Add some feature'). | ||
|
||
4. Push to the branch to GitHub: (git push origin feature). | ||
|
||
5. Create a new pull request against `main` branch. | ||
|
||
> **Note**: you don't need to take care about typescript compilation and minifycation, there are automated [git hooks](./.husky) taking care of that! | ||
|
||
## License | ||
|
||
Backporting (BPer) open source project is licensed under the [MIT](./LICENSE) license. |
Oops, something went wrong.