Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI testing workflow #9

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
- pull_request

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
go:
- "1.21"
- "1.22"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go }}
- name: Build
run: make build
- name: Test
run: make test-unit
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.PHONY: test build install lint clean fmt processbin

CGO_ENABLED ?= 0

BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILDDATE ?= $(shell date +"%Y-%m-%dT%H:%M:%S%z")
REVISION ?= $(shell git rev-parse HEAD)
Expand All @@ -18,19 +20,19 @@ test-ci: processbin
go test -race ./... -count=30

test-unit: processbin
go test -short -timeout 15s ./...
CGO_ENABLED=$(CGO_ENABLED) go test -short -timeout 15s ./...

processbin:
go build -o dist/processbin ./cmd/processbin
CGO_ENABLED=$(CGO_ENABLED) go build -o dist/processbin ./cmd/processbin

build:
go build -ldflags "$(VERSION_LDFLAGS)" -o dist/monoceros ./cmd/monoceros
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags "$(VERSION_LDFLAGS)" -o dist/monoceros ./cmd/monoceros

build-race:
go build -race -ldflags "$(VERSION_LDFLAGS)" -o dist/monoceros-race ./cmd/monoceros
CGO_ENABLED=$(CGO_ENABLED) go build -race -ldflags "$(VERSION_LDFLAGS)" -o dist/monoceros-race ./cmd/monoceros

install:
go install -ldflags "$(VERSION_LDFLAGS)" ./cmd/monoceros
CGO_ENABLED=$(CGO_ENABLED) go install -ldflags "$(VERSION_LDFLAGS)" ./cmd/monoceros

lint:
go mod tidy
Expand Down
3 changes: 0 additions & 3 deletions cmd/monoceros/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ package main
import (
"context"
"fmt"
"math/rand"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"
Expand Down Expand Up @@ -97,7 +95,6 @@ func mainCore(config *config.MonocerosConfig, logger *zap.Logger) error {

func main() {
prometheus.MustRegister(version.NewCollector(AppName))
rand.Seed(time.Now().UnixNano())

app := &cli.App{
Name: AppName,
Expand Down
11 changes: 4 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
module github.com/reddit/monoceros

go 1.19
go 1.21

require (
github.com/go-cmd/cmd v1.4.2
github.com/stretchr/testify v1.8.0 // indirect
go.uber.org/zap v1.21.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/google/go-cmp v0.6.0
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/common v0.37.0
github.com/prometheus/procfs v0.8.0
github.com/urfave/cli/v2 v2.11.1
go.uber.org/zap v1.21.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -27,6 +23,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/testify v1.8.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down
Loading