From cdde7f12c92b74609e7de3494425456d18be6ca5 Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Thu, 28 Apr 2022 17:34:52 +0000 Subject: [PATCH 1/5] Add dev CodeBuild --- buildspecs/build-artifacts.yml | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 buildspecs/build-artifacts.yml diff --git a/buildspecs/build-artifacts.yml b/buildspecs/build-artifacts.yml new file mode 100644 index 00000000000..996672f74fd --- /dev/null +++ b/buildspecs/build-artifacts.yml @@ -0,0 +1,64 @@ +version: 0.2 + +env: + variables: + # Github username of the forked repo on which to make builds + GITHUBUSERNAME: prateekchaudhry + +phases: + install: + commands: + - go version + - architecture="" + # Same buildspec for different architectures - detect the architecture here and rename the artifacts accordingly + - case $(uname -m) in + x86_64) + architecture="amd64" + ;; + aarch64) + architecture="arm64" + ;; + esac + + # Tested with GOVERSION 1.15.x and 1.17.x + - GOVERSION="1.15.15" + - BUILD_LOG="build_${architecture}.log" + - GOLANG_TAR="go${GOVERSION}.linux-${architecture}.tar.gz" + + # Need to install GOLANG explicitly as required versions do not come preinstalled + - wget -O /tmp/${GOLANG_TAR} https://storage.googleapis.com/golang/${GOLANG_TAR} 2>&1 | tee $BUILD_LOG + - tar -C /usr/local -xzf /tmp/${GOLANG_TAR} 2>&1 | tee -a $BUILD_LOG + - go version + + # glibc-static required for dockerfree make method + - echo "Install glibc-static for dockerfree make method" | tee -a $BUILD_LOG + - yum -y install glibc-static 2>&1 | tee -a $BUILD_LOG + build: + commands: + - go version + - echo "build_id = $CODEBUILD_LOG_PATH" 2>&1 | tee -a $BUILD_LOG + - echo Building agent image 2>&1 | tee -a $BUILD_LOG + - AGENT_VERSION=$(cat VERSION) + - ECS_AGENT_TAR="ecs-agent-v${AGENT_VERSION}.tar" + - echo $(pwd) 2>&1 | tee -a $BUILD_LOG + + # Path readjustment for codebuild testing with fork due to cni plugins - may not needed when deploying with main account + - cd ../.. + - mv $GITHUBUSERNAME aws + - cd aws/amazon-ecs-agent + + - GO111MODULE=auto + - make dockerfree-agent-image 2>&1 | tee -a $BUILD_LOG + # Rename artifacts for architecture + - | + if [[ $architecture == "arm64" ]] ; then + mv $ECS_AGENT_TAR "ecs-agent-arm64-v${AGENT_VERSION}.tar" + ECS_AGENT_TAR="ecs-agent-arm64-v${AGENT_VERSION}.tar" + fi + post_build: + commands: +artifacts: + files: + - $ECS_AGENT_TAR + - $BUILD_LOG + name: $CODEBUILD_RESOLVED_SOURCE_VERSION From 83e2ee9186fd19e7f01df462dfb1061ea54c8c20 Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Thu, 28 Apr 2022 20:00:45 +0000 Subject: [PATCH 2/5] github GO111MODULE --- .github/workflows/static.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 776e47a68cb..1aa190b6b38 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -26,7 +26,6 @@ jobs: export PATH=$PATH:$(go env GOPATH)/bin export GO111MODULE=auto cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent - make get-deps make static-check init-check: From a1b5c46b2dc0f50c7f20513094a30b4db2679e30 Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Thu, 28 Apr 2022 20:44:36 +0000 Subject: [PATCH 3/5] Add GO111MODULE=on to init honnef staticcheck --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f87b173550..d26e8df8275 100644 --- a/Makefile +++ b/Makefile @@ -355,7 +355,7 @@ get-deps-init: cd "${GOPATH}/src/github.com/golang/mock/mockgen" && git checkout 1.3.1 && go get ./... && go install ./... && cd - GO111MODULE=on go get github.com/fzipp/gocyclo/cmd/gocyclo@v0.3.1 go get golang.org/x/tools/cmd/goimports - go get honnef.co/go/tools/cmd/staticcheck + GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck@v0.2.1 .amazon-linux-rpm-integrated-done: ./scripts/update-version.sh From 15432cce929d1df5854f2908d64198ee24c2b930 Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Thu, 28 Apr 2022 20:47:30 +0000 Subject: [PATCH 4/5] Add back get-deps to github workflows --- .github/workflows/static.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 1aa190b6b38..776e47a68cb 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -26,6 +26,7 @@ jobs: export PATH=$PATH:$(go env GOPATH)/bin export GO111MODULE=auto cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent + make get-deps make static-check init-check: From a918c287ed9061f9386e2dfb50c382bc2080977e Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Fri, 29 Apr 2022 20:11:46 +0000 Subject: [PATCH 5/5] read goversion --- buildspecs/build-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspecs/build-artifacts.yml b/buildspecs/build-artifacts.yml index 996672f74fd..770860aa39b 100644 --- a/buildspecs/build-artifacts.yml +++ b/buildspecs/build-artifacts.yml @@ -21,7 +21,7 @@ phases: esac # Tested with GOVERSION 1.15.x and 1.17.x - - GOVERSION="1.15.15" + - GOVERSION="$(cat GO_VERSION)" - BUILD_LOG="build_${architecture}.log" - GOLANG_TAR="go${GOVERSION}.linux-${architecture}.tar.gz"