Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Update GH actions #4

Draft
wants to merge 1 commit into
base: master
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
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,23 @@ jobs:
- name: Get Go dependencies
run: go get -v -t -d ./...

- name: Lint Go Code
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
make lint

- name: Run Code Coverage
run: make test-coverage

- name: Upload Coverage report to CodeCov
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}} ## https://github.com/ComplianceAsCode/libreSCAP/settings/secrets
file: ./coverage.txt

- name: Unit tests
run: go test ./...

- name: Build
run: make build
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Mostly copied from https://github.com/brpaz/github-actions-demo-go/blob/master/.github/workflows/release.yml

name: Release
on:
create:
tags:
-v*

jobs:
release:
name: Release on GitHub
runs-on ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2

- name: Validates Go releaser config
uses: docker://goreleaser/goreleaser:latest
with:
args: check

- name: Create GitHub Release
uses: docker://goreleaser/goreleaser:latest
with:
args: release
env:
GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}}

35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PROJECT_NAME := "libreSCAP"

PKG := "github.com/ComplianceAsCode/$(PROJECT_NAME)"

PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)

GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)

.PHONY: all dep lint vet test test-coverage build clean

all: build

dep: ## Get the dependencies
@go mod download

lint: ## Lint the Golang files
@golint -set_exit_status ${PKG_LIST}

vet: ## Run go vet
@go vet ${PKG_LIST}

test: ## Run unit tests
@go test -short ${PKG_LIST}

test-coverage: ## Run tests with coverage reports
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}

build: dep ## Build the binary file
@go build -i -o build/main ${PKG}

clean: ## Remove previous build
@rm -f ${PROJECT_NAME)/build

help: ## Display help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6 changes: 6 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cli

// Hello World scaffolding
func HelloWorld() string {
return "Hello. LibreSCAP is awesome."
}
13 changes: 13 additions & 0 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cli

import "testing"

func TestCLI(t *testing.T) {

result := HelloWorld()

if result != "Hello. LibreSCAP is awesome." {
t.Errorf("HelloWorld() = %s; want Hello. LibreSCAP is awesome.", result)
}

}
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
"fmt"
"github.com/ComplianceAsCode/libreSCAP/cli"
)

func main() {
fmt.Println(cli.HelloWorld())
}