Skip to content

Commit f4f8c19

Browse files
authored
Merge pull request #1 from mona-actions/init-cli
Init cli
2 parents 74dcc09 + 324609b commit f4f8c19

12 files changed

Lines changed: 1664 additions & 232 deletions

File tree

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Please include a summary of the changes and the related issue. Please also inclu
1515
## Checklist
1616

1717
<!-- - [ ] Issue linked if existing -->
18+
- [ ] I have added the appropriate label to this PR according to the type of change
1819
- [ ] I have commented my code, particularly in hard-to-understand areas
1920
- [ ] I have made corresponding changes to the documentation
2021
- [ ] I have added tests

.github/workflows/build.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ jobs:
2121
CI: true
2222
steps:
2323
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b #v4.1.4
24-
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 #v5.0.1
24+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 #v6.0.0
2525
with:
26-
go-version: 1.21
26+
go-version-file: ./go.mod
2727
- run: go get -v -t -d ./...
28-
- run: go build -v .
28+
29+
- name: Run Build
30+
run: go build -v .
31+
32+
- name: Run Tests
33+
run: go test -v ./...

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b #v4.1.4
13-
- uses: cli/gh-extension-precompile@v2
13+
- uses: cli/gh-extension-precompile@561b19deda1228a0edf856c3325df87416f8c9bd #v2.0.0
1414
with:
15-
go_version: 1.23
15+
go_version_file: go.mod

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ scratch
3232
*.csv
3333
*.log
3434
.vscode
35-
.env
35+
.env
36+
37+
# binary
38+
gh-migration-validator

README.md

Lines changed: 104 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,125 @@
1-
# gh-extension-template
1+
# GitHub Migration Validator
22

3-
`gh-extension-template` is a template for creating GitHub CLI extensions. It provides a basic structure and some common features to help you get started quickly.
3+
A GitHub CLI extension for validating GitHub organization and repository migrations by comparing key metrics between source and target repositories.
4+
5+
## Overview
6+
7+
The GitHub Migration Validator helps ensure that your migration from one GitHub organization/repository to another has been completed successfully. It compares various repository metrics (issues, pull requests, tags, releases, commits) between source and target repositories and provides a detailed validation report.
48

59
## Install
610

711
```bash
8-
gh extension install mona-actions/<repo-name>
12+
gh extension install mona-actions/gh-migration-validator
913
```
1014

11-
## Dependencies
15+
## Usage
1216

13-
- [Go](https://golang.org/doc/install) 1.20 or higher
14-
- Key dependencies:
15-
- [Cobra](https://github.com/spf13/cobra) - CLI framework for command line applications
16-
- [Viper](https://github.com/spf13/viper) - Configuration management with environment variable support
17-
- [go-github](https://github.com/google/go-github) - GitHub REST API v3 client
18-
- [githubv4](https://github.com/shurcooL/githubv4) - GitHub GraphQL API v4 client
19-
- [go-githubauth](https://github.com/jferrl/go-githubauth) - GitHub App authentication
20-
- [go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) - Rate limit handling
17+
### Basic Usage
18+
19+
```bash
20+
gh migration-validator \
21+
--source-organization "source-org" \
22+
--target-organization "target-org" \
23+
--source-repo "my-repo" \
24+
--target-repo "my-repo" \
25+
--source-token "ghp_xxx" \
26+
--target-token "ghp_yyy"
27+
```
2128

22-
## Features
29+
### With Markdown Output
2330

24-
- Pre-configured GitHub API clients:
25-
- REST API client using [`go-github`](https://github.com/google/go-github)
26-
- GraphQL API client with rate limit handling
27-
- Support for both Personal Access Token and GitHub App authentication
28-
- Enterprise Server support via hostname configuration
31+
```bash
32+
gh migration-validator \
33+
--source-organization "source-org" \
34+
--target-organization "target-org" \
35+
--source-repo "my-repo" \
36+
--target-repo "my-repo" \
37+
--source-token "ghp_xxx" \
38+
--target-token "ghp_yyy" \
39+
--markdown-table
40+
```
2941

30-
- Common CLI flags:
31-
- Source/target organization flags
32-
- Token authentication flags
33-
- Enterprise hostname support
34-
- All flags support environment variable configuration
42+
### Environment Variables
3543

36-
- Built-in release management:
37-
- Automated versioning using Release Drafter
38-
- Version bumping based on PR labels
39-
- Automated changelog generation
40-
- Pre-compiled extension binaries
44+
You can use environment variables instead of flags:
4145

42-
### Environment variables
46+
```bash
47+
export GHMV_SOURCE_ORGANIZATION="source-org"
48+
export GHMV_TARGET_ORGANIZATION="target-org"
49+
export GHMV_SOURCE_TOKEN="ghp_xxx"
50+
export GHMV_TARGET_TOKEN="ghp_yyy"
51+
export GHMV_SOURCE_REPO="my-repo"
52+
export GHMV_TARGET_REPO="my-repo"
53+
export GHMV_MARKDOWN_TABLE="true"
54+
55+
gh migration-validator
56+
```
4357

44-
GitHub App authentication in this template is not handled by flags, but by environment variables. You can set them in your shell or in a `.env` file.
45-
This can be quickly changed to add flags for the app ID, private key, and installation ID.
58+
### GitHub App Authentication
59+
60+
For GitHub App authentication, use environment variables:
61+
62+
```bash
63+
# Source GitHub App
64+
export GHMV_SOURCE_APP_ID="123456"
65+
export GHMV_SOURCE_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..."
66+
export GHMV_SOURCE_INSTALLATION_ID="987654"
67+
68+
# Target GitHub App
69+
export GHMV_TARGET_APP_ID="123457"
70+
export GHMV_TARGET_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..."
71+
export GHMV_TARGET_INSTALLATION_ID="987655"
72+
```
4673

47-
It's recommended to use the prefix set in the `viper` configuration, which is `GHET_` in this case, to avoid conflicts with other environment variables.
74+
### Enterprise Server Support
4875

49-
```sh
50-
# Required for GitHub App auth
51-
export GHET_SOURCE_APP_ID="123456"
52-
export GHET_SOURCE_PRIVATE_KEY="-----BEGIN RSA -----\n..."
53-
export GHET_SOURCE_INSTALLATION_ID="987654"
76+
For GitHub Enterprise Server:
5477

55-
# Optional Enterprise Server URL
56-
export GHET_SOURCE_HOSTNAME="https://github.example.com"
78+
```bash
79+
export GHMV_SOURCE_HOSTNAME="https://github.example.com"
5780
```
5881

82+
## What Gets Validated
83+
84+
The tool compares the following metrics between source and target repositories:
85+
86+
- **Issues**: Total count (expects +1 in target for migration log issue)
87+
- **Pull Requests**: Total, Open, Merged, and Closed counts
88+
- **Tags**: Total count of Git tags
89+
- **Releases**: Total count of GitHub releases
90+
- **Commits**: Total commit count on default branch
91+
- **Latest Commit SHA**: Ensures both repositories have the same latest commit in default branch
92+
93+
## Validation Results
94+
95+
-**PASS**: Metrics match expected values
96+
-**FAIL**: Target is missing data from source
97+
- ⚠️ **WARN**: Target has more data than source (usually acceptable)
98+
99+
## Output Formats
100+
101+
### Console Output
102+
The tool provides a formatted table with colored status indicators and a summary.
103+
104+
### Markdown Output
105+
Use the `--markdown-table` flag to generate copy-paste ready markdown for documentation.
106+
107+
## Dependencies
108+
109+
- [Go](https://golang.org/doc/install) 1.20 or higher
110+
- Key dependencies:
111+
- [Cobra](https://github.com/spf13/cobra) - CLI framework
112+
- [Viper](https://github.com/spf13/viper) - Configuration management
113+
- [go-github](https://github.com/google/go-github) - GitHub REST API client
114+
- [githubv4](https://github.com/shurcooL/githubv4) - GitHub GraphQL API client
115+
- [go-githubauth](https://github.com/jferrl/go-githubauth) - GitHub App authentication
116+
- [go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) - Rate limit handling
117+
- [pterm](https://github.com/pterm/pterm) - Terminal styling and formatting
118+
119+
## Contributing
120+
121+
Contributions are welcome! Please see [CONTRIBUTING.md](.github/contributing.md) for guidelines.
122+
59123
## License
60124

61-
- [MIT](./license) (c) [Mona-Actions](https://github.com/mona-actions)
62-
- [Contributing](./contributing.md)
125+
[MIT](./LICENSE) © [Mona-Actions](https://github.com/mona-actions)

0 commit comments

Comments
 (0)