Skip to content

feat(project): add base of project #1

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
93 changes: 93 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Go

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ develop ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: go build -race -v ./...

- name: Test
run: |
go test -race -cover -coverprofile ./coverage.out.tmp ./...
cat ./coverage.out.tmp | grep -v '.pb.go' | grep -v 'mock_' > ./coverage.out
rm ./coverage.out.tmp

- name: Coverage
id: coverage
run: |
go tool cover -func ./coverage.out | tee -a coverage.txt
#export COVERAGE_CONTENT=$(cat coverage.txt)
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
cat coverage.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- uses: actions/github-script@v4
if: github.event_name == 'pull_request'
env:
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `Code Coverage\n
\`\`\`\n
${process.env.COVERAGE_CONTENT}
\`\`\`

*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;

const response = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

var comments = response.data;

console.log(comments);

if (comments.length > 0) {
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
}

if (comments.length > 0) {
const comment = comments.shift();

github.issues.updateComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: output
})
} else {
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1
skip-pkg-cache: true
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ linters-settings:
goimports:
local-prefixes: go.opentelemetry.io

tagliatelle:
# check the struck tag name case
case:
# use the struct field name to check the name of the struct tag
use-field-name: false
rules:
# any struct tag type can be used.
# support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: snake
yaml: snake
avro: snake
mapstructure: snake


linters:
disable-all: true
Expand Down
27 changes: 27 additions & 0 deletions cmd/hyperhook/app/config/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021 Hyperhook. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package config

import (
"github.com/euskadi31/go-server"
"github.com/hyperscale/hyperhook/pkg/environment"
"github.com/hyperscale/hyperhook/pkg/logger"
)

// Configuration struct.
type Configuration struct {
Environment environment.Env
Logger *logger.Configuration
Server *server.Configuration
}

// NewConfiguration constructor.
func NewConfiguration() *Configuration {
return &Configuration{
Environment: environment.Dev,
Logger: &logger.Configuration{},
Server: &server.Configuration{},
}
}
19 changes: 19 additions & 0 deletions cmd/hyperhook/app/config/configuration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2021 Hyperhook. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package config

import (
"testing"

"github.com/hyperscale/hyperhook/pkg/environment"
"github.com/stretchr/testify/assert"
)

func TestConfiguration(t *testing.T) {
c := NewConfiguration()

assert.NotNil(t, c)
assert.Equal(t, environment.Dev, c.Environment)
}
12 changes: 12 additions & 0 deletions cmd/hyperhook/app/controller/eventemitter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2021 Hyperhook. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package controller

import "github.com/euskadi31/go-eventemitter"

//go:generate mockery --name=EventEmitter --inpackage --case underscore
type EventEmitter interface {
eventemitter.EventEmitter
}
46 changes: 46 additions & 0 deletions cmd/hyperhook/app/controller/mock_event_emitter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading