Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: support running unit test on multiple os #162

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 16 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@ on:
workflow_dispatch: {}

jobs:
get-go-version:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.read-go-version.outputs.version }}
steps:
- uses: actions/checkout@v3
- id: read-go-version
name: Determine Go version from go.mod
run: echo "::set-output name=version::$(grep "go 1." go.mod | cut -d " " -f 2)"

golangci-lint:
runs-on: ubuntu-latest
needs:
- get-go-version
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- uses: actions/checkout@v3
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
Expand All @@ -44,13 +32,11 @@ jobs:

staticcheck:
runs-on: ubuntu-latest
needs:
- get-go-version
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- uses: actions/checkout@v3
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
Expand All @@ -64,14 +50,15 @@ jobs:
install-go: false

unit-tests:
runs-on: ubuntu-latest
needs:
- get-go-version
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- uses: actions/checkout@v3
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
Expand All @@ -82,30 +69,31 @@ jobs:
${{ runner.os }}-ut-
- name: Check Go modules
run: |
go mod tidy && git add go.*
go mod tidy && git add go.* &&
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Check manifests
run: |
make manifests && git add config
make manifests && git add config &&
git diff --cached --exit-code || (echo 'Please run "make manifests" to generate manifests' && exit 1);
- name: Check auto-generated codes
run: |
make generate && git add apis
make generate && git add apis &&
git diff --cached --exit-code || (echo 'Please run "make generate" to generate Go codes' && exit 1);
- name: Verify gofmt
run: |
make fmt && git add pkg cmd
make fmt && git add pkg cmd &&
git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1);
- name: Verify govet
run: |
make vet && git add pkg cmd
make vet && git add pkg cmd &&
git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1);
- name: Run Go build
run: make build-koordlet build-koord-manager build-koord-scheduler
- name: Run Go test
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'
with:
flags: unittests
file: cover.out
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

[![License](https://img.shields.io/badge/License-Apache_2.0-4EB1BA.svg)](https://opensource.org/licenses/Apache-2.0)
[![codecov](https://codecov.io/github/koordinator-sh/koordinator/branch/main/graph/badge.svg?token=CPUKM09WJL)](https://codecov.io/github/koordinator-sh/koordinator)
[![CI](https://github.com/koordinator-sh/koordinator/actions/workflows/ci.yaml/badge.svg)](https://github.com/koordinator-sh/koordinator/actions/workflows/ci.yaml)
[![PRs Welcome](https://badgen.net/badge/PRs/Welcome/green?icon=https://api.iconify.design/octicon:git-pull-request.svg?color=white)](CONTRIBUTING.md)
[![Slack](https://badgen.net/badge/Slack/Join/4A154B?icon=slack)](https://join.slack.com/t/koordinator-sh/shared_invite/zt-1756qoub4-Cn4~esfdlfAPsD7cwO2NzA)

Expand Down