Skip to content

Commit a231533

Browse files
author
Jon Corbin
authored
Makefile and developer docs (#53)
* add built binary to .gitignore * create makefile * create developer docs * quote ignored jobs * new line * use macos build agent * use ubuntu; update importer install cmd
1 parent 1aec150 commit a231533

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

.github/workflows/documentation-ci.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ jobs:
1818
with:
1919
fetch-depth: 0
2020

21+
- name: Setup Go
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version: ">=1.18.0"
25+
check-latest: true
26+
2127
- name: Install Importer
22-
run: brew install upsidr/tap/importer
28+
run: go install github.com/upsidr/importer/cmd/importer@v0.1.4
2329

2430
- name: Run Importer against all *.md files
2531
run: find . -name '*.md' -exec importer update {} \;

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
# Built binary
18+
merge-gatekeeper

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
TOKEN=${GITHUB_TOKEN}
2+
REF=main
3+
REPO=upsidr/merge-gatekeeper
4+
IGNORED=""
5+
6+
go-build:
7+
GO111MODULE=on LANG=en_US.UTF-8 CGO_ENABLED=0 go build ./cmd/merge-gatekeeper
8+
9+
go-run: go-build
10+
./merge-gatekeeper validate --token=$(TOKEN) --ref $(REF) --repo $(REPO) --ignored "$(IGNORED)"
11+
12+
docker-build:
13+
docker build -t merge-gatekeeper:latest .
14+
15+
docker-run: docker-build
16+
docker run --rm -it --name merge-gatekeeper merge-gatekeeper:latest validate --token=$(TOKEN) --ref $(REF) --repo $(REPO) --ignored "$(IGNORED)"
17+
18+
test:
19+
go test ./...

docs/developer-guide.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Working with Merge Gatekeeper locally
2+
3+
## Requirements
4+
5+
- [`go` >= 1.16.7](https://go.dev/doc/install)
6+
- [A valid github token with `repo` permissions](https://github.com/settings/tokens)
7+
- [make](https://en.wikipedia.org/wiki/Make_(software))
8+
9+
## Useful but not required
10+
11+
- [`docker`](https://docs.docker.com/engine/install/)
12+
- required for building and running via docker
13+
14+
## Building Merge Gatekeeper
15+
16+
Using the [`Makefile`](./../Makefile) run the following to build:
17+
```bash
18+
# build go binary
19+
make go-build
20+
21+
# build docker container
22+
make docker-build
23+
```
24+
25+
## Running Merge Gatekeeper
26+
27+
it is recommend to export you [github token with `repo` permissions](https://github.com/settings/tokens) to the environment using
28+
```bash
29+
export GITHUB_TOKEN="your token"
30+
```
31+
otherwise, you will need to pass your token in via
32+
```bash
33+
GITHUB_TOKEN="your token" make go-run
34+
```
35+
36+
Using the [`Makefile`](./../Makefile) run the following to run:
37+
```bash
38+
# build and run go binary
39+
make go-run
40+
41+
# build and run docker container
42+
make docker-run
43+
```
44+
45+
## Testing
46+
To test, use the makefile:
47+
48+
```bash
49+
make test
50+
```

0 commit comments

Comments
 (0)