Skip to content

Commit

Permalink
Moving from Travis to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Nov 29, 2020
1 parent ff3428a commit bad7fd1
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 63 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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.
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 23 * * 0'

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

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# 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
44 changes: 44 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: run-go-tests

env:
GO111MODULE: on

on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
schedule:
- cron: '* 22 * * *'

jobs:
test:
strategy:
matrix:
go-version: [ 1.15.x ]
#go-version: [ 1.14.x, 1.15.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linter and tests
run: make test-ci
- name: Update code coverage
run: bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ issues:
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- abcdef
- Using the variable on range scope .* in function literal

# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
Expand Down
19 changes: 13 additions & 6 deletions .make/Makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ install-go: ## Install the application (Using Native Go)

lint: ## Run the golangci-lint application (install if not found)
@#Travis (has sudo)
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.32.2 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.33.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
@#AWS CodePipeline
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2; fi;
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.33.0; fi;
@#Github Actions
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.33.0; fi;
@#Brew - MacOS
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi;
@echo "running golangci-lint..."
Expand All @@ -60,14 +62,19 @@ test-short: ## Runs vet, lint and tests (excludes integration tests)
@echo "running tests (short)..."
@go test ./... -v -test.short

test-travis: ## Runs all tests via Travis (also exports coverage)
test-ci: ## Runs all tests via CI (exports coverage)
@$(MAKE) lint
@echo "running tests..."
@echo "running tests (CI)..."
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic

test-travis-short: ## Runs unit tests via Travis (also exports coverage)
test-ci-no-race: ## Runs all tests via CI (no race) (exports coverage)
@$(MAKE) lint
@echo "running tests (short)..."
@echo "running tests (CI - no race)..."
@go test ./... -coverprofile=coverage.txt -covermode=atomic

test-ci-short: ## Runs unit tests via CI (exports coverage)
@$(MAKE) lint
@echo "running tests (CI - unit tests only)..."
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic

uninstall: ## Uninstall the application (and remove files)
Expand Down
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
> Simple library of sanitation methods for data sanitation and reduction
[![Release](https://img.shields.io/github/release-pre/mrz1836/go-sanitize.svg?logo=github&style=flat)](https://github.com/mrz1836/go-sanitize/releases)
[![Build Status](https://travis-ci.com/mrz1836/go-sanitize.svg?branch=master)](https://travis-ci.com/mrz1836/go-sanitize)
[![Build Status](https://img.shields.io/github/workflow/status/mrz1836/go-sanitize/run-go-tests?logo=github&v=3)](https://github.com/mrz1836/go-sanitize/actions)
[![Report](https://goreportcard.com/badge/github.com/mrz1836/go-sanitize?style=flat)](https://goreportcard.com/report/github.com/mrz1836/go-sanitize)
[![codecov](https://codecov.io/gh/mrz1836/go-sanitize/branch/master/graph/badge.svg)](https://codecov.io/gh/mrz1836/go-sanitize)
[![Go](https://img.shields.io/github/go-mod/go-version/mrz1836/go-sanitize)](https://golang.org/)
Expand Down Expand Up @@ -60,37 +60,39 @@ make help

List of all current commands:
```text
all Runs multiple commands
clean Remove previous builds and any test cache data
clean-mods Remove all the Go mod cache
coverage Shows the test coverage
godocs Sync the latest tag with GoDocs
help Show this help message
install Install the application
install-go Install the application (Using Native Go)
lint Run the golangci-lint application (install if not found)
release Full production release (creates release in Github)
release Runs common.release then runs godocs
release-snap Test the full release (build binaries)
release-test Full production test release (everything except deploy)
replace-version Replaces the version in HTML/JS (pre-deploy)
tag Generate a new tag and push (tag version=0.0.0)
tag-remove Remove a tag if found (tag-remove version=0.0.0)
tag-update Update an existing tag to current commit (tag-update version=0.0.0)
test Runs vet, lint and ALL tests
test-short Runs vet, lint and tests (excludes integration tests)
test-travis Runs all tests via Travis (also exports coverage)
test-travis-short Runs unit tests via Travis (also exports coverage)
uninstall Uninstall the application (and remove files)
update-linter Update the golangci-lint package (macOS only)
vet Run the Go vet application
all Runs multiple commands
clean Remove previous builds and any test cache data
clean-mods Remove all the Go mod cache
coverage Shows the test coverage
godocs Sync the latest tag with GoDocs
help Show this help message
install Install the application
install-go Install the application (Using Native Go)
lint Run the golangci-lint application (install if not found)
release Full production release (creates release in Github)
release Runs common.release then runs godocs
release-snap Test the full release (build binaries)
release-test Full production test release (everything except deploy)
replace-version Replaces the version in HTML/JS (pre-deploy)
tag Generate a new tag and push (tag version=0.0.0)
tag-remove Remove a tag if found (tag-remove version=0.0.0)
tag-update Update an existing tag to current commit (tag-update version=0.0.0)
test Runs vet, lint and ALL tests
test-ci Runs all tests via CI (exports coverage)
test-ci-no-race Runs all tests via CI (no race) (exports coverage)
test-ci-short Runs unit tests via CI (exports coverage)
test-short Runs vet, lint and tests (excludes integration tests)
uninstall Uninstall the application (and remove files)
update-linter Update the golangci-lint package (macOS only)
vet Run the Go vet application
```
</details>

<br/>

## Examples & Tests
All unit tests and [examples](sanitize_test.go) run via [Travis CI](https://travis-ci.org/mrz1836/go-sanitize) and uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [deployment configuration file](.travis.yml).
All unit tests and [examples](examples) run via [Github Actions](https://github.com/mrz1836/go-sanitize/actions) and
uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [configuration file](.github/workflows/run-tests.yml).

Run all tests (including any integration tests)
```shell script
Expand All @@ -113,7 +115,7 @@ Read more about this Go project's [code standards](CODE_STANDARDS.md).
<br/>

## Usage
- View the [examples](sanitize_test.go)
- View the [examples](examples)
- View the [benchmarks](sanitize_test.go)
- View the [tests](sanitize_test.go)

Expand Down

0 comments on commit bad7fd1

Please sign in to comment.