Skip to content

Commit

Permalink
ci: Updated CI/CD to use GitHub actions instead of Travis (#282)
Browse files Browse the repository at this point in the history
* ci: Removing .travis.yml from CI build
* ci: Renamed flex.yaml to push_pr.yml and updated job names to match.
* ci: Ignoring pushes to docs or examples
* ci: Added snyk scan to build process
* ci: Cleaning up make target build-ci
* ci: Adding code coverage using Coveralls
* ci: Adding release workflow
* ci: Enabling docker login
* ci: Updated CI to use Docker to run tests

Co-authored-by: noly <noeliaddf@gmail.com>
  • Loading branch information
carlosroman and noly committed Feb 24, 2021
1 parent 0748889 commit a8d7d37
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 149 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
docs
.git
vendor
57 changes: 0 additions & 57 deletions .github/workflows/flex.yaml

This file was deleted.

117 changes: 117 additions & 0 deletions .github/workflows/push_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
name: Push/PR pipeline

on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- README.md
- 'docs/**'
- 'examples/**'

env:
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
ORIGINAL_REPO_NAME: "newrelic/nri-flex"
GO_VERSION: '1.15'

jobs:

test-nix:
strategy:
matrix:
os: [ ubuntu-20.04 ]
name: Run unit tests in ${{matrix.os}}
runs-on: ${{matrix.os}}
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Run unit tests
run: make ci/test
- name: Convert coverage.out to lcov.info
run: make ci/convert-coverage
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: lcov.info
flag-name: run-linux
parallel: true

test-integration-nix:
name: Run integration tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Run integration tests
run: make test-integration

snyk:
name: Run security checks via snyk
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Scan code for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
run: make ci/snyk-test

test-windows:
strategy:
matrix:
go: [ '1.16' ]
os: [ windows-2019 ]
name: Run unit and integration tests in ${{matrix.os}} with go ${{matrix.go}}
runs-on: ${{matrix.os}}
steps:
- name: checkout
uses: actions/checkout@v2
- name: install go
uses: actions/setup-go@v2
with:
go-version: ${{matrix.go}}
- name: run unit tests
# we don't have 'make' on windows.
run: |
go test ./...
- name: run integration tests
# we don't have 'make' on windows.
run: |
go test --tags=integration ./...
test-build:
name: Test binary compilation for all platforms:arch
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Build all platforms:arch
run: make ci/pre-release

finish:
name: Finish
needs: [ test-nix, test-windows ]
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
121 changes: 121 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
name: Release pipeline

on:
release:
types:
- prereleased
tags:
- 'v*'

env:
GO_VERSION: '1.15'
TAG: ${{ github.event.release.tag_name }}
IS_RELEASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # needed for goreleaser

jobs:

test-nix:
strategy:
matrix:
os: [ ubuntu-20.04 ]
name: Run unit tests in ${{matrix.os}}
runs-on: ${{matrix.os}}
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Run unit tests
run: make ci/test
- name: Convert coverage.out to lcov.info
run: make ci/convert-coverage
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: lcov.info
flag-name: run-linux
parallel: true

test-integration-nix:
name: Run integration tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Run integration tests
run: make test-integration

snyk:
name: Run security checks via snyk
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Scan code for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
run: make ci/snyk-test

test-windows:
strategy:
matrix:
go: [ '1.15' ]
os: [ windows-2019 ]
name: Run unit and integration tests in ${{matrix.os}} with go ${{matrix.go}}
runs-on: ${{matrix.os}}
steps:
- name: checkout
uses: actions/checkout@v2
- name: install go
uses: actions/setup-go@v2
with:
go-version: ${{matrix.go}}
- name: run unit tests
# we don't have 'make' on windows.
run: |
go test ./...
- name: run integration tests
# we don't have 'make' on windows.
run: |
go test --tags=integration ./...
prerelease:
name: Build and release binaries
runs-on: ubuntu-20.04
needs: [ test-nix, test-windows, snyk, test-integration-nix ]
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Pre release
run: make ci/pre-release
- name: Notify failure via Slack
if: ${{ failure() }}
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."

finish:
name: Finish
needs: [ prerelease ]
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ envvars
flexConfigs/
results
pkg/
lcov.info
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit a8d7d37

Please sign in to comment.