Skip to content

Commit

Permalink
Update README, Add "make run" target.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinHeinz committed Jan 1, 2022
1 parent 5c0f024 commit 9ff48e6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ ci: $(BUILD_DIRS)
$(BUILD_DIRS):
@mkdir -p $@

run:
@docker run \
--rm \
--name go-github-app \
-v $$(pwd)/config:/config \
-p 8080:8080 \
$(IMAGE):$(TAG)

clean: container-clean bin-clean

container-clean:
Expand Down
68 changes: 62 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Template for GitHub Apps built with Golang
# Template for GitHub Apps built with Golang

[![Build, Test and Lint Action](https://github.com/MartinHeinz/go-github-app/workflows/Build,%20Test,%20Lint/badge.svg)](https://github.com/MartinHeinz/go-github-app/workflows/Build,%20Test,%20Lint/badge.svg)
[![Release Action](https://github.com/MartinHeinz/go-github-app/workflows/Release/badge.svg)](https://github.com/https://github.com/MartinHeinz/go-github-app/workflows/Release/badge.svg)
Expand All @@ -7,11 +7,67 @@
[![Test Coverage](https://api.codeclimate.com/v1/badges/05a671e6cc9b25ddd1e5/test_coverage)](https://codeclimate.com/github/MartinHeinz/go-github-app/test_coverage)
[![Go Report Card](https://goreportcard.com/badge/github.com/MartinHeinz/go-github-app)](https://goreportcard.com/report/github.com/MartinHeinz/go-github-app)

### Running
## Blog Posts - More Information About This Repo

You can find more information about this project/repository and how to use it in following blog post:

- _Soon..._

## Quick Start

To use this repository as starter for your project you can run configure_project.sh script, which sets up all variables and file names. This way you can avoid configuring and renaming things yourself:

```bash
docker run --rm --name go-github-app \
-v $(pwd)/config:/config \
-p 8080:8080 \
ghcr.io/martinheinz/go-github-app/app
./configure_project.sh \
APP_ID="54321" \
INSTALLATION_ID="987654321" \
WEBHOOK_SECRET="verysecret" \
KEY_PATH="./github_key.pem" \
REGISTRY="ghcr.io/<GITHUB_USERNAME>/go-github-app"
```

## Running

```bash
make container # Builds containerized application
make run # Runs container at localhost

# From another terminal:
curl http://localhost:8080/api/v1/github/pullrequests/octocat/hello-world
```

## Testing

Test are run inside container image, equivalent to the container in which the application runs. To run tests:

```bash
make test

Running tests:
? github.com/MartinHeinz/go-github-app/cmd/app [no test files]
ok github.com/MartinHeinz/go-github-app/cmd/app/apis 0.010s
? github.com/MartinHeinz/go-github-app/cmd/app/config [no test files]
? github.com/MartinHeinz/go-github-app/cmd/app/httputil [no test files]
? github.com/MartinHeinz/go-github-app/cmd/app/test_data [no test files]
? github.com/MartinHeinz/go-github-app/cmd/app/utils [no test files]
ok github.com/MartinHeinz/go-github-app/cmd/app/webhooks 0.006s
? github.com/MartinHeinz/go-github-app/pkg [no test files]

Checking gofmt: PASS

Checking go vet: PASS
```

## CI/CD

Predefined CI/CD uses GitHub Actions:

- _Build, Test, Lint_ Workflow (`build.yaml`):
- Builds binary and container image
- Runs tests and generates code coverage report
- Performs SonarCloud code analysis
- Sends coverage starts to CodeClimate

- _Release_ Workflow (`release.yaml`, triggered on _tag_ creation):
- Builds container image
- Pushes the image to GitHub container registry
2 changes: 1 addition & 1 deletion cmd/app/apis/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func GetPullRequests(c *gin.Context) {
if pullRequests, resp, err := config.Config.GitHubClient.PullRequests.List(c, owner, repo, &github.PullRequestListOptions{
State: "open",
}); err != nil {
c.AbortWithStatus(resp.StatusCode)
log.Println(err)
c.AbortWithStatus(resp.StatusCode)
} else {
var pullRequestTitles []string
for _, pr := range pullRequests {
Expand Down

0 comments on commit 9ff48e6

Please sign in to comment.