Skip to content

Commit

Permalink
configure GitHub Actions (#1)
Browse files Browse the repository at this point in the history
Configure GitHub Actions
- Enable testing and quality check of source code for each pull request.
- Enable automated releasing
  • Loading branch information
fogfish authored Feb 19, 2024
1 parent cb20739 commit 26a4011
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 11 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
##
## Build the main branch
##
name: build
on:
push:
branches:
- main
- /refs/heads/main

jobs:

build:
runs-on: ubuntu-latest
steps:

## actions/setup-go@v5
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: "1.21"

## actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0

- name: go build
run: |
go build ./...
- name: go test
run: |
go test -v ./...
## reecetech/[email protected]
- uses: reecetech/version-increment@71036b212bbdc100b48aae069870f10953433346
id: version
with:
scheme: semver
increment: patch

- name: tag version
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag ${{ steps.version.outputs.v-version }}
git push origin -u ${{ steps.version.outputs.v-version }}
## goreleaser/goreleaser-action@v5
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8
with:
distribution: goreleaser
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##
## Check quality of source code
##
name: check
on:
pull_request:
types:
- opened
- synchronize

jobs:
code:
runs-on: ubuntu-latest
steps:

## actions/setup-go@v5
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: "1.21"

## actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

## dominikh/[email protected]
- uses: dominikh/staticcheck-action@ba605356b4b29a60e87ab9404b712f3461e566dc
with:
install-go: false
31 changes: 31 additions & 0 deletions .github/workflows/check-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
##
## Unit Tests & Coverage
##
name: test
on:
pull_request:
types:
- opened
- synchronize

jobs:

unit:
runs-on: ubuntu-latest
steps:

## actions/setup-go@v5
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: "1.21"

## actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: go build
run: |
go build ./...
- name: go test
run: |
go test -v $(go list ./... | grep -v /examples/)
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

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

# Go workspace file
go.work

#Go Releaser output
dist/
49 changes: 49 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
project_name: rds-health

release:
github:
owner: zalando
name: rds-health

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

ignore:
- goarch: 386

archives:
- format: binary

checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

brews:
- repository:
owner: zalando
name: rds-health
folder: Formula
goarm: "7"
homepage: https://github.com/zalando/rds-health
description: rds-health discovers anomalies, performance issues and optimization within AWS RDS.
license: MIT
test: |
system "#{bin}/rds-health --version"
9 changes: 9 additions & 0 deletions .zappr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
approvals:
groups:
zalando:
minimum: 2
from:
orgs:
- zalando
# one of [code, doc, config, tools, secrets]
X-Zalando-Type: code
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
<a href="https://github.com/zalando/rds-health/releases">
<img src="https://img.shields.io/github/v/tag/zalando/rds-health?label=version" />
</a>
<!-- Build Status
<!-- Build Status -->
<a href="https://github.com/zalando/rds-health/actions/">
<img src="https://github.com/zalando/rds-health/workflows/test/badge.svg" />
</a>
-->
<!-- GitHub -->
<a href="http://github.com/zalando/rds-health">
<img src="https://img.shields.io/github/last-commit/zalando/rds-health.svg" />
Expand All @@ -41,7 +40,16 @@ Let's get your start with `rds-health`. These few simple steps explain how to ru

### Install

Easiest way to install the latest version of utility using binary release, which are available [here](https://github.com/zalando/rds-health/releases) for multiple platforms.
Easiest way to install the latest version of utility using binary release, which are available
either from [Homebrew](https://brew.sh/) taps or [GitHub](https://github.com/zalando/rds-health/releases) for multiple platforms.

```bash
## Install using brew
brew tap zalando/rds-health https://github.com/zalando/rds-health
brew install -q rds-health

## use `brew upgrade` to upgrade to latest version
```

Alternatively, you can install application from source code but it requires [Golang](https://go.dev/) to be installed.

Expand Down Expand Up @@ -78,7 +86,7 @@ AZ ENGINE VSN INSTANCE CPU MEM STORAGE TYPE RO NAME
1b postgres 14.7 db.t3.medium 2x 4 GiB 40 GiB gp2 my-database-2
...
(use "rds-health check -a" to check health status of instances)
(use "rds-health check" to check health status of instances)
```


Expand Down Expand Up @@ -148,4 +156,4 @@ The library is [MIT](./LICENSE.md) licensed and accepts contributions via GitHub

## License

[![See LICENSE](https://img.shields.io/github/license/zalando/rds-health.svg?style=for-the-badge)](LICENSE)
[![See LICENSE](https://img.shields.io/github/license/zalando/rds-health.svg?style=for-the-badge)](./LICENSE.md)
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ func list(cmd *cobra.Command, args []string, api Service) error {

func listPost(cmd *cobra.Command, args []string) {
if !outJsonify {
stderr("\n(use \"rds-health check -a\" to check health status of instances)\n")
stderr("\n(use \"rds-health check\" to check health status of instances)\n")
}
}
7 changes: 3 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
)

// Execute is entry point for cobra cli application
func Execute() {
func Execute(vsn string) {
rootCmd.Version = vsn

if err := rootCmd.Execute(); err != nil {
e := err.Error()
fmt.Println(strings.ToUpper(e[:1]) + e[1:])
Expand Down Expand Up @@ -51,8 +53,6 @@ func init() {

}

var version = "v0.0.0-dev"

var rootCmd = &cobra.Command{
Use: "rds-health",
Short: "command line interface to check health of AWS RDS",
Expand Down Expand Up @@ -152,7 +152,6 @@ Examples:
`,
Run: root,
PersistentPreRun: setup,
Version: version,
}

func root(cmd *cobra.Command, args []string) {
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
package main

import (
"fmt"

"github.com/zalando/rds-health/cmd"
)

var (
// See https://goreleaser.com/cookbooks/using-main.version/
version = "dev"
commit = "unknown"
date = "unknown"
)

func main() {
cmd.Execute()
cmd.Execute(fmt.Sprintf("rds-health/%s (%s), %s", version, commit[:7], date))
}

0 comments on commit 26a4011

Please sign in to comment.