Skip to content

Commit

Permalink
build: update Makefile to be more modern
Browse files Browse the repository at this point in the history
Added copywrite and golangci-lint steps to ci.yaml

Added all ubuntu versions to test matrix

Will make pass over the CRT build file in followup
  • Loading branch information
shoenig committed Jun 28, 2024
1 parent 6fa450b commit a0eb80a
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 243 deletions.
15 changes: 15 additions & 0 deletions .copywrite.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

schema_version = 1

project {
license = "MPL-2.0"
copyright_year = 2024

header_ignore = [
".golangci.yaml",
".copywrite.hcl",
".github/**",
]
}
File renamed without changes.
53 changes: 53 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run CI Tests
on:
pull_request:
paths-ignore:
- 'README.md'
push:
branches:
- 'main'
paths-ignore:
- 'README.md'
jobs:
run-lint:
timeout-minutes: 10
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-golang@v3
with:
version-file: go.mod
- uses: golangci/golangci-lint-action@v3
with:
version: 1.59.1
skip-cache: true
args: --timeout=9m
run-copywrite:
timeout-minutes: 10
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: hashicorp/[email protected]
- name: verify copywrite headers
run: |
copywrite --config .copywrite.hcl headers --spdx "MPL-2.0" --plan
run-tests:
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-golang@v3
with:
version-file: go.mod
- name: Run Go Test
run: |
make test
permissions:
contents: read
16 changes: 0 additions & 16 deletions .github/workflows/tests.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.3
1.22.4
56 changes: 0 additions & 56 deletions GNUmakefile

This file was deleted.

49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SHELL = bash

NOMAD_PLUGIN_DIR ?= /tmp/nomad-plugins

.PHONY: clean
clean:
@echo "==> Cleanup previous build"
rm -f $(NOMAD_PLUGIN_DIR)/nomad-device-nvidia

.PHONY: copywrite
copywrite:
@echo "==> Checking copywrite headers"
copywrite --config .copywrite.hcl headers --spdx "MPL-2.0"

.PHONY: compile
compile: clean
@echo "==> Compile nvidia driver plugin ..."
mkdir -p $(NOMAD_PLUGIN_DIR)
go build -race -trimpath -o $(NOMAD_PLUGIN_DIR)/nomad-device-nvidia cmd/main.go

.PHONY: test
test:
@echo "==> Running tests ..."
go test -v -race ./...

.PHONY: hack
hack: compile
hack:
@echo "==> Run dev Nomad with nomad plugin"
sudo nomad agent -dev -plugin-dir=$(NOMAD_PLUGIN_DIR)

# CRT release compilation
pkg/%/nomad-device-nvidia: GO_OUT ?= $@
pkg/%/nomad-device-nvidia:
@echo "==> RELEASE BUILD of $@ ..."
GOOS=linux GOARCH=$(lastword $(subst _, ,$*)) \
go build -trimpath -o $(GO_OUT) cmd/main.go

# CRT release packaging (zip only)
.PRECIOUS: pkg/%/nomad-device-nvidia
pkg/%.zip: pkg/%/nomad-device-nvidia
@echo "==> RELEASE PACKAGING of $@ ..."
@cp LICENSE $(dir $<)LICENSE.txt
zip -j $@ $(dir $<)*

# CRT version generation
.PHONY: version
version:
@$(CURDIR)/version/generate.sh version/version.go version/version.go
99 changes: 51 additions & 48 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module github.com/hashicorp/nomad-device-nvidia

go 1.21
go 1.22

replace (
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
)
// maintain the go-metrics version required by nomad
replace github.com/armon/go-metrics => github.com/armon/go-metrics v0.0.0-20230509193637-d9ca9af9f1f9

// switched to a broken vanity url
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16

require (
github.com/NVIDIA/go-nvml v0.12.0-2
github.com/NVIDIA/go-nvml v0.12.4-0
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/nomad v1.7.6
github.com/shoenig/test v1.7.2
github.com/hashicorp/nomad v1.8.1
github.com/shoenig/test v1.8.2
)

require (
Expand All @@ -21,36 +22,36 @@ require (
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/armon/go-metrics v0.5.3 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/container-storage-interface/spec v1.9.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-test/deep v1.1.0 // indirect
github.com/gojuno/minimock/v3 v3.1.3 // indirect
github.com/gojuno/minimock/v3 v3.3.13 // indirect
github.com/golang-jwt/jwt/v5 v5.1.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/consul/api v1.26.1 // indirect
github.com/hashicorp/consul/api v1.29.1 // indirect
github.com/hashicorp/cronexpr v1.1.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.13 // indirect
github.com/hashicorp/go-bexpr v0.1.14 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-msgpack v1.1.6-0.20240304204939-8824e8ccc35f // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.1 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/listenerutil v0.1.9 // indirect
Expand All @@ -61,28 +62,28 @@ require (
github.com/hashicorp/go-set/v2 v2.1.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.6 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/memberlist v0.5.0 // indirect
github.com/hashicorp/raft v1.6.0 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/hashicorp/memberlist v0.5.1 // indirect
github.com/hashicorp/raft v1.7.0 // indirect
github.com/hashicorp/raft-autopilot v0.2.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/hashicorp/vault/api v1.10.0 // indirect
github.com/hashicorp/serf v0.10.2-0.20240625143733-fca5ddd4724e // indirect
github.com/hashicorp/vault/api v1.14.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hpcloud/tail v1.0.1-0.20170814160653-37f427138745 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jefferai/isbadcipher v0.0.0-20190226160619-51d2077c035f // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.57 // indirect
github.com/miekg/dns v1.1.61 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -97,36 +98,38 @@ require (
github.com/oklog/run v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/shirou/gopsutil/v3 v3.23.10 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-landlock v1.2.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
kernel.org/pub/linux/libs/security/libcap/psx v1.2.70 // indirect
oss.indeed.com/go/libtime v1.6.0 // indirect
)
Loading

0 comments on commit a0eb80a

Please sign in to comment.