A GitHub (gh) CLI extension for automating daily development work, brought to you by Elhub's DevXP team. It implements an opinionated workflow based around small and frequent commits, squash merge, and mandatory linting and unit testing.
As mentioned, the workflow implemented by this extension is built around the Elhub's development teams opinionated workflow. It is a one-idea, one-commit workflow based around trunk based development.
We always lint and unit test commits before submitting them for review in addition to CI/CD checks; there is no point in knowingly pushing bad formatting/bugs into a pull request and wasting the reviewer's time.
To start a change, we create a new local branch:
gh dxp branch newfeature
This creates a new branch newfeature
and switches to it.
We use this new branch to work on our feature. When we feel ready to have our work reviewed, we create a pull request in the working branch.
gh dxp pr
This does a number of things. First it runs lint
and unit
in order to verify that there are no unneeded issues with the code. If all is well, it will push the newfeature
branch to GitHub and create a new pull request, asking a few questions as needed to fill in the review template.
When the code is reviewed, run:
gh dxp merge
This squash merges your pull request into the main branch and deletes both your local and the remote branch.
In addition, there are some convenience operations available to support our daily work:
gh dxp lint
This runs the installed linters on the given repository. Linters need to be configured, either locally in the repository, or with a config file in your home directory.
gh dxp unit
This runs unit tests on the given repository. The extension will try to guess the unit test framework to run based on project type, but it can also be configured in the configuration files.
!!! TODO: Describe configurations options using the .devxp file.
To avoid having to type gh dxp
constantly, we recommend running:
gh alias import alias.yml
On the alias.yml
file that follows this project. This installs a number of useful aliases for the commands in this extension.
- Install the
gh
CLI - Install gh-dxp:
gh extension install elhub/gh-dxp
Manual Install
If you want to install this extension manually, follow these steps:
-
Clone the repo
# git git clone https://github.com/elhub/gh-dxp
-
Build and install locally
cd gh-dxp; make clean install
Following are some of the things we are thinking/working on.
- Settings files that can be used to configure linters, etc.
- Linters to use
- Workflows:
- new: Create a new project with default template files.
- branch: Create a new local branch, switch to it. If already created, switch to branch
- pr: Lint, Unit Test and Create a pull request from the existing branch with default info
- merge: Squash-merge a pull request, switch back to default branch
- lint: Run linters on project
- unit: Run unit tests
- Wish-List:
- Proper Jira integration. Do some basic Jira checks (is ticket assigned, put into progress, etc).
Supported | Language | Linter |
---|---|---|
🔲 | Ansible | ansible-lint |
🔲 | C# | |
🔲 | CSS | style-lint |
✅ | Golang | golangci-cli |
🔲 | Java | checkstyle |
🔲 | Javascript | eslint |
✅ | Kotlin | detekt |
🔲 | Markdown | markdownlint |
🔲 | OpenAPI | spectral |
🔲 | Shell | ShellCheck |
🔲 | SQL | sql-lint |
🔲 | Terraform | fmt |
🔲 | Typescript | eslint |
✅ | YAML | YamlLint |