From 5a1bbf77d7361b0b0d1af6eb016df6e1a0019535 Mon Sep 17 00:00:00 2001 From: Debasish Biswas Date: Wed, 18 Dec 2024 14:46:57 +0530 Subject: [PATCH 1/2] fix: Move the go mod tidy after cd to modrootfeat: Check if go.mod file exiest in modroot dir to ensure modroot is set correctly Previously if in a go/build pipeline we set both modroot and tidy=true, go mod tidy command was running in the home dir instead of running into the modroot dir Checking the go.mod exist inside modroot make sure we set the modroot correctly, thish will help with the go/bump automation Signed-off-by: Debasish Biswas --- pkg/build/pipelines/go/build.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/build/pipelines/go/build.yaml b/pkg/build/pipelines/go/build.yaml index 9f8bcf471..2ab5ee702 100644 --- a/pkg/build/pipelines/go/build.yaml +++ b/pkg/build/pipelines/go/build.yaml @@ -98,8 +98,16 @@ inputs: pipeline: - runs: | + cd "${{inputs.modroot}}" + + // check if modroot is set correctly by checking go.mod file exist + if [ ! -e go.mod ]; then + echo "go.mod not found in ${{inputs.modroot}}" + exit 1 + fi + "${{inputs.tidy}}" && go mod tidy - + LDFLAGS="${{inputs.strip}} ${{inputs.ldflags}}" BASE_PATH="${{inputs.prefix}}/${{inputs.install-dir}}/${{inputs.output}}" @@ -107,8 +115,6 @@ pipeline: # Take advantage of melange's buid cache for downloaded modules export GOMODCACHE=/var/cache/melange/gomodcache - cd "${{inputs.modroot}}" - # Install any specified dependencies if [ ! "${{inputs.deps}}" == "" ]; then for dep in ${{inputs.deps}}; do From cb6b1430bed4b5fb253e44be192b6312558c40a6 Mon Sep 17 00:00:00 2001 From: Debasish Biswas Date: Wed, 18 Dec 2024 15:06:55 +0530 Subject: [PATCH 2/2] Fix(piepline): use correct comment systax Signed-off-by: Debasish Biswas --- pkg/build/pipelines/go/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/build/pipelines/go/build.yaml b/pkg/build/pipelines/go/build.yaml index 2ab5ee702..f02542087 100644 --- a/pkg/build/pipelines/go/build.yaml +++ b/pkg/build/pipelines/go/build.yaml @@ -100,7 +100,7 @@ pipeline: - runs: | cd "${{inputs.modroot}}" - // check if modroot is set correctly by checking go.mod file exist + # check if modroot is set correctly by checking go.mod file exist if [ ! -e go.mod ]; then echo "go.mod not found in ${{inputs.modroot}}" exit 1