diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index 1cfd6451..671715a6 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -33,13 +33,17 @@ jobs: go-version-file: 'go.mod' - name: Run unit tests run: make ci/test - - name: Convert coverage.out to lcov.info - run: make ci/convert-coverage + - name: Convert coverage to lcov + uses: jandelgado/gcov2lcov-action@v1.0.5 + with: + infile: coverage.out + outfile: coverage.lcov - name: Coveralls Parallel uses: coverallsapp/github-action@master + continue-on-error: true with: github-token: ${{ secrets.github_token }} - path-to-lcov: lcov.info + path-to-lcov: coverage.lcov flag-name: run-linux parallel: true @@ -132,6 +136,7 @@ jobs: steps: - name: Coveralls Finished uses: coverallsapp/github-action@master + continue-on-error: true with: github-token: ${{ secrets.github_token }} parallel-finished: true diff --git a/Makefile b/Makefile index ff946daa..014068cf 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SRCDIR ?= . BUILD_DIR ?= $(CURDIR)/bin COVERAGE_FILE ?= coverage.out -GO_VERSION ?= 1.22 +GO_VERSION ?= 1.22.8 GO_CMD ?= go GODOC ?= godocdown diff --git a/build/Dockerfile b/build/Dockerfile index aa24fdad..9a70aaaf 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,6 +1,38 @@ -ARG GO_VERSION=1.22 +# Use Ubuntu 16.04 as the base image +FROM ubuntu:16.04 -FROM golang:$GO_VERSION +# Define Go version +ARG GO_VERSION=1.22.8 +ARG ARCH='amd64' + +# Install dependencies +RUN apt-get update && apt-get install -y \ + curl \ + wget \ + expect \ + git \ + tar \ + gcc \ + g++ \ + gnupg2 \ + gnupg-agent \ + debsigs \ + rpm \ + build-essential \ + software-properties-common \ + python-software-properties \ + gcc-arm-linux-gnueabi \ + dpkg-sig \ + gcc-aarch64-linux-gnu + +# Install Go 1.22.8 +RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o go${GO_VERSION}.linux-${ARCH}.tar.gz && \ + tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH}.tar.gz && \ + rm go${GO_VERSION}.linux-${ARCH}.tar.gz + +# Set Go environment variables +ENV PATH="/usr/local/go/bin:${PATH}" +ENV GOPATH="/go" WORKDIR /app @@ -9,7 +41,10 @@ COPY tools /app/tools COPY go.mod go.sum Makefile /app/ +# Optional: Set Go environment flags ENV GOFLAGS="-buildvcs=false" + +# Optional: Configure git RUN git config --global --add safe.directory /go/src/github.com/newrelic/nri-flex RUN make deps diff --git a/build/compile.mk b/build/compile.mk index d4b66b28..da2b8398 100644 --- a/build/compile.mk +++ b/build/compile.mk @@ -19,7 +19,7 @@ compile-only: deps-only @mkdir -p $(BUILD_DIR)/$(GOOS) @for b in $(BINS); do \ echo "=== $(PROJECT_NAME) === [ compile ]: $(BUILD_DIR)$(GOOS)/$$b"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ $(GO_CMD) build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(GOOS)/$$b $$BUILD_FILES ; \ done @@ -40,10 +40,21 @@ compile-linux: deps-only @for b in $(BINS); do \ OUTPUT_FILE="$(BUILD_DIR)linux/$$b" ; \ echo "=== $(PROJECT_NAME) === [ compile-linux ]: $$OUTPUT_FILE"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ GOOS=linux $(GO_CMD) build -ldflags="$(LDFLAGS)" -o $$OUTPUT_FILE $$BUILD_FILES ; \ done +.PHONY: compile-linux-fips +compile-linux-fips: deps-only + @echo "=== $(PROJECT_NAME) === [ compile-linux-fips ]: building commands:" + @mkdir -p $(BUILD_DIR)/linux-fips + @for b in $(BINS); do \ + OUTPUT_FILE="$(BUILD_DIR)linux-fips/$$b" ; \ + echo "=== $(PROJECT_NAME) === [ compile-linux-fips ]: $$OUTPUT_FILE"; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ + GOOS=linux GOFIPS=1 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOEXPERIMENT=boringcrypto $(GO_CMD) build -tags fips -ldflags="$(LDFLAGS)" -o $$OUTPUT_FILE $$BUILD_FILES ; \ + done + .PHONY: build-darwin build-darwin: compile-darwin @@ -54,7 +65,7 @@ compile-darwin: deps-only @for b in $(BINS); do \ OUTPUT_FILE="$(BUILD_DIR)darwin/$$b" ; \ echo "=== $(PROJECT_NAME) === [ compile-darwin ]: $$OUTPUT_FILE"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ GOOS=darwin $(GO_CMD) build -ldflags="$(LDFLAGS)" -o $$OUTPUT_FILE $$BUILD_FILES ; \ done @@ -68,7 +79,7 @@ compile-windows: deps-only @for b in $(BINS); do \ OUTPUT_FILE="$(BUILD_DIR)windows/$$b.exe" ; \ echo "=== $(PROJECT_NAME) === [ compile-windows ]: $$OUTPUT_FILE"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ GOOS=windows $(GO_CMD) build -ldflags="$(LDFLAGS)" -o $$OUTPUT_FILE $$BUILD_FILES ; \ done @@ -82,7 +93,7 @@ compile-windows32: deps-only @for b in $(BINS); do \ OUTPUT_FILE="$(BUILD_DIR)windows/$$b.exe" ; \ echo "=== $(PROJECT_NAME) === [ compile-windows ]: $$OUTPUT_FILE"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ GOARCH=386 CGO_ENABLED=1 GOOS=windows $(GO_CMD) build -ldflags="$(LDFLAGS)" -o $$OUTPUT_FILE $$BUILD_FILES ; \ done @@ -93,6 +104,6 @@ compile-for-debug-linux: deps-only @for b in $(BINS); do \ OUTPUT_FILE="$(BUILD_DIR)/linux/$$b" ; \ echo "=== $(PROJECT_NAME) === [ compile-for-debug-linux ]: $$OUTPUT_FILE"; \ - BUILD_FILES=`find $(SRCDIR)/cmd/$$b -type f -name "*.go"` ; \ + BUILD_FILES="$(SRCDIR)/cmd/..." ; \ GOOS=linux $(GO_CMD) build -gcflags 'all=-N -l' -o $$OUTPUT_FILE $$BUILD_FILES ; \ done diff --git a/build/goreleaser.yml b/build/goreleaser.yml index d1decf70..cbc91a0b 100644 --- a/build/goreleaser.yml +++ b/build/goreleaser.yml @@ -20,12 +20,30 @@ builds: {{- if eq .Os "linux" -}} CGO_ENABLED=0 {{- end }} - # overrides: - # - goos: linux - # env: - # - CGO_ENABLED=0 + - id: nri-flex-fips + main: ./cmd/nri-flex/ + binary: nri-flex + ldflags: + - -s -w -X github.com/newrelic/nri-flex/internal/load.IntegrationVersion={{.Version}} + goos: + - linux + goarch: + - amd64 + - arm64 + env: + - CGO_ENABLED=1 + - GOEXPERIMENT=boringcrypto + - >- + {{- if eq .Arch "arm64" -}} + CC=aarch64-linux-gnu-gcc + {{- end }} + tags: + - fips archives: - - files: + - id: nri-flex + builds: + - nri-flex + files: - LICENSE - README.md - CHANGELOG.md @@ -34,6 +52,18 @@ archives: format_overrides: - goos: windows format: zip + - id: nri-flex-fips + builds: + - nri-flex-fips + files: + - LICENSE + - README.md + - CHANGELOG.md + - examples/* + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Version }}_{{ .Arch }}_fips" # Used to change `armv6` to `arm` + format_overrides: + - goos: windows + format: zip checksum: name_template: 'checksums.txt' snapshot: diff --git a/cmd/nri-flex/nri-flex-fips.go b/cmd/nri-flex/nri-flex-fips.go new file mode 100644 index 00000000..de5d3a87 --- /dev/null +++ b/cmd/nri-flex/nri-flex-fips.go @@ -0,0 +1,26 @@ +// Copyright 2019 New Relic Corporation. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +//go:build fips +// +build fips + +package main + +import ( + _ "crypto/tls/fipsonly" + + "github.com/newrelic/nri-flex/internal/load" + "github.com/newrelic/nri-flex/internal/runtime" +) + +func main() { + runtime.CommonPreInit() + + i := runtime.GetFlexRuntime() + err := runtime.RunFlex(i) + if err != nil { + load.Logrus.WithError(err).Fatal("flex: failed to run runtime") + } + + runtime.CommonPostInit() +} diff --git a/cmd/nri-flex/nri-flex.go b/cmd/nri-flex/nri-flex.go index b7060006..7d48e286 100644 --- a/cmd/nri-flex/nri-flex.go +++ b/cmd/nri-flex/nri-flex.go @@ -1,7 +1,8 @@ -/* -* Copyright 2019 New Relic Corporation. All rights reserved. -* SPDX-License-Identifier: Apache-2.0 - */ +// Copyright 2019 New Relic Corporation. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +//go:build !fips +// +build !fips package main diff --git a/go.sum b/go.sum index d771480a..dd3580e1 100644 --- a/go.sum +++ b/go.sum @@ -175,8 +175,6 @@ github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo= -github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk= github.com/pkg/sftp v1.13.7 h1:uv+I3nNJvlKZIQGSr8JVQLNHFU9YhhNpvC14Y6KgmSM= github.com/pkg/sftp v1.13.7/go.mod h1:KMKI0t3T6hfA+lTR/ssZdunHo+uwq7ghoN09/FSu3DY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -200,10 +198,6 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= -github.com/sijms/go-ora/v2 v2.8.19 h1:7LoKZatDYGi18mkpQTR/gQvG9yOdtc7hPAex96Bqisc= -github.com/sijms/go-ora/v2 v2.8.19/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= -github.com/sijms/go-ora/v2 v2.8.20 h1:VeJ97pwuIesYCeMgFmw60IiYZDst98annQCtxbLP7qU= -github.com/sijms/go-ora/v2 v2.8.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/sijms/go-ora/v2 v2.8.22 h1:3ABgRzVKxS439cEgSLjFKutIwOyhnyi4oOSBywEdOlU= github.com/sijms/go-ora/v2 v2.8.22/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -266,7 +260,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= @@ -289,7 +282,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= @@ -319,7 +311,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -331,7 +322,6 @@ golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=