Skip to content
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
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: ci
on:
push:
tags:
- v*
branches:
- master
- release-*
pull_request:

jobs:

lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: golangci/golangci-lint-action@v2
with:
version: v1.42

commit:
runs-on: ubuntu-20.04
# Only check commits on pull requests.
if: github.event_name == 'pull_request'
steps:
- name: get pr commits
id: 'get-pr-commits'
uses: tim-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: check subject line length
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^.{0,72}(\n.*)*$'
error: 'Subject too long (max 72)'

test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
go-version: [1.16.x, 1.17.x]
race: ["-race", ""]

steps:
- name: checkout
uses: actions/checkout@v2
- name: install go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
stable: '!contains(${{ matrix.go-version }}, "beta") && !contains(${{ matrix.go-version }}, "rc")'
go-version: ${{ matrix.go-version }}
- name: build
run: make EXTRA_FLAGS="${{ matrix.race }}"
- name: test
run: make TESTFLAGS="${{ matrix.race }}" test
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For documentation, see https://golangci-lint.run/usage/configuration/

linters:
disable:
- errcheck
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

23 changes: 9 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ TAP ?= tap

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

all: tool runtimetest validation-executables

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

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

.PHONY: man
man:
Expand Down Expand Up @@ -56,25 +58,18 @@ validation-executables: $(VALIDATION_TESTS)
.PRECIOUS: $(VALIDATION_TESTS)
.PHONY: $(VALIDATION_TESTS)
$(VALIDATION_TESTS): %.t: %.go
go build -tags "$(BUILDTAGS)" ${TESTFLAGS} -o $@ $<
go build $(BUILD_FLAGS) -o $@ $<

print-validation-tests:
@echo $(VALIDATION_TESTS)

.PHONY: test .gofmt .govet .golint print-validation-tests
.PHONY: test .govet print-validation-tests

PACKAGES = $(shell go list ./... | grep -v vendor)
test: .gofmt .govet .golint .gotest

.gofmt:
OUT=$$(go fmt $(PACKAGES)); if test -n "$${OUT}"; then echo "$${OUT}" && exit 1; fi
test: .govet .gotest

.govet:
go vet -x $(PACKAGES)

.golint:
golint -set_exit_status $(PACKAGES)

UTDIRS = ./filepath/... ./validate/... ./generate/...
.gotest:
go test $(UTDIRS)
go test $(TESTFLAGS) ./...
12 changes: 3 additions & 9 deletions cmd/oci-runtime-tool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
return err
}
if err := g.AddPostStartHook(tmpHook); err != nil {
return err
}
g.AddPostStartHook(tmpHook)
}
}

Expand All @@ -546,9 +544,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
return err
}
if err := g.AddPostStopHook(tmpHook); err != nil {
return err
}
g.AddPostStopHook(tmpHook)
}
}

Expand All @@ -563,9 +559,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
if err := json.Unmarshal([]byte(hook), &tmpHook); err != nil {
return err
}
if err := g.AddPreStartHook(tmpHook); err != nil {
return err
}
g.AddPreStartHook(tmpHook)
}
}

Expand Down
Loading