Skip to content

Commit

Permalink
update CI workflow (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
maskarb committed May 2, 2023
1 parent 92acab7 commit be0268b
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 72 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- downstream
- main

jobs:

golangci-lint:
name: golangci-lint
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: golangci-lint
uses: golangci/golangci-lint-action@v3

unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04

steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Display build environment
run: printenv

- name: Setup Go
uses: actions/setup-go@v3
with:
stable: 'true'
go-version: 1.18 # The Go version to download (if necessary) and use.

- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}


- name: Install kubebuilder
run : |
os=$(go env GOOS)
arch=$(go env GOARCH)
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- name: Run tests
run: |
make generate manifests
go test ./... -v -coverprofile cover.out -covermode=atomic
- name: Upload test coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
path: cover.out

coverage:
name: Coverage
needs: unit-tests
runs-on: ubuntu-22.04
steps:

- name: Checkout
# this checkout is required for the coverage report. If we don't do this, then
# the uploaded report is invalid and codecov doesn't know how to process it.
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Download coverage result from unit-tests
uses: actions/download-artifact@v3
with:
name: coverage

- name: Upload coverage
uses: codecov/[email protected]
with:
file: ./cover.out
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
17 changes: 0 additions & 17 deletions .github/workflows/golangci-lint.yaml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/unittests.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ linters:
- unused

- goimports
# - gosec

issues:
max-issues-per-linter: 0
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.50.1
rev: v1.52.2
hooks:
- id: golangci-lint

0 comments on commit be0268b

Please sign in to comment.