Skip to content

Commit

Permalink
Merge pull request #41 from kinvolk/invidian/add-ci
Browse files Browse the repository at this point in the history
Add CI using GitHub actions
  • Loading branch information
invidian authored Nov 3, 2020
2 parents 4036c44 + 7f9ed93 commit 63a878c
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 10 deletions.
1 change: 1 addition & 0 deletions .codespell.ignorewords
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ue
4 changes: 4 additions & 0 deletions .codespell.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
./.git
./vendor
./bin
./go.sum
55 changes: 55 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI
on:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:

- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.15.3'
id: go

- name: Check out code into the Go module directory
uses: actions/[email protected]

- name: Run CI checks
run: make ci

lint:
name: Lint
runs-on: ubuntu-latest
container: golangci/golangci-lint:v1.32.2
timeout-minutes: 10
steps:

- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Run lint
run: make lint-bin

codespell:
name: Codespell
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- uses: actions/[email protected]
- name: Codespell test
uses: codespell-project/actions-codespell@master
with:
skip: ./.git,./vendor,./bin,./go.sum
ignore_words_file: '.codespell.ignorewords'
check_filenames: true
check_hidden: true
70 changes: 70 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
run:
modules-download-mode: vendor
timeout: 5m

issues:
exclude-use-default: false
max-same-issues: 0
max-issues-per-linter: 0

# List for enabled linters can be generated for updates using the following command.
# golangci-lint linters | grep -E '^\S+:' | cut -d: -f1 | sort | sed 's/^/ - /g' | grep -v -E "($(grep '^ disable:' -A 100 .golangci.yml | grep -E ' - \S+$' | awk '{print $2}' | tr \\n '|' | sed 's/|$//g'))"
linters:
disable-all: false
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- errorlint
- exhaustive
- exhaustivestruct
- exportloopref
- funlen
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- gofumpt
- goheader
- goimports
- golint
- gomnd
- gomodguard
- goprintffuncname
- ineffassign
- interfacer
- lll
- maligned
- misspell
- nakedret
- nestif
- nlreturn
- noctx
- nolintlint
- prealloc
- rowserrcheck
- scopelint
- sqlclosecheck
- structcheck
- stylecheck
- testpackage
- tparallel
- typecheck
- unconvert
- unparam
- varcheck
- whitespace
- wrapcheck
- wsl
disable:
- gci
- gochecknoglobals
- godox
- goerr113
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all release-bin image clean test vendor
.PHONY: all release-bin image clean test vendor ci lint-bin codespell
export CGO_ENABLED:=0

VERSION=$(shell ./build/git-version.sh)
Expand Down Expand Up @@ -33,3 +33,15 @@ vendor:

clean:
rm -rf bin

ci: all test

lint-bin:
@if [ "$$(git config --get diff.noprefix)" = "true" ]; then printf "\n\ngolangci-lint has a bug and can't run with the current git configuration: 'diff.noprefix' is set to 'true'. To override this setting for this repository, run the following command:\n\n'git config diff.noprefix false'\n\nFor more details, see https://github.com/golangci/golangci-lint/issues/948.\n\n\n"; exit 1; fi
golangci-lint run --new-from-rev=$$(git merge-base $$(cat .git/resource/base_sha 2>/dev/null || echo "origin/master") HEAD) ./...

codespell: CODESPELL_SKIP := $(shell cat .codespell.skip | tr \\n ',')
codespell: CODESPELL_BIN := codespell
codespell:
which $(CODESPELL_BIN) >/dev/null 2>&1 || (echo "$(CODESPELL_BIN) binary not found, skipping spell checking"; exit 0)
$(CODESPELL_BIN) --skip $(CODESPELL_SKIP) --ignore-words .codespell.ignorewords --check-filenames --check-hidden
2 changes: 1 addition & 1 deletion doc/labels-and-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A few labels may be set directly by admins to customize behavior. These are call

| name | example | setter | description |
|-------|------------|--------|---------------|
| agent | true/false | admin, update-operator | When the `auto-label-flatcar-linux` compatability mode is enabled (via flag), the `update-operator` sets agent true on Flatcar Container Linux nodes. This is a convenient label that users may node selector upon, if desired. |
| agent | true/false | admin, update-operator | When the `auto-label-flatcar-linux` compatibility mode is enabled (via flag), the `update-operator` sets agent true on Flatcar Container Linux nodes. This is a convenient label that users may node selector upon, if desired. |
| before-reboot | true | update-operator | The `update-operator` sets the `before-reboot` label when a machine want to reboot. It signifies that the before-reboot checks should run on the node, if there are any. |
| after-reboot | true | update-operator | The `update-operator` sets the `after-reboot` label when a machine has completed it's reboot. It signifies that the after-reboot checks should run on the node, if there are any. |

Expand Down
5 changes: 3 additions & 2 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ const (
// It is an opaque string, but might be semver.
AnnotationNewVersion = Prefix + "new-version"

// Ket set by update-agent to indicate it was responsible for making node unschedulable
// AnnotationAgentMadeUnschedulable is a key set by update-agent to indicate
// it was responsible for making node unschedulable.
AnnotationAgentMadeUnschedulable = Prefix + "agent-made-unschedulable"

// Keys set to true when the operator is waiting for configured annotation
// before and after the reboot repectively
// before and after the reboot respectively.
LabelBeforeReboot = Prefix + "before-reboot"
LabelAfterReboot = Prefix + "after-reboot"

Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutil/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"k8s.io/apimachinery/pkg/selection"
)

// NewRequirementOrDie wraps a call to NewRequirement and panics if the Requirment
// NewRequirementOrDie wraps a call to NewRequirement and panics if the Requirement
// cannot be created. It is intended for use in variable initializations only.
func NewRequirementOrDie(key string, op selection.Operator, vals []string) *labels.Requirement {
req, err := labels.NewRequirement(key, op, vals)
Expand Down
8 changes: 4 additions & 4 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type Kontroller struct {
// It will be set to the namespace the operator is running in automatically.
namespace string

// auto-label Flatcar Container Linux nodes for migration compatability
// auto-label Flatcar Container Linux nodes for migration compatibility
autoLabelContainerLinux bool

// reboot window
Expand All @@ -116,7 +116,7 @@ type Kontroller struct {
type Config struct {
// Kubernetesc client
Client kubernetes.Interface
// migration compatability
// migration compatibility
AutoLabelContainerLinux bool
// annotations to look for before and after reboots
BeforeRebootAnnotations []string
Expand Down Expand Up @@ -193,7 +193,7 @@ func New(config Config) (*Kontroller, error) {
}, nil
}

// Run starts the operator reconcilitation proces and runs until the stop
// Run starts the operator reconcilitation process and runs until the stop
// channel is closed.
func (k *Kontroller) Run(stop <-chan struct{}) error {
err := k.withLeaderElection()
Expand All @@ -206,7 +206,7 @@ func (k *Kontroller) Run(stop <-chan struct{}) error {
go wait.Until(k.legacyLabeler, reconciliationPeriod, stop)
}

// Before doing anytihng else, make sure the associated agent daemonset is
// Before doing anything else, make sure the associated agent daemonset is
// ready if it's our responsibility.
if k.manageAgent && k.agentImageRepo != "" {
// create or update the update-agent daemonset
Expand Down
3 changes: 2 additions & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var Semver semver.Version
func init() {
v, err := semver.Parse(Version)
if err != nil {
glog.Fatalf("invalid build of update operator; version.Version must be set at compiletime to a valid semver value. %v could not parse: %v", Version, err)
glog.Fatalf("invalid build of update operator; version.Version must be set at compile "+
"time to a valid semver value. %v could not parse: %v", Version, err)
}
Semver = v
}
Expand Down

0 comments on commit 63a878c

Please sign in to comment.