Skip to content

Commit

Permalink
Makefile and developer docs (#53)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Jon Corbin authored Nov 23, 2022
1 parent 1aec150 commit a231533
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/documentation-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ jobs:
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
check-latest: true

- name: Install Importer
run: brew install upsidr/tap/importer
run: go install github.com/upsidr/importer/cmd/importer@v0.1.4

- name: Run Importer against all *.md files
run: find . -name '*.md' -exec importer update {} \;
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# Built binary
merge-gatekeeper
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TOKEN=${GITHUB_TOKEN}
REF=main
REPO=upsidr/merge-gatekeeper
IGNORED=""

go-build:
GO111MODULE=on LANG=en_US.UTF-8 CGO_ENABLED=0 go build ./cmd/merge-gatekeeper

go-run: go-build
./merge-gatekeeper validate --token=$(TOKEN) --ref $(REF) --repo $(REPO) --ignored "$(IGNORED)"

docker-build:
docker build -t merge-gatekeeper:latest .

docker-run: docker-build
docker run --rm -it --name merge-gatekeeper merge-gatekeeper:latest validate --token=$(TOKEN) --ref $(REF) --repo $(REPO) --ignored "$(IGNORED)"

test:
go test ./...
50 changes: 50 additions & 0 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Working with Merge Gatekeeper locally

## Requirements

- [`go` >= 1.16.7](https://go.dev/doc/install)
- [A valid github token with `repo` permissions](https://github.com/settings/tokens)
- [make](https://en.wikipedia.org/wiki/Make_(software))

## Useful but not required

- [`docker`](https://docs.docker.com/engine/install/)
- required for building and running via docker

## Building Merge Gatekeeper

Using the [`Makefile`](./../Makefile) run the following to build:
```bash
# build go binary
make go-build

# build docker container
make docker-build
```

## Running Merge Gatekeeper

it is recommend to export you [github token with `repo` permissions](https://github.com/settings/tokens) to the environment using
```bash
export GITHUB_TOKEN="your token"
```
otherwise, you will need to pass your token in via
```bash
GITHUB_TOKEN="your token" make go-run
```

Using the [`Makefile`](./../Makefile) run the following to run:
```bash
# build and run go binary
make go-run

# build and run docker container
make docker-run
```

## Testing
To test, use the makefile:

```bash
make test
```

0 comments on commit a231533

Please sign in to comment.