Skip to content

Commit

Permalink
feat: initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ielaajezdev committed Jan 24, 2024
1 parent 92bb46d commit 97437db
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: release

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: simple
# if we are not at v1.0.0 yet, breaking changes do not need to add a new major version
bump-minor-pre-major: true
pull-request-title-pattern: "chore: ${scope} release${component} ${version}"

45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test
on:
push:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
lint:
name: linter
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- run: sudo apt update && sudo apt install pkg-config libzmq3-dev protobuf-compiler
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
skip-pkg-cache: true
tests:
name: automated tests
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- run: sudo apt update && sudo apt install pkg-config libzmq3-dev protobuf-compiler
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- name: Run tests
run: make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

# Go workspace file
go.work

# Build outputs
bin
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Makefile in accordance with the docs on git management (to use in combination with meta)
.PHONY: build start clean test

BUILD_DIR=bin/
BINARY_NAME=ReplaceThisName

build:
@echo "building ${BINARY_NAME}"
@cd src/ && go build -o "../$(BUILD_DIR)/${BINARY_NAME}"

start: build
@echo "starting ${BINARY_NAME}"
@cd "./${BUILD_DIR}/${BINARY_NAME}"

clean:
@echo "Cleaning all targets for mod/Actuator"
rm -rf $(BUILD_DIR)

test:
go test ./src -v -count=1 -timeout 0
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# template-GoModule
Template repository to create new Go utilities easily and make them conform to the multi-repo spec.
# template: Go module

This repository serves as a template repository which can be cloned to get you set up quickly. It can be used to write utilities, modules and packages in Go. The following will be set up for you when you use this template:

- A *Makefile* following the spec of our multi-repo setup using Meta (with the essential targets: `build`, `start`, `test`, `clean`)
- Github CI workflows and branch protections
- Including Google's release-please action to release conveniently
- On every push, the linter and all automated tests are run
- Direct pushes to main are restricted, a PR with passing status checks (lint + test) is enforced
- A correct gitignore
- A base Go module definition with zerolog installed (see *src/main.go*)

## Getting started

- Press the top right button in Github to use this repository as a template
- After cloning, make sure to do the following:
- Open *go.mod* and update the `module` field. Replace `ENTERYOURMODULENAMEHERE` with the name of your module
- Open the *Makefile* and update the `BINARY_NAME` field with the name of your module
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module vu/ase/ENTERYOURMODULENAMEHERE

go 1.21.6

require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/rs/zerolog v1.31.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1 change: 1 addition & 0 deletions include/PLACE YOUR INCLUDES HERE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Place them in this folder
7 changes: 7 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rs/zerolog/log"

func main() {
log.Info().Str("planet", "earth").Msg("Hello World!")
}
9 changes: 9 additions & 0 deletions src/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"testing"
)

func TestMain(t *testing.T) {
t.Error("Test main failed. Did you forget to remove the test in main_test.go?")
}

0 comments on commit 97437db

Please sign in to comment.