From 55271f890296fef38d219bf277522fb9cc28f24f Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Mon, 22 Feb 2021 09:44:02 +0100 Subject: [PATCH 1/4] Add support for Go 1.16 Signed-off-by: Cosmin Cojocar --- go1.16/Dockerfile | 22 ++++++++++++++++ go1.16/entrypoint.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 go1.16/Dockerfile create mode 100755 go1.16/entrypoint.sh diff --git a/go1.16/Dockerfile b/go1.16/Dockerfile new file mode 100644 index 00000000..72d22799 --- /dev/null +++ b/go1.16/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.16 + +LABEL name="Golang Action" +LABEL maintainer="Cedric Kring" +LABEL version="2.0.0" +LABEL repository="https://github.com/cedrickring/golang-action" + +LABEL com.github.actions.name="Golang Action" +LABEL com.github.actions.description="Run Golang commands" +LABEL com.github.actions.icon="box" +LABEL com.github.actions.color="blue" + +# Install dep and check sha256 checksum matches for version 0.5.4 https://github.com/golang/dep/releases/tag/v0.5.4 +RUN set -eux; \ + curl -L -s https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 -o "$GOPATH/bin/dep"; \ + echo "40a78c13753f482208d3f4bea51244ca60a914341050c588dad1f00b1acc116c $GOPATH/bin/dep" | sha256sum -c -; \ + chmod +x "${GOPATH}/bin/dep"; + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD [""] diff --git a/go1.16/entrypoint.sh b/go1.16/entrypoint.sh new file mode 100755 index 00000000..21a1426e --- /dev/null +++ b/go1.16/entrypoint.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +set -e + +if [ -z "${IMPORT}" ]; then + IMPORT="${GITHUB_REPOSITORY}" +fi +WORKDIR="${GOPATH}/src/github.com/${IMPORT}" + +# PROJECT_PATH specifies the subdirectory in the working directory that the Go project is +if [ -z "${PROJECT_PATH}" ]; then + PROJECT_PATH="." +fi + +# Go can only find dependencies if they're under $GOPATH/src. +# GitHub Actions mounts your repository outside of $GOPATH. +# So symlink the repository into $GOPATH, and then cd to it. +mkdir -p "$(dirname "${WORKDIR}")" +ln -s "${PWD}" "${WORKDIR}" +cd "${WORKDIR}/${PROJECT_PATH}" + +# If a command was specified with `args="..."`, then run it. Otherwise, +# look for something useful to run. +if [ $# -eq 0 ] || [ "$*" = "" ]; then + if [ -r Makefile ]; then + make + else + if [ -r go.mod ]; then + export GO111MODULE=on + # Check if using vendored dependencies + if [ -d "vendor" ]; then + export GOFLAGS="-mod=vendor" + else + # Ensure no go.mod changes are made that weren't committed + export GOFLAGS="-mod=readonly" + fi + else + if [ -r Gopkg.toml ]; then + # Check if using vendored dependencies + if [ -d "vendor" ]; then + # Check that dep is in sync with /vendor dependencies and that running dep ensure doesn't result in modifications to Gopkg.lock/Gopkg.toml + "$GOPATH/bin/dep" ensure && "$GOPATH/bin/dep" check + git_workspace_status="$(git status --porcelain)" + if [ -n "${git_workspace_status}" ]; then + echo "Unexpected changes were found in dep /vendored. Please run $(dep ensure) and commit changes:"; + echo "${git_workspace_status}"; + exit 1; + fi + else + # Run dep ensure to download and sync dependencies + "$GOPATH/bin/dep" ensure + fi + fi + fi + go build ./... + go test ./... + fi +else + sh -c "$*" +fi From 8e3e881c783123731fa37687864899b95bbb6edf Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Mon, 22 Feb 2021 11:24:23 +0100 Subject: [PATCH 2/4] Add a module file in the go_standard test project This is required for Go 1.16 to pass. Signed-off-by: Cosmin Cojocar --- go1.16/Dockerfile | 2 +- tests/projects/go_standard/go.mod | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/projects/go_standard/go.mod diff --git a/go1.16/Dockerfile b/go1.16/Dockerfile index 72d22799..70eb09bf 100644 --- a/go1.16/Dockerfile +++ b/go1.16/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.16 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="2.0.0" +LABEL version="1.6.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/tests/projects/go_standard/go.mod b/tests/projects/go_standard/go.mod new file mode 100644 index 00000000..4b3addcf --- /dev/null +++ b/tests/projects/go_standard/go.mod @@ -0,0 +1,3 @@ +module github.com/cedrickring/golang-action + +go 1.16 From 793000742c90a003d43cb2d8c1a159e389e1f54c Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Wed, 24 Feb 2021 20:58:58 +0100 Subject: [PATCH 3/4] Update the go version to 1.16 in the default Docker file Signed-off-by: Cosmin Cojocar --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53f2fe78..72d22799 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM golang:1.15 +FROM golang:1.16 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="2.0.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" From 923aa2d887aac8c20df5bd569b7594bdba63a855 Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Fri, 26 Feb 2021 09:33:32 +0100 Subject: [PATCH 4/4] Update version label in all docker file to 1.7.0 Signed-off-by: Cosmin Cojocar --- Dockerfile | 2 +- go1.10/Dockerfile | 2 +- go1.11/Dockerfile | 2 +- go1.12/Dockerfile | 2 +- go1.13/Dockerfile | 2 +- go1.14/Dockerfile | 2 +- go1.15/Dockerfile | 2 +- go1.16/Dockerfile | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72d22799..8bd904f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.16 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="2.0.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.10/Dockerfile b/go1.10/Dockerfile index a92f9287..82d3e3ac 100644 --- a/go1.10/Dockerfile +++ b/go1.10/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.10 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.11/Dockerfile b/go1.11/Dockerfile index 3c8ab564..d2ebeb1e 100644 --- a/go1.11/Dockerfile +++ b/go1.11/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.11 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.12/Dockerfile b/go1.12/Dockerfile index bfc9fa17..e8584310 100644 --- a/go1.12/Dockerfile +++ b/go1.12/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.12 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.13/Dockerfile b/go1.13/Dockerfile index ff693915..94281148 100644 --- a/go1.13/Dockerfile +++ b/go1.13/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.13 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.14/Dockerfile b/go1.14/Dockerfile index 174a61e2..a55cf7fa 100644 --- a/go1.14/Dockerfile +++ b/go1.14/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.14 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.15/Dockerfile b/go1.15/Dockerfile index 53f2fe78..7aefa314 100644 --- a/go1.15/Dockerfile +++ b/go1.15/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.15 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action" diff --git a/go1.16/Dockerfile b/go1.16/Dockerfile index 70eb09bf..8bd904f7 100644 --- a/go1.16/Dockerfile +++ b/go1.16/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.16 LABEL name="Golang Action" LABEL maintainer="Cedric Kring" -LABEL version="1.6.0" +LABEL version="1.7.0" LABEL repository="https://github.com/cedrickring/golang-action" LABEL com.github.actions.name="Golang Action"