From 0ccb22a3f385e9fb66fc8d709aa60b6d23a0e08e Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Thu, 2 Jan 2025 20:25:27 +0000 Subject: [PATCH 1/3] use a timestamp to determine whether `pnpm i` needs to run --- Makefile | 40 ++++++++++++++++++++++------------------ scripts/pnpm_install.sh | 3 +++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e7f29a738b70d..d4e66fe4fc938 100644 --- a/Makefile +++ b/Makefile @@ -387,14 +387,24 @@ $(foreach chart,$(charts),build/$(chart)_helm_$(VERSION).tgz): build/%_helm_$(VE --chart $* \ --output "$@" -site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \)) +node_modules/.installed: package.json + ./scripts/pnpm_install.sh + +offlinedocs/node_modules/.installed: offlinedocs/package.json + cd offlinedocs + ../scripts/pnpm_install.sh + +site/node_modules/.installed: site/package.json + cd site + ../scripts/pnpm_install.sh + +site/out/index.html: site/package.json site/node_modules/.installed $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \)) cd site # prevents this directory from getting to big, and causing "too much data" errors rm -rf out/assets/ - ../scripts/pnpm_install.sh pnpm build -offlinedocs/out/index.html: $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g') +offlinedocs/out/index.html: offlinedocs/node_modules/.installed $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g') cd offlinedocs ../scripts/pnpm_install.sh pnpm export @@ -425,7 +435,7 @@ fmt/go: go run mvdan.cc/gofumpt@v0.4.0 -w -l . .PHONY: fmt/go -fmt/ts: +fmt/ts: site/node_modules/.installed echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET)" cd site # Avoid writing files in CI to reduce file write activity @@ -468,7 +478,7 @@ lint/site-icons: ./scripts/check_site_icons.sh .PHONY: lint/site-icons -lint/ts: +lint/ts: site/node_modules/.installed cd site pnpm lint .PHONY: lint/ts @@ -643,14 +653,12 @@ site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./ # -C sets the directory for the go run command go run -C ./scripts/apitypings main.go > $@ -site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go +site/e2e/provisionerGenerated.ts: site/node_modules/.installed provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go cd site - ../scripts/pnpm_install.sh pnpm run gen:provisioner -site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*) +site/src/theme/icons.json: site/node_modules/.installed $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*) go run ./scripts/gensite/ -icons "$@" - ./scripts/pnpm_install.sh pnpm -C site/ exec biome format --write src/theme/icons.json examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates) @@ -674,24 +682,20 @@ site/src/api/rbacresourcesGenerated.ts: scripts/typegen/codersdk.gotmpl scripts/ site/src/api/countriesGenerated.ts: scripts/typegen/countries.tstmpl scripts/typegen/main.go codersdk/countries.go go run scripts/typegen/main.go countries > "$@" -docs/admin/integrations/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics +docs/admin/integrations/prometheus.md: node_modules/.installed scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics go run scripts/metricsdocgen/main.go - ./scripts/pnpm_install.sh pnpm exec prettier --write ./docs/admin/integrations/prometheus.md -docs/reference/cli/index.md: scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES) +docs/reference/cli/index.md: node_modules/.installed scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES) CI=true BASE_PATH="." go run ./scripts/clidocgen - ./scripts/pnpm_install.sh pnpm exec prettier --write ./docs/reference/cli/index.md ./docs/reference/cli/*.md ./docs/manifest.json -docs/admin/security/audit-logs.md: coderd/database/querier.go scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go +docs/admin/security/audit-logs.md: node_modules/.installed coderd/database/querier.go scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go go run scripts/auditdocgen/main.go - ./scripts/pnpm_install.sh pnpm exec prettier --write ./docs/admin/security/audit-logs.md -coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go +coderd/apidoc/swagger.json: node_modules/.installed $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go ./scripts/apidocgen/generate.sh - ./scripts/pnpm_install.sh pnpm exec prettier --write ./docs/reference/api ./docs/manifest.json ./coderd/apidoc/swagger.json update-golden-files: \ @@ -874,5 +878,5 @@ test-clean: .PHONY: test-clean .PHONY: test-e2e -test-e2e: +test-e2e: site/node_modules/.installed cd ./site && DEBUG=pw:api pnpm playwright:test --forbid-only --workers 1 diff --git a/scripts/pnpm_install.sh b/scripts/pnpm_install.sh index 0316c8cd8359c..b5a05bfc83e75 100755 --- a/scripts/pnpm_install.sh +++ b/scripts/pnpm_install.sh @@ -33,3 +33,6 @@ pnpm_flags+=("$@") echo "+ pnpm install ${pnpm_flags[*]}" pnpm install "${pnpm_flags[@]}" + +# Used for Makefile optimizations +touch node_modules/.installed From df31ef40cdae0680647ac9f7586cd5a3f59cb3c6 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Thu, 2 Jan 2025 20:43:15 +0000 Subject: [PATCH 2/3] :) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d4e66fe4fc938..f5b990fa15cca 100644 --- a/Makefile +++ b/Makefile @@ -398,7 +398,7 @@ site/node_modules/.installed: site/package.json cd site ../scripts/pnpm_install.sh -site/out/index.html: site/package.json site/node_modules/.installed $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \)) +site/out/index.html: site/node_modules/.installed $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \)) cd site # prevents this directory from getting to big, and causing "too much data" errors rm -rf out/assets/ From 5e0b0c5b0b56c14ad566a93d5ae2f763726baa46 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 3 Jan 2025 18:24:46 +0500 Subject: [PATCH 3/3] update for docs linting changes --- Makefile | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index e9e97cd5650e2..e8ea137460d65 100644 --- a/Makefile +++ b/Makefile @@ -448,7 +448,7 @@ else endif .PHONY: fmt/ts -fmt/biome: +fmt/biome: site/node_modules/.installed echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET)" cd site # Avoid writing files in CI to reduce file write activity @@ -474,9 +474,8 @@ else endif .PHONY: fmt/shfmt -fmt/markdown: +fmt/markdown: node_modules/.installed echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET)" - ./scripts/pnpm_install.sh pnpm format-docs .PHONY: fmt/markdown @@ -514,8 +513,7 @@ lint/helm: make lint .PHONY: lint/helm -lint/markdown: - ./scripts/pnpm_install.sh +lint/markdown: node_modules/.installed pnpm lint-docs .PHONY: lint/markdown @@ -663,11 +661,10 @@ vpn/vpn.pb.go: vpn/vpn.proto --go_opt=paths=source_relative \ ./vpn/vpn.proto -site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go') +site/src/api/typesGenerated.ts: site/node_modules/.installed $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go') # -C sets the directory for the go run command go run -C ./scripts/apitypings main.go > $@ cd site - ../scripts/pnpm_install.sh pnpm exec biome format --write src/api/typesGenerated.ts site/e2e/provisionerGenerated.ts: site/node_modules/.installed provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go @@ -676,7 +673,8 @@ site/e2e/provisionerGenerated.ts: site/node_modules/.installed provisionerd/prot site/src/theme/icons.json: site/node_modules/.installed $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*) go run ./scripts/gensite/ -icons "$@" - pnpm -C site/ exec biome format --write src/theme/icons.json + cd site + pnpm exec biome format --write src/theme/icons.json examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates) go run ./scripts/examplegen/main.go > examples/examples.gen.json @@ -693,16 +691,14 @@ codersdk/rbacresources_gen.go: scripts/typegen/codersdk.gotmpl scripts/typegen/m go run scripts/typegen/main.go rbac codersdk > /tmp/rbacresources_gen.go mv /tmp/rbacresources_gen.go codersdk/rbacresources_gen.go -site/src/api/rbacresourcesGenerated.ts: scripts/typegen/codersdk.gotmpl scripts/typegen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go +site/src/api/rbacresourcesGenerated.ts: site/node_modules/.installed scripts/typegen/codersdk.gotmpl scripts/typegen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go go run scripts/typegen/main.go rbac typescript > "$@" cd site - ../scripts/pnpm_install.sh pnpm exec biome format --write src/api/rbacresourcesGenerated.ts -site/src/api/countriesGenerated.ts: scripts/typegen/countries.tstmpl scripts/typegen/main.go codersdk/countries.go +site/src/api/countriesGenerated.ts: site/node_modules/.installed scripts/typegen/countries.tstmpl scripts/typegen/main.go codersdk/countries.go go run scripts/typegen/main.go countries > "$@" cd site - ../scripts/pnpm_install.sh pnpm exec biome format --write src/api/countriesGenerated.ts docs/admin/integrations/prometheus.md: node_modules/.installed scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics @@ -710,7 +706,7 @@ docs/admin/integrations/prometheus.md: node_modules/.installed scripts/metricsdo pnpm exec markdownlint-cli2 --fix ./docs/admin/integrations/prometheus.md pnpm exec markdown-table-formatter ./docs/admin/integrations/prometheus.md -docs/reference/cli/index.md: node_modules/.installed scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES) +docs/reference/cli/index.md: node_modules/.installed site/node_modules/.installed scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES) CI=true BASE_PATH="." go run ./scripts/clidocgen pnpm exec markdownlint-cli2 --fix ./docs/reference/cli/*.md pnpm exec markdown-table-formatter ./docs/reference/cli/*.md @@ -722,7 +718,7 @@ docs/admin/security/audit-logs.md: node_modules/.installed coderd/database/queri pnpm exec markdownlint-cli2 --fix ./docs/admin/security/audit-logs.md pnpm exec markdown-table-formatter ./docs/admin/security/audit-logs.md -coderd/apidoc/swagger.json: node_modules/.installed $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go +coderd/apidoc/swagger.json: node_modules/.installed site/node_modules/.installed $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go ./scripts/apidocgen/generate.sh pnpm exec markdownlint-cli2 --fix ./docs/reference/api/*.md pnpm exec markdown-table-formatter ./docs/reference/api/*.md