Skip to content

Commit 17ac4c5

Browse files
authored
Merge pull request #728 from kolyshkin/gha-ci
Switch to GHA CI
2 parents 4a0d318 + 10c865d commit 17ac4c5

File tree

35 files changed

+215
-282
lines changed

35 files changed

+215
-282
lines changed

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: ci
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- master
8+
- release-*
9+
pull_request:
10+
11+
jobs:
12+
13+
lint:
14+
runs-on: ubuntu-20.04
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: golangci/golangci-lint-action@v2
18+
with:
19+
version: v1.42
20+
21+
commit:
22+
runs-on: ubuntu-20.04
23+
# Only check commits on pull requests.
24+
if: github.event_name == 'pull_request'
25+
steps:
26+
- name: get pr commits
27+
id: 'get-pr-commits'
28+
uses: tim-actions/[email protected]
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: check subject line length
33+
uses: tim-actions/[email protected]
34+
with:
35+
commits: ${{ steps.get-pr-commits.outputs.commits }}
36+
pattern: '^.{0,72}(\n.*)*$'
37+
error: 'Subject too long (max 72)'
38+
39+
test:
40+
runs-on: ubuntu-20.04
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
go-version: [1.16.x, 1.17.x]
45+
race: ["-race", ""]
46+
47+
steps:
48+
- name: checkout
49+
uses: actions/checkout@v2
50+
- name: install go ${{ matrix.go-version }}
51+
uses: actions/setup-go@v2
52+
with:
53+
stable: '!contains(${{ matrix.go-version }}, "beta") && !contains(${{ matrix.go-version }}, "rc")'
54+
go-version: ${{ matrix.go-version }}
55+
- name: build
56+
run: make EXTRA_FLAGS="${{ matrix.race }}"
57+
- name: test
58+
run: make TESTFLAGS="${{ matrix.race }}" test

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# For documentation, see https://golangci-lint.run/usage/configuration/
2+
3+
linters:
4+
disable:
5+
- errcheck

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ TAP ?= tap
44

55
BUILDTAGS=
66
RUNTIME ?= runc
7-
COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
7+
COMMIT ?= $(shell git describe --dirty --long --always --tags 2> /dev/null)
88
VERSION := ${shell cat ./VERSION}
9+
BUILD_FLAGS := -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION)" $(EXTRA_FLAGS)
10+
STATIC_BUILD_FLAGS := -tags "$(BUILDTAGS) netgo osusergo" -ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION)" $(EXTRA_FLAGS)
911
VALIDATION_TESTS ?= $(patsubst %.go,%.t,$(shell find ./validation/ -name *.go | grep -v util))
1012

1113
all: tool runtimetest validation-executables
1214

1315
tool:
14-
go build -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o oci-runtime-tool ./cmd/oci-runtime-tool
16+
go build $(BUILD_FLAGS) -o oci-runtime-tool ./cmd/oci-runtime-tool
1517

1618
.PHONY: runtimetest
1719
runtimetest:
18-
CGO_ENABLED=0 go build -installsuffix cgo -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o runtimetest ./cmd/runtimetest
20+
go build $(STATIC_BUILD_FLAGS) -o runtimetest ./cmd/runtimetest
1921

2022
.PHONY: man
2123
man:
@@ -56,25 +58,18 @@ validation-executables: $(VALIDATION_TESTS)
5658
.PRECIOUS: $(VALIDATION_TESTS)
5759
.PHONY: $(VALIDATION_TESTS)
5860
$(VALIDATION_TESTS): %.t: %.go
59-
go build -tags "$(BUILDTAGS)" ${TESTFLAGS} -o $@ $<
61+
go build $(BUILD_FLAGS) -o $@ $<
6062

6163
print-validation-tests:
6264
@echo $(VALIDATION_TESTS)
6365

64-
.PHONY: test .gofmt .govet .golint print-validation-tests
66+
.PHONY: test .govet print-validation-tests
6567

6668
PACKAGES = $(shell go list ./... | grep -v vendor)
67-
test: .gofmt .govet .golint .gotest
68-
69-
.gofmt:
70-
OUT=$$(go fmt $(PACKAGES)); if test -n "$${OUT}"; then echo "$${OUT}" && exit 1; fi
69+
test: .govet .gotest
7170

7271
.govet:
7372
go vet -x $(PACKAGES)
7473

75-
.golint:
76-
golint -set_exit_status $(PACKAGES)
77-
78-
UTDIRS = ./filepath/... ./validate/... ./generate/...
7974
.gotest:
80-
go test $(UTDIRS)
75+
go test $(TESTFLAGS) ./...

cmd/oci-runtime-tool/generate.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
529529
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
530530
return err
531531
}
532-
if err := g.AddPostStartHook(tmpHook); err != nil {
533-
return err
534-
}
532+
g.AddPostStartHook(tmpHook)
535533
}
536534
}
537535

@@ -546,9 +544,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
546544
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
547545
return err
548546
}
549-
if err := g.AddPostStopHook(tmpHook); err != nil {
550-
return err
551-
}
547+
g.AddPostStopHook(tmpHook)
552548
}
553549
}
554550

@@ -563,9 +559,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
563559
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
564560
return err
565561
}
566-
if err := g.AddPreStartHook(tmpHook); err != nil {
567-
return err
568-
}
562+
g.AddPreStartHook(tmpHook)
569563
}
570564
}
571565

0 commit comments

Comments
 (0)