Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace deprecated bouk/staticfiles with native Go embed. fixes #11654 #11707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ issues:
- sdks
- ui
- vendor
exclude-files:
- server/static/files.go
31 changes: 10 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,14 @@ endef
cli: dist/argo

ui/dist/app/index.html: $(shell find ui/src -type f && find ui -maxdepth 1 -type f)
ifeq ($(STATIC_FILES),true)
# `yarn install` is fast (~2s), so you can call it safely.
JOBS=max yarn --cwd ui install
# `yarn build` is slow, so we guard it with a up-to-date check.
JOBS=max yarn --cwd ui build

$(GOPATH)/bin/staticfiles:
# update this in Nix when updating it here
ifneq ($(USE_NIX), true)
go install bou.ke/staticfiles@dd04075
endif

ifeq ($(STATIC_FILES),true)
server/static/files.go: $(GOPATH)/bin/staticfiles ui/dist/app/index.html
# Pack UI into a Go file
$(GOPATH)/bin/staticfiles -o server/static/files.go ui/dist/app
else
server/static/files.go:
# Building without static files
cp ./server/static/files.go.stub ./server/static/files.go
@mkdir -p ui/dist/app
touch ui/dist/app/index.html
endif

dist/argo-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
Expand All @@ -194,16 +183,16 @@ dist/argo-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64
dist/argo-windows-%.gz: dist/argo-windows-%
gzip --force --keep dist/argo-windows-$*.exe

dist/argo-windows-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-windows-%: ui/dist/app/index.html $(CLI_PKGS) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@.exe ./cmd/argo

dist/argo-%.gz: dist/argo-%
gzip --force --keep dist/argo-$*

dist/argo-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-%: ui/dist/app/index.html $(CLI_PKGS) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argo

dist/argo: server/static/files.go $(CLI_PKGS) go.sum
dist/argo: ui/dist/app/index.html $(CLI_PKGS) go.sum
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS}' -o $@ ./cmd/argo
Expand Down Expand Up @@ -448,7 +437,7 @@ $(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.55.1

.PHONY: lint
lint: server/static/files.go $(GOPATH)/bin/golangci-lint
lint: ui/dist/app/index.html $(GOPATH)/bin/golangci-lint
rm -Rf v3 vendor
# If you're using `woc.wf.Spec` or `woc.execWf.Status` your code probably won't work with WorkflowTemplate.
# * Change `woc.wf.Spec` to `woc.execWf.Spec`.
Expand All @@ -465,7 +454,7 @@ lint: server/static/files.go $(GOPATH)/bin/golangci-lint

# for local we have a faster target that prints to stdout, does not use json, and can cache because it has no coverage
.PHONY: test
test: server/static/files.go
test: ui/dist/app/index.html
go build ./...
env KUBECONFIG=/dev/null $(GOTEST) ./...
# marker file, based on it's modification time, we know how long ago this target was run
Expand Down Expand Up @@ -670,11 +659,11 @@ go-diagrams/diagram.dot: ./hack/docs/diagram.go
docs/assets/diagram.png: go-diagrams/diagram.dot
cd go-diagrams && dot -Tpng diagram.dot -o ../docs/assets/diagram.png

docs/fields.md: api/openapi-spec/swagger.json $(shell find examples -type f) hack/docs/fields.go
docs/fields.md: api/openapi-spec/swagger.json $(shell find examples -type f) ui/dist/app/index.html hack/docs/fields.go
env ARGO_SECURE=false ARGO_INSECURE_SKIP_VERIFY=false ARGO_SERVER= ARGO_INSTANCEID= go run ./hack/docs fields

# generates several other files
docs/cli/argo.md: $(CLI_PKGS) go.sum server/static/files.go hack/docs/cli.go
docs/cli/argo.md: $(CLI_PKGS) go.sum ui/dist/app/index.html hack/docs/cli.go
go run ./hack/docs cli

# docs
Expand Down
1 change: 0 additions & 1 deletion dev/nix/conf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Even then the buildFlags are not passed into Go, meaning you won't see the correct version info yet.
# This is only intended for quick developing at the moment, gradually more functionality will be pushed here.
rec {
staticFiles = false; # not acted upon
version = "latest";
env = {
DEFAULT_REQUEUE_TIME = "1s";
Expand Down
Loading
Loading