Skip to content

Commit

Permalink
GitHub Action CI/CD Migration (#553)
Browse files Browse the repository at this point in the history
* Refactored builds and tests into github actions

Signed-off-by: Corbin Phelps <[email protected]>

* Moved docker build and publish to github action

Signed-off-by: Corbin Phelps <[email protected]>

* Fixed up issues with makefile and ci/cd

Signed-off-by: Corbin Phelps <[email protected]>

* Updated readme badges

Signed-off-by: Corbin Phelps <[email protected]>

* Added action caches

Signed-off-by: Corbin Phelps <[email protected]>
  • Loading branch information
Corbin Phelps authored Feb 16, 2022
1 parent ed8843f commit 55abccb
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 581 deletions.
559 changes: 0 additions & 559 deletions .circleci/config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .circleci/scripts/startup-ttl.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .circleci/testdata/benchmark.yaml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/multi_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Build is responsible for testing builds on all supported platforms.
# It is broken up into three separate jobs with targeted builds so that each OS will
# build in parallel and speed up overall CI time.
name: Build
on:
pull_request:

jobs:
build_linux:
runs-on: ubuntu-20.04
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
check-latest: true
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make build-linux
build_darwin:
runs-on: macos-11
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
check-latest: true
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make build-darwin
build_windows:
runs-on: windows-2019
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
check-latest: true
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: |
%LocalAppData%\go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make build-windows
43 changes: 41 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: release

on:
push:
tags:
- 'v*'
tags:
- "v*"

jobs:
release:
Expand All @@ -28,3 +28,42 @@ jobs:
env:
# Default github token should have enough permissions to make a release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-push-container-image:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
check-latest: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# Org level secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Get Tag From Environment
id: get-tag
run: printf '::set-output name=tag::%s' "$(printf '%s' "${{ github.ref }}" | sed 's/refs\/tags\///')"
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: observiq/stanza:latest,observiq/stanza:${{ steps.get-tag.outputs.tag }}
59 changes: 59 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests
on:
pull_request:

jobs:
unit-tests:
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
check-latest: true

# Load caches based on OS
- name: Linux Cache Go Modules
if: matrix.os == 'ubuntu-20.04'
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: MacOS Cache Go Modules
if: matrix.os == 'macos-11'
uses: actions/cache@v2
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Windows Cache Go Modules
if: matrix.os == 'windows-2019'
uses: actions/cache@v2
with:
path: |
%LocalAppData%\go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Tests
run: go test -race -coverprofile coverage.txt -coverpkg ./... ./...
- name: Upload Codecov
# Only submit code coverage if OS is Linux
if: matrix.os == 'ubuntu-20.04'
uses: codecov/[email protected]
with:
files: ./coverage.txt
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ scan-license: build-all
$$GOPATH/bin/lichen --config=./license.yaml "./artifacts/stanza_darwin_amd64"

.PHONY: test
test: vet test-only
test: $(MAKE) for-all CMD="go test -race -coverprofile coverage.txt -coverpkg ./... ./..."

.PHONY: test-only
test-only:
$(MAKE) for-all CMD="go test -race -coverprofile coverage.txt -coverpkg ./... ./..."

.PHONY: test-integration
test-integration:
Expand Down Expand Up @@ -112,6 +109,15 @@ build:
install:
(cd ./cmd/stanza && CGO_ENABLED=0 go install .)

.PHONY: build-linux
build-linux: build-linux-amd64 build-linux-arm64

.PHONY: build-darwin
build-darwin: build-darwin-amd64 build-darwin-arm64

.PHONY: build-windows
build-windows: build-windows-amd64

.PHONY: build-all
build-all: build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64 build-windows-amd64

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<center>

[![<observIQ>](https://circleci.com/gh/observIQ/stanza.svg?style=shield&circle-token=980a514f9dc5a48ac2b8e61a4cdb7555ea5646ca)](https://app.circleci.com/pipelines/github/observIQ/stanza)
[![Action Status](https://github.com/observIQ/stanza/workflows/Build/badge.svg)](https://github.com/observIQ/stanza/actions)
[![Action Test Status](https://github.com/observIQ/stanza/workflows/Tests/badge.svg)](https://github.com/observIQ/stanza/actions)
[![codecov](https://codecov.io/gh/observIQ/stanza/branch/master/graph/badge.svg)](https://codecov.io/gh/observIQ/stanza)
[![Go Report Card](https://goreportcard.com/badge/github.com/observIQ/stanza)](https://goreportcard.com/report/github.com/observIQ/stanza)
[![License](https://github.com/observIQ/stanza/workflows/license/badge.svg)](https://github.com/observIQ/stanza/license)
Expand Down

0 comments on commit 55abccb

Please sign in to comment.