Skip to content

Commit

Permalink
chore: avoid apparent race condition in Make task execution (#23)
Browse files Browse the repository at this point in the history
This is a weird one...somehow, switching to running Go commands in a
container (#14), combined with the passage of time (worked fine for me
last week, consistently doesn't this week) has broken the `make
generate-all` task (and the underlying `make -f Makefile.metalv1
generate` task). But only when I'm running locally.

In CI, `make generate-all` runs just fine (as it used to do for me
locally). Today, locally, it fails every time. After digging through
loads of console output I found this message about halfway through:

```
docker  run --rm -u 502:20 -v /Users/ctreatman/Documents/code/equinix-sdk-go:/workdir -w /workdir -e GOCACHE=/tmp/.cache golang:1.19 go mod tidy
go: warning: "all" matched no packages
```

As a result of this failed execution, the `go.mod` and `go.sum` don't
declare any dependencies, which eventually causes the Go tests to fail.
  • Loading branch information
cprivitere authored Jan 19, 2024
2 parents e1b272c + 9bfd6cb commit 9e6dfd4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ generate-all:
done

mod:
rm -f go.mod go.sum ${PACKAGE_PREFIX}/${PACKAGE_MAJOR}/go.mod ${PACKAGE_PREFIX}/${PACKAGE_MAJOR}/go.sum
for goModOrSum in $(shell set -x; find . -not \( -path ./examples -prune \) -name go.mod -o -name go.sum | sort -n); do \
rm -f $$goModOrSum;\
done
${GO_CMD} go mod init github.com/${GIT_ORG}/${GIT_REPO}
${GO_CMD} go mod tidy

Expand Down
6 changes: 2 additions & 4 deletions Makefile.metalv1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SPEC_PATCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.patched

all: pull fetch patch generate stage

generate: clean codegen remove-unused mod patch-post fmt test
generate: clean codegen remove-unused patch-post fmt mod test

pull:
${CRI} pull ${OPENAPI_IMAGE}
Expand Down Expand Up @@ -60,6 +60,4 @@ remove-unused:
rm -rf ${CODE_DIR}/api \
${CODE_DIR}/.travis.yml \
${CODE_DIR}/git_push.sh \
${CODE_DIR}/.openapi-generator \
${CODE_DIR}/go.mod \
${CODE_DIR}/go.sum
${CODE_DIR}/.openapi-generator
6 changes: 2 additions & 4 deletions templates/Makefile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SPEC_PATCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.patched

all: pull fetch patch generate stage

generate: clean codegen remove-unused mod patch-post fmt test
generate: clean codegen remove-unused patch-post mod fmt test

pull:
${CRI} pull ${OPENAPI_IMAGE}
Expand Down Expand Up @@ -60,6 +60,4 @@ remove-unused:
rm -rf ${CODE_DIR}/api \
${CODE_DIR}/.travis.yml \
${CODE_DIR}/git_push.sh \
${CODE_DIR}/.openapi-generator \
${CODE_DIR}/go.mod \
${CODE_DIR}/go.sum
${CODE_DIR}/.openapi-generator

0 comments on commit 9e6dfd4

Please sign in to comment.