Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

build: Upgrade to Go 1.18 and optimize attribution script #445

Merged
merged 1 commit into from
Jul 13, 2022
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
8 changes: 4 additions & 4 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Intel Corporation
# Copyright (c) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,16 @@
# limitations under the License.
#

ARG BASE=golang:1.17-alpine3.15
ARG BASE=golang:1.18-alpine3.16
FROM ${BASE}

ARG ALPINE_PKG_BASE="make git zip tar"
ARG ALPINE_PKG_EXTRA=""

LABEL license='SPDX-License-Identifier: Apache-2.0' \
copyright='Copyright (c) 2020: Intel'
copyright='Copyright (c) 2022: Intel'

RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories
RUN sed -e 's/dl-cdn[.]alpinelinux.org/dl-4.alpinelinux.org/g' -i~ /etc/apk/repositories
RUN apk add --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA}

WORKDIR /edgex-cli
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ TIME=$(shell date)
GOFLAGS=-ldflags "-X 'github.com/edgexfoundry/edgex-cli.BuildVersion=$(VERSION)' -X 'github.com/edgexfoundry/edgex-cli.BuildTime=$(TIME)'"
ARTIFACT_ROOT?=bin

tidy:
go mod tidy

build:
@echo "GOPATH=$(GOPATH)"
$(GO) build -o ${ARTIFACT_ROOT}/$(BINARY) $(GOFLAGS) ./cmd/edgex-cli

tidy:
go mod tidy

# initial impl. Feel free to override. Please keep ARTIFACT_ROOT coming from env though. CI/CD pipeline relies on this
build-all:
@echo "GOPATH=$(GOPATH)"
Expand Down
40 changes: 4 additions & 36 deletions bin/test-attribution-txt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,16 @@ EXIT_CODE=0

cd "$GIT_ROOT"

if [ -d vendor.bk ]; then
echo "vendor.bk exits - remove before continuing"
exit 1
fi

trap cleanup 0 1 2 3 6

cleanup()
{
cd "$GIT_ROOT"
# restore the vendor dir
rm -rf vendor
if [ -d vendor.bk ]; then
mv vendor.bk vendor
fi
exit $EXIT_CODE
}

# if the vendor directory exists, back it up so we can build a fresh one
if [ -d vendor ]; then
mv vendor vendor.bk
fi

# create a vendor dir with the mod dependencies
GO111MODULE=on go mod vendor

# turn on nullglobbing so if there is nothing in cmd dir then we don't do
# anything in this loop
shopt -s nullglob

if [ ! -f Attribution.txt ]; then
echo "An Attribution.txt file is missing, please add"
EXIT_CODE=1
else
# loop over every library in the modules.txt file in vendor
# loop over every library in the go.mod file
while IFS= read -r lib; do
if ! grep -q "$lib" Attribution.txt && [ "$lib" != "explicit" ] && [ "$lib" != "explicit;" ]; then
echo "An attribution for $lib is missing from in Attribution.txt, please add"
if ! grep -q "$lib" Attribution.txt; then
echo "An attribution for $lib is missing from Attribution.txt, please add"
# need to do this in a bash subshell, see SC2031
(( EXIT_CODE=1 ))
fi
done < <(grep '#' < "$GIT_ROOT/vendor/modules.txt" | awk '{print $2}')
done < <(cat $GIT_ROOT/go.mod | grep -v 'module ' | grep -v TODO | grep '/' | sed 's/require //' | sed 's/replace //' | awk '{print $1}')
fi

cd "$GIT_ROOT"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/edgexfoundry/edgex-cli

go 1.18

require (
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.0.0
github.com/spf13/cobra v1.3.0
Expand All @@ -19,5 +21,3 @@ require (
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/text v0.3.7 // indirect
)

go 1.17
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ parts:
source: .
plugin: make
build-snaps:
- go/1.17/stable
- go/1.18/stable
override-build: |
cd $SNAPCRAFT_PART_SRC

Expand Down