Skip to content

Commit

Permalink
CI: Add GitHub workflows and Pull reuest template (#2)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflows

* Add pull request template

* ci: Fix condition, master -> main

* Add config for golanci-lint
  • Loading branch information
onprem committed Dec 20, 2020
1 parent 53f905d commit 34b18ff
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 0 deletions.
1 change: 1 addition & 0 deletions .errcheck_excludes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(github.com/go-kit/kit/log.Logger).Log
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Keep PR title verbose enough and add prefix telling
about what components it touches e.g "furnace:", "docs:", or ".*:"
-->

<!--
Don't forget about CHANGELOG!
Changelog entry format:
- [#<PR-ID>](<PR-URL>) Foundry <Component> ...
<PR-ID> Id of your pull request.
<PR-URL> URL of your PR such as https://github.com/prmsrswt/foundry/pull/<PR-ID>
<Component> Component affected by your changes such as Furnace, Store, Gateway.
-->

- [ ] I added CHANGELOG entry for this change.
- [ ] Change is not relevant to the end user.

## Changes

<!-- Enumerate changes you made -->

## Verification

<!-- How you tested it? How do you know it works? -->
67 changes: 67 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '30 12 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
75 changes: 75 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

name: run tests
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Run linters
uses: golangci/golangci-lint-action@v2
with:
version: v1.33.0

test:
strategy:
matrix:
go-version: [1.15.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Run tests
run: go test -v -covermode=count ./...

coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Calc coverage
run: |
go test -v -covermode=count -coverprofile=coverage.out ./...
- name: Convert coverage.out to coverage.lcov
uses: jandelgado/gcov2lcov-action@v1.0.6
- name: Coveralls
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov

build:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Build binaries
run: |
go build ./cmd/foundry/...
63 changes: 63 additions & 0 deletions .github/workflows/upload_assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
release:
types: [created]

name: Upload release assets after release is created
jobs:
build:
name: build binaries
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: build
run: |
echo "GO111MODULE=on" >> $GITHUB_ENV
GOOS=windows GOARCH=amd64 go build ./cmd/foundry/... -o bin/foundry-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build ./cmd/foundry/... -o bin/foundry-linux-amd64
GOOS=darwin GOARCH=amd64 go build ./cmd/foundry/... -o bin/foundry-macos-amd64
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: binaries
path: bin/

upload:
name: Upload release assets
runs-on: ubuntu-latest
needs: [build]
steps:

- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- uses: actions/checkout@v1

- name: Download build artifacts
uses: actions/download-artifact@v1
with:
name: binaries
path: bin/

- name: Create asset zips
env:
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
run: |
mkdir assets
mv bin/foundry-windows-amd64.exe foundry-${SOURCE_TAG}-windows-amd64.exe
mv bin/foundry-linux-amd64 assets/foundry-${SOURCE_TAG}-linux-amd64
mv bin/foundry-darwin-amd64 assets/foundry-${SOURCE_TAG}-darwin-amd64
sha256sum assets/* > assets/SHASUMS256.txt
- name: Upload release assets
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: './assets/*'
57 changes: 57 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs: vendor

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

linters:
enable:
# Sorted alphabetically.
- deadcode
- errcheck
- goconst
- godot
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- structcheck
- typecheck
- unparam
- unused
- varcheck
- exportloopref

linters-settings:
errcheck:
exclude: ./.errcheck_excludes.txt
misspell:
locale: US
goconst:
min-occurrences: 5
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

NOTE: As semantic versioning states all 0.y.z releases can contain breaking changes in API (flags, gRPC API, any backward compatibility)

We use _breaking :warning:_ to mark changes that are not backward compatible (relates only to v0.y.z releases.)

## Unreleased

### Added

### Fixed

### Changed

0 comments on commit 34b18ff

Please sign in to comment.