Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aiKrice committed Dec 1, 2024
2 parents de7cb11 + 71dc39d commit 5191fd0
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 89 deletions.
3 changes: 0 additions & 3 deletions .badgetizr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ badge_ci:
color: "purple"
label: "Bitrise"
logo: "bitrise"
build_number: "${BADGETIZR_BUILD_NUMBER}"
build_url: "${BADGETIZR_BUILD_URL}"

badge_ticket:
enabled: true
Expand All @@ -21,7 +19,6 @@ badge_base_branch:
settings:
color: "orange"
label: "Base Branch"
destination_pr_branch: "${BADGETIZR_PR_DESTINATION_BRANCH}"
base_branch: "develop"

badge_wip:
Expand Down
3 changes: 0 additions & 3 deletions .badgetizr.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ badge_ci:
color: "purple"
label: "Bitrise"
logo: "bitrise"
build_number: "${BADGETIZR_BUILD_NUMBER}"
build_url: "${BADGETIZR_BUILD_URL}"

badge_ticket:
enabled: true
Expand All @@ -21,7 +19,6 @@ badge_base_branch:
settings:
color: "orange"
label: "Base Branch"
destination_pr_branch: "${BADGETIZR_PR_DESTINATION_BRANCH}"
base_branch: "develop"

badge_wip:
Expand Down
5 changes: 3 additions & 2 deletions Formula/badgetizr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ class Badgetizr < Formula
desc "Badgetizr is a tool to allow custom badges automatically added and updated according the content of your pull request."
homepage "https://github.com/aiKrice/homebrew-badgetizr"
url "https://github.com/aiKrice/homebrew-badgetizr/archive/refs/tags/1.2.0.tar.gz"
sha256 "024892da67071348af9b4bef84be76c121ab8b0779dd099ae0c8478f9aec59a3"
head "https://github.com/aiKrice/homebrew-badgetizr.git", branch: "master"
sha256 "77469507609086c18662cd51dc9c5864bb2f5ee48a39e8525fe97709c2095928"
license "MIT"

depends_on "yq"
depends_on "gh"

Expand Down
115 changes: 72 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@

---

## What is Badgetizr ?
Badgetizr is a tool that will add badges to your pull requests to increase your team's productivity. It is fully customizable and you can add (almost) as many badges as you want. With Badgtizr on your CI, you will be able to save time by:
- Stop adding a link to your ticket in the description of the PR if you add the id of it in the title of the PR.
- Reminding that some tasks are still missing to do in the PR.
- Stop adding a visual indicator if your PR is a WIP.
- Having a badge to know the status of the CI pipeline without having to click on it, scrolling down to the bottom of the page _(coming soon)_.

## To read before going further: I need your ⭐ !
_📣 I would like to put this tool available with Homebrew and Apt-Get. To succeed, I need a maximum of star on this repository (according to the submission of Homebrew, min = 40stars). By using Homebrew or apt-get, I will be able to simplify the installation process by skipping the configure step below 🚀. Thank you for your help!_
_📣 I would like to put this tool available with Homebrew and Apt-Get. To succeed, I need a maximum of star on this repository (according to the submission of Homebrew, min = 75stars). By using Homebrew or apt-get, I will be able to simplify the installation process by skipping the configure step below 🚀. Thank you for your help!_

## Roadmap
- [x] Add option to use a custom configuration file
- [ ] Make the badge_ci badge dynamic (success, failure, pending)
- [ ] Add a beautiful icon for this repository
- [ ] Improve the Readme.md file
- [x] Improve the Readme.md file
- [x] Add the tools to Homebrew tap
- [ ] Add the tool to Homebrew
- [ ] Add the tool to Apt-Get
Expand All @@ -30,9 +37,8 @@ _📣 I would like to put this tool available with Homebrew and Apt-Get. To succ

To see how to contribute, please refer to the section [Contributing](#contributing).

## I am 🇫🇷 and I love coffee ☕.
I am fully engaged to make this tool the best tool ever to add badges to your pull requests and increase your productivity 🚀. The roadmap is huge and I will do my best to achieve all of this and achieve my goal to make this the best tool to add badges to your pull requests. If you want to support me, you can buy me a coffee, you will be mentioned in the README.md file as a backer ❤️.

## I love coffee ☕.
If your productivity has increased, my mission is done 🎉. This means I can go back to my coffee and enjoy it 🤤. If you want to support me, you can buy me a coffee, you will be mentioned in the README.md file as a backer ❤️. It will also motivate me to continue to work on this tool and improve it.
<a href='https://ko-fi.com/Q5Q7PPTYK' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

## Installation via Homebrew (MacOS)
Expand All @@ -47,15 +53,12 @@ $ brew tap aiKrice/badgetizr
$ brew install aiKrice/badgetizr/badgetizr
# edit the .badgetizr.yml file to your needs
$ export GITHUB_TOKEN="your_github_token"
$ export BADGETIZR_BUILD_NUMBER="123" # the build number of your CI
$ export BADGETIZR_BUILD_URL="https://your-shiny-ci.io/app/build/123" # the build url of your CI
$ export BADGETIZR_PR_DESTINATION_BRANCH="develop" # the destination branch of your PR from the CI.
```

## Installation via Apt-Get (Linux)
Coming soon...

## Installation manually
## Installation manually (for MacOS and Linux)
```bash
$ git clone https://github.com/aiKrice/badgetizr.git --branch master
$ cd badgetizr
Expand All @@ -65,46 +68,61 @@ In the rest of the documentation, I will consider that you have installed the to

## Usage
```bash
$ badgetizr
$ badgetizr #[options]
```
To see the different options available, you can use the `--help` option:
```bash
$ badgetizr --help
```

## Configuration
By default, the configuration file used is `.badgetizr.yml`. You can also specify a configuration file to use by using the `-c` option.
```bash
$ badgetizer -c my_config.yml
```

## Configuration
You can look to the `.badgetizr.yml.example` file at the root of the repository to see the different configuration options available.

All icons are available at [simpleicons.org](https://simpleicons.org/).
If you want to use an icon for your badge, you can use the `icon` option and specify the icon name (badge ci only). All icons are available at [simpleicons.org](https://simpleicons.org/).

## Badges

### Badge Ticket
`Disabled` by default.
### Badge Ticket [![Static Badge](https://img.shields.io/badge/JIRA-GH--1234-blue?logo=jirasoftware&color=blue&labelColor=grey)](https://yourproject.atlassian.net/browse/badge)
#### Status
`Disabled` by default.

#### Description

The badge ticket is a badge that will be displayed on your pull request if you have a Jira ticket or a Youtrack ticket in your pull request title or overall, something you would like to extract from the pull request title.
To do so, you have to define a pattern that will be used to extract the data (ie: ticket id). This pattern will be used with the `sed` command with the `-n -E` options and the `p` flag and will extract the first occurrence of the pattern found in the string.

For example, consider the following pull request title: `[ABC-123] My Pull Request Title`.
If you set the pattern to `.*\(([^)]+)\).*`, the ticket id `ABC-123` will be extracted from the pull request title.
You can also use the url option to define the url of the badge by letting `%s` as a placeholder for the ticket id. `url: "https://yourproject.atlassian.net/browse/%s"` will be `https://yourproject.atlassian.net/browse/ABC-123`.
You don't need to escape the `-` and ` ` characters, they will be automatically escaped.
#### Configuration:
- `color`: The color of the badge (default: `blue`).
- `label`: The label of the badge (default: `JIRA`).
- `logo`: The logo of the badge (default: `jirasoftware`).
- `sed_pattern`: The pattern to use to extract the ticket id from the pull request title (default: `.*\(([^)]+)\).*`, will match something like `feat(ABC-123): My Pull Request Title` -> `ABC-123`).
- `url`: The url of the badge (default: `https://yourproject.atlassian.net/browse/%s`, will be `https://yourproject.atlassian.net/browse/ABC-123`). You don't need to escape the `-` and ` ` characters, they will be automatically escaped.

### Badge Wip ![Static Badge](https://img.shields.io/badge/WIP-yellow?logo=vlcmediaplayer&logoColor=white)

### Badge Wip
#### Status
`Enabled` by default.

#### Description
The badge wip is a badge that will be displayed on your pull request if the pull request title contains the word `WIP` whatever the case.

### Badge Dynamic
### Badge Dynamic ![Static Badge](https://img.shields.io/badge/Task_2-Done-grey?label=Task%202&labelColor=grey&color=darkgreen)
#### Status
`Disabled` by default.

#### Description
The badge dynamic is a badge that will be displayed on your pull request if the pull request body contains a pattern. You can define multiple patterns and each pattern will be displayed with a badge.

### Badge Base Branch
`Enabled` by default.

The badge base branch is a badge that will be displayed on your pull request to indicate the target branch of the pull request. The default value is `develop`.
#### Configuration:
- `color`: The color of the badge (default: `grey`).
- `label`: The label of the badge (default: `Task 2`).
- `value`: The value of the badge (default: `Done`).
- `labelColor`: The color of the label (default: `grey`).
- `color`: The color of the badge (default: `darkgreen`).

example:
```yaml
Expand All @@ -113,8 +131,7 @@ example:
value: "Not done"
color: "orange"
```
will display:
![Static Badge](https://img.shields.io/badge/Task_1-Not_done-orange) if the checkbox is not checked.
will display: ![Static Badge](https://img.shields.io/badge/Task_1-Not_done-orange) if the checkbox is not checked.
In this case you can also use this to display a badge if the checkbox is checked.
example:
Expand All @@ -125,35 +142,47 @@ example:
color: "green"
```
will display:
![Static Badge](https://img.shields.io/badge/Task_1-Done-green) if the checkbox is checked.
will display: ![Static Badge](https://img.shields.io/badge/Task_1-Done-green) if the checkbox is checked.
You don't need to escape the `-` and ` ` characters, they will be automatically escaped.

⚠️ Beware currently the regex has limitations, it is not using sed regex but only bash regex by checking if the pattern is found in the string (like a `contains`). An opened issue has been created and you are welcome to contribute to fix this ❤️.
⚠️ Beware currently the regex has limitations, it is not using sed regex but only bash regex by checking if the pattern is found in the string (like a `contains`). An [opened issue](https://github.com/aiKrice/homebrew-badgetizr/issues/5) has been created and you are welcome to contribute to fix this ❤️.

### Badge CI
`Disabled` by default.
### Badge Base Branch ![Static Badge](https://img.shields.io/badge/Base_Branch-master-orange?labelColor=grey&color=red)

The badge ci is a badge that will be displayed on your pull request to indicate the status of the CI pipeline, the build number and the build url. Currently the status is not dynamic but it will be in a short future.
#### Status
`Enabled` by default.

You must define the build number and the build url in your environment variables such as
```shell
export BADGETIZR_BUILD_NUMBER="123"
export BADGETIZR_BUILD_URL="https://random.url%s"
```
#### Description
The badge base branch is a badge that will be displayed on your pull request to indicate the target branch of the pull request. The default value is `develop`.

## Contributing
#### CLI Parameters
- `--pr-destination-branch`: The base branch to use to compare the pull request to.

### Badge CI [![Static Badge](https://img.shields.io/badge/My_CI-Build_number-purple?logo=bitrise&logoColor=white&labelColor=purple&color=green)](https://www.google.com)
#### Status
`Disabled` by default.

#### Description
The `badge ci` is a badge that will be displayed on your pull request to indicate the status of the CI pipeline, the build number and the build url. Currently the status is **static** but it will be **dynamic** in a short future.

#### CLI Parameters:
- `--pr-build-number`: The build number of the CI pipeline.
- `--pr-build-url`: The build url of the CI pipeline.

#### Configuration:
- `color`: The color of the badge (default: `purple`).
- `label`: The label of the badge (default: `Bitrise`).
- `logo`: The logo of the badge (default: `bitrise`).

## Contributing
You are welcome to contribute to this project. The current rules to follow is that each time you are opening a pull request, you have to generate yourself the badge inside the pull request by running the script locally on your machine when your forked the repository.

example:
```bash
export GITHUB_TOKEN="your_github_token"
export BADGETIZR_BUILD_NUMBER="123"
export BADGETIZR_BUILD_URL="https://random.url%s"
export BADGETIZR_PR_DESTINATION_BRANCH="develop"
$ ./configure && ./badgetizer.sh
$ ./configure #optional, just for dependencies
$ ./badgetizer.sh
```

## Release (for maintainers)
Expand Down
Loading

0 comments on commit 5191fd0

Please sign in to comment.