Skip to content

init rand once

init rand once #137

Workflow file for this run

---
name: ci
on: pull_request
jobs:
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
- name: Install yamllint
run: pip install --user yamllint
- name: Run yamllint
run: ~/.local/bin/yamllint -c .yamllint.yml --strict .
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: shellcheck
uses: fkautz/[email protected]
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.21
- run: |
go build -race ./...
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.21
- name: Install gotestsum
run: go install gotest.tools/[email protected]
- name: Run tests
run: |
eval $(go env)
mkdir -p ~/junit/
${GOPATH}/bin/gotestsum --junitfile ~/junit/unit-tests.xml -- -race -short $(go list ./...)
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
env:
GOLANGCI_LINT_CONTAINER: golangci/golangci-lint:v1.59.1
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Pull golangci-lint docker container
run: docker pull ${GOLANGCI_LINT_CONTAINER}
- name: Run golangci-lint
run: docker run --rm -v $(pwd):/app -w /app ${GOLANGCI_LINT_CONTAINER} golangci-lint run
buildDockerImage:
name: build docker image
runs-on: ubuntu-latest
env:
TAG: test
ORG: networkservicemesh
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.21
- name: build coredns binary
run: |
go build -o coredns/coredns coredns/main.go
- name: build docker image
run: |
docker build coredns/. -t "${ORG}/coredns:${TAG}"
- name: remove docker image
run:
docker image rm "${ORG}/coredns:${TAG}"
excludeFmtErrorf:
name: exclude fmt.Errorf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exclude fmt.Errorf
run: |
if grep -r --include=*.go fmt.Errorf . ; then
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
exit 1
fi
restrictNSMDeps:
name: Restrict dependencies on github.com/networkservicemesh/*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restrict dependencies on github.com/networkservicemesh/*
run: |
for i in $(grep github.com/networkservicemesh/ go.mod |grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[a-zA-z\/]*\).*;\1;g' | sort -u);do
if [ "${i}" != "github.com/networkservicemesh/api" ]; then
echo Dependency on "${i}" is forbidden
exit 1
fi
done
checkgomod:
name: check go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.21
- run: go mod tidy
- name: Check for changes in go.mod or go.sum
run: |
git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false )
git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false )
license:
name: license header check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.21
- name: Install go-header
run: 'go install github.com/denis-tingajkin/[email protected]'
- name: Run go-header
run: |
eval $(go env)
${GOPATH}/bin/go-header
excludereplace:
name: Exclude Replace in go.mod
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Exclude replace in go.mod
run: |
grep ^replace go.mod || exit 0
exit 1
captureRunEnv:
name: Capture CI Run Env
runs-on: ubuntu-latest
steps:
- run: printenv