From 87596c6f8efe03729843af3e59a2861dd9d0de0e Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Tue, 27 Jul 2021 16:05:35 -0600 Subject: [PATCH] build: detect git version instead of setting to 0 The build version should be detected with the git describe command, but if the VERSION var is already set, it will be used instead of being detected from git. During the official builds or even local builds, we just want to let the makefile detect the git version. The full git history is added to enable proper detection of the version. Without the full history only a hash is returned for the version, which then results in an invalid semantic version error for the helm chart. Signed-off-by: Travis Nielsen --- .github/workflows/build.yml | 7 +++++-- .../canary-integration-test-arm64.yml | 2 ++ .github/workflows/canary-integration-test.yml | 20 +++++++++++++++++++ .github/workflows/codegen.yml | 2 ++ .github/workflows/codespell.yaml | 2 ++ .github/workflows/crds-gen.yml | 2 ++ .github/workflows/golangci-lint.yaml | 2 ++ .../integration-test-cassandra-suite.yaml | 5 +++-- .../integration-test-flex-suite.yaml | 2 ++ .../integration-test-helm-suite.yaml | 2 ++ .../workflows/integration-test-mgr-suite.yaml | 2 ++ .../integration-test-multi-cluster-suite.yaml | 2 ++ .../workflows/integration-test-nfs-suite.yaml | 5 +++-- .../integration-test-smoke-suite.yaml | 2 ++ .../integration-test-upgrade-suite.yaml | 2 ++ .../integration-tests-on-release.yaml | 20 +++++++++++++++---- .github/workflows/mod-check.yml | 2 ++ .github/workflows/unit-test.yml | 2 ++ .github/workflows/yaml-lint.yaml | 2 ++ tests/scripts/build-release.sh | 3 +-- tests/scripts/github-action-helper.sh | 3 +-- 21 files changed, 77 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6000547bc..365a88b67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: @@ -24,8 +26,7 @@ jobs: - name: build rook working-directory: /Users/runner/go/src/github.com/rook/rook run: | - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='ceph' VERSION=0 BUILD_CONTAINER_IMAGE=false build + GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='ceph' BUILD_CONTAINER_IMAGE=false build - name: run codegen working-directory: /Users/runner/go/src/github.com/rook/rook @@ -59,6 +60,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/canary-integration-test-arm64.yml b/.github/workflows/canary-integration-test-arm64.yml index 4d0dcd674..d9c79c6cc 100644 --- a/.github/workflows/canary-integration-test-arm64.yml +++ b/.github/workflows/canary-integration-test-arm64.yml @@ -18,6 +18,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/canary-integration-test.yml b/.github/workflows/canary-integration-test.yml index 41d9804c8..a884c50a9 100644 --- a/.github/workflows/canary-integration-test.yml +++ b/.github/workflows/canary-integration-test.yml @@ -23,6 +23,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -100,6 +102,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -178,6 +182,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -243,6 +249,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -312,6 +320,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -380,6 +390,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -448,6 +460,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -518,6 +532,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -605,6 +621,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -668,6 +686,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 3cd1ea884..81ba0ec66 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -26,6 +26,8 @@ jobs: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: copy working directory to GOPATH run: sudo mkdir -p /home/runner/go/src/github.com && sudo cp -a /home/runner/work/rook /home/runner/go/src/github.com/ diff --git a/.github/workflows/codespell.yaml b/.github/workflows/codespell.yaml index 13d9c315a..509ea592a 100644 --- a/.github/workflows/codespell.yaml +++ b/.github/workflows/codespell.yaml @@ -17,6 +17,8 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: codespell uses: codespell-project/actions-codespell@master with: diff --git a/.github/workflows/crds-gen.yml b/.github/workflows/crds-gen.yml index 199767cb7..ad3bffe4c 100644 --- a/.github/workflows/crds-gen.yml +++ b/.github/workflows/crds-gen.yml @@ -26,6 +26,8 @@ jobs: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: copy working directory to GOPATH run: sudo mkdir -p /home/runner/go/src/github.com && sudo cp -a /home/runner/work/rook /home/runner/go/src/github.com/ diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 2eeab3376..19a423f56 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -20,6 +20,8 @@ jobs: with: go-version: 1.16 - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: diff --git a/.github/workflows/integration-test-cassandra-suite.yaml b/.github/workflows/integration-test-cassandra-suite.yaml index e76e5f23c..956daf6d0 100644 --- a/.github/workflows/integration-test-cassandra-suite.yaml +++ b/.github/workflows/integration-test-cassandra-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -40,8 +42,7 @@ jobs: - name: build rook run: | - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='cassandra' VERSION=0 build + GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='cassandra' build docker images docker tag $(docker images|awk '/build-/ {print $1}') rook/cassandra:master diff --git a/.github/workflows/integration-test-flex-suite.yaml b/.github/workflows/integration-test-flex-suite.yaml index 13b57be54..9e518a5d0 100644 --- a/.github/workflows/integration-test-flex-suite.yaml +++ b/.github/workflows/integration-test-flex-suite.yaml @@ -17,6 +17,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-test-helm-suite.yaml b/.github/workflows/integration-test-helm-suite.yaml index beeb2b313..ea7977601 100644 --- a/.github/workflows/integration-test-helm-suite.yaml +++ b/.github/workflows/integration-test-helm-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-test-mgr-suite.yaml b/.github/workflows/integration-test-mgr-suite.yaml index 58ef88d85..6deb56324 100644 --- a/.github/workflows/integration-test-mgr-suite.yaml +++ b/.github/workflows/integration-test-mgr-suite.yaml @@ -18,6 +18,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-test-multi-cluster-suite.yaml b/.github/workflows/integration-test-multi-cluster-suite.yaml index b51c0fb8a..5040f44ca 100644 --- a/.github/workflows/integration-test-multi-cluster-suite.yaml +++ b/.github/workflows/integration-test-multi-cluster-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-test-nfs-suite.yaml b/.github/workflows/integration-test-nfs-suite.yaml index 70ef77ecf..3394cb8d7 100644 --- a/.github/workflows/integration-test-nfs-suite.yaml +++ b/.github/workflows/integration-test-nfs-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -40,8 +42,7 @@ jobs: - name: build rook run: | - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='nfs' VERSION=0 build + GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='nfs' build docker images docker tag $(docker images|awk '/build-/ {print $1}') rook/nfs:master diff --git a/.github/workflows/integration-test-smoke-suite.yaml b/.github/workflows/integration-test-smoke-suite.yaml index 2c33f38dd..e57dcfb88 100644 --- a/.github/workflows/integration-test-smoke-suite.yaml +++ b/.github/workflows/integration-test-smoke-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-test-upgrade-suite.yaml b/.github/workflows/integration-test-upgrade-suite.yaml index e35657184..3aec1367e 100644 --- a/.github/workflows/integration-test-upgrade-suite.yaml +++ b/.github/workflows/integration-test-upgrade-suite.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 diff --git a/.github/workflows/integration-tests-on-release.yaml b/.github/workflows/integration-tests-on-release.yaml index 7646cc047..9e4220fd8 100644 --- a/.github/workflows/integration-tests-on-release.yaml +++ b/.github/workflows/integration-tests-on-release.yaml @@ -22,6 +22,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -71,6 +73,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -125,6 +129,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -175,6 +181,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -224,6 +232,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -273,6 +283,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -292,8 +304,7 @@ jobs: - name: build rook run: | - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='cassandra' VERSION=0 build + GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='cassandra' build docker images docker tag $(docker images|awk '/build-/ {print $1}') rook/cassandra:master @@ -323,6 +334,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: setup golang uses: actions/setup-go@v2 @@ -342,8 +355,7 @@ jobs: - name: build rook run: | - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='nfs' VERSION=0 build + GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='nfs' build docker images docker tag $(docker images|awk '/build-/ {print $1}') rook/nfs:master diff --git a/.github/workflows/mod-check.yml b/.github/workflows/mod-check.yml index a31920d23..212a30a42 100644 --- a/.github/workflows/mod-check.yml +++ b/.github/workflows/mod-check.yml @@ -22,6 +22,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a82c6906c..59e1ba87c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -22,6 +22,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: diff --git a/.github/workflows/yaml-lint.yaml b/.github/workflows/yaml-lint.yaml index b7757b438..70a779f19 100644 --- a/.github/workflows/yaml-lint.yaml +++ b/.github/workflows/yaml-lint.yaml @@ -16,6 +16,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 diff --git a/tests/scripts/build-release.sh b/tests/scripts/build-release.sh index 2c63efa44..e8553e8ce 100755 --- a/tests/scripts/build-release.sh +++ b/tests/scripts/build-release.sh @@ -6,8 +6,7 @@ set -ex ############# function build() { - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" - build/run make VERSION=0 build.all + build/run make build.all # quick check that go modules are tidied build/run make mod.check } diff --git a/tests/scripts/github-action-helper.sh b/tests/scripts/github-action-helper.sh index d86996b34..d6f435f3c 100755 --- a/tests/scripts/github-action-helper.sh +++ b/tests/scripts/github-action-helper.sh @@ -94,9 +94,8 @@ function build_rook() { build_type=$1 fi GOPATH=$(go env GOPATH) make clean - # set VERSION to a dummy value since Jenkins normally sets it for us. Do this to make Helm happy and not fail with "Error: Invalid Semantic Version" for _ in $(seq 1 3); do - if ! o=$(make -j"$(nproc)" IMAGES='ceph' VERSION=0 "$build_type"); then + if ! o=$(make -j"$(nproc)" IMAGES='ceph' "$build_type"); then case "$o" in *"$NETWORK_ERROR"*) echo "network failure occurred, retrying..."