GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — coder/Makefile at main · coder/coder Expand file tree/ Copy pathMakefileMore file actions 1938 lines (1682 loc) · 74 KB / Copy pathMakefileFile metadata and controls1938 lines (1682 loc) · 74 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 # This is the Coder Makefile. The build directory for most tasks is `build/`. # # These are the targets you're probably looking for: # - clean # - build-fat: builds all "fat" binaries for all architectures # - build-slim: builds all "slim" binaries (no frontend or slim binaries # embedded) for all architectures # - release: simulate a release (mostly, does not push images) # - build/coder(-slim)?_${os}_${arch}(.exe)?: build a single fat binary # - build/coder_${os}_${arch}.(zip|tar.gz): build a release archive # - build/coder_linux_${arch}.(apk|deb|rpm): build a release Linux package # - build/coder_${version}_linux_${arch}.tag: build a release Linux Docker image # - build/coder_helm.tgz: build a release Helm chart .DEFAULT_GOAL := build-fat # Use a single bash shell for each job, and immediately exit on failure SHELL := bash .SHELLFLAGS := -ceu .ONESHELL: # When MAKE_TIMED=1, replace SHELL with a wrapper that prints # elapsed wall-clock time for each recipe. pre-commit and pre-push # set this on their sub-makes so every parallel job reports its # duration. Ad-hoc usage: make MAKE_TIMED=1 test # The target name is prefixed with "target:" because GNU make 4.4 with # .ONESHELL mangles the arguments when the first word of .SHELLFLAGS is # a shell builtin such as test, exec, or cd. SHELL then receives # "/bin/sh -c '<target> -ceu' <recipe>", which skips the recipe for the # test target or crashes make. ifdef MAKE_TIMED SHELL := $(CURDIR)/scripts/lib/timed-shell.sh .SHELLFLAGS = target:$@ -ceu export MAKE_TIMED export MAKE_LOGDIR endif # This doesn't work on directories. # See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets .DELETE_ON_ERROR: # Protect git-tracked generated files from deletion on interrupt. # .DELETE_ON_ERROR is desirable for most targets but for files that # are committed to git and serve as inputs to other rules, deletion # is worse than a stale file — `git restore` is the recovery path. .PRECIOUS: \ coderd/database/dump.sql \ coderd/database/querier.go \ coderd/database/unique_constraint.go \ coderd/database/dbmetrics/querymetrics.go \ coderd/database/dbauthz/dbauthz.go \ coderd/database/dbmock/dbmock.go \ coderd/database/pubsub/psmock/psmock.go \ agent/agentcontainers/acmock/acmock.go \ coderd/httpmw/loggermw/loggermock/loggermock.go \ codersdk/workspacesdk/agentconnmock/agentconnmock.go \ tailnet/tailnettest/coordinatormock.go \ tailnet/tailnettest/coordinateemock.go \ tailnet/tailnettest/workspaceupdatesprovidermock.go \ tailnet/tailnettest/subscriptionmock.go \ coderd/aibridged/aibridgedmock/clientmock.go \ coderd/aibridged/aibridgedmock/poolmock.go \ tailnet/proto/tailnet.pb.go \ agent/proto/agent.pb.go \ agent/agentsocket/proto/agentsocket.pb.go \ agent/boundarylogproxy/codec/boundary.pb.go \ provisionersdk/proto/provisioner.pb.go \ provisionerd/proto/provisionerd.pb.go \ vpn/vpn.pb.go \ coderd/aibridged/proto/aibridged.pb.go \ site/src/api/typesGenerated.ts \ site/e2e/provisionerGenerated.ts \ site/src/api/chatModelOptionsGenerated.json \ site/src/api/appFamiliesGenerated.ts \ site/src/api/rbacresourcesGenerated.ts \ site/src/api/countriesGenerated.ts \ site/src/theme/icons.json \ examples/examples.gen.json \ docs/manifest.json \ docs/manifest/generated/cli.json \ docs/manifest/generated/rest-api.json \ docs/admin/integrations/prometheus.md \ docs/admin/security/audit-logs.md \ docs/admin/setup/configuration-reference.md \ docs/reference/api-key-scopes.md \ docs/reference/cli/index.md \ coderd/apidoc/swagger.json \ coderd/rbac/object_gen.go \ coderd/rbac/scopes_constants_gen.go \ codersdk/rbacresources_gen.go \ codersdk/apikey_scopes_gen.go \ codersdk/dbenums_gen.go # atomic_write runs a command, captures stdout into a temp file, and # atomically replaces $@. An optional second argument is a formatting # command that receives the temp file path as its argument. # Usage: $(call atomic_write,GENERATE_CMD[,FORMAT_CMD]) define atomic_write tmpdir=$$(mktemp -d -p _gen) && tmpfile=$$(realpath "$$tmpdir")/$(notdir $@) && \ $(1) > "$$tmpfile" && \ $(if $(2),$(2) "$$tmpfile" &&) \ mv "$$tmpfile" "$@" && rm -rf "$$tmpdir" endef # CLI doc generation reflects over the assembled CLI tree. Track command # definitions plus the top-level SDK types they expose in help text and flag # values, without pulling in unrelated generated sources. CLIDOC_SRC_FILES := \ $(shell find ./cli ./enterprise/cli -type f -name '*.go' -not -name '*_test.go') \ $(wildcard codersdk/*.go) \ $(wildcard buildinfo/*.go) CLIDOCGEN_INPUTS := \ $(wildcard scripts/clidocgen/*.go) \ $(filter-out %_test.go,$(wildcard scripts/docgenenv/*.go)) \ scripts/clidocgen/command.tpl \ $(CLIDOC_SRC_FILES) # Hand-edited YAML sidebar sources that docsmanifestgen compiles, together # with the generated fragments under docs/manifest/generated, into # docs/manifest.json. Each file holds one route and one level of children, so # the sources nest in subdirectories. DOCS_MANIFEST_SOURCES := $(shell find docs/manifest -type f -name '*.yml' -not -path 'docs/manifest/generated/*') DOCSMANIFESTGEN_INPUTS := \ $(filter-out %_test.go,$(wildcard scripts/docsmanifestgen/*.go)) \ $(filter-out %_test.go,$(wildcard scripts/docgenenv/*.go)) # Helper binaries that import repo packages need their compile-time inputs on # the binary target. Most generated outputs keep these binaries as order-only # prereqs, so stale binaries otherwise survive source changes. RBAC_GO_FILES := \ $(wildcard coderd/rbac/*.go) \ $(wildcard coderd/rbac/policy/*.go) DBDUMP_INPUTS := \ $(wildcard coderd/database/migrations/*.go) \ $(wildcard coderd/database/migrations/*.sql) # Exclude generated RBAC files to avoid cycles with typegen outputs. The # output rules still order generated RBAC prerequisites where needed. TYPEGEN_RBAC_GO_FILES := \ $(filter-out coderd/rbac/%_gen.go,$(wildcard coderd/rbac/*.go)) \ $(wildcard coderd/rbac/policy/*.go) TYPEGEN_INPUTS := \ $(wildcard scripts/typegen/*.go) \ $(wildcard scripts/typegen/*.gotmpl) \ $(wildcard scripts/typegen/*.tstmpl) \ $(TYPEGEN_RBAC_GO_FILES) \ $(wildcard coderd/util/strings/*.go) \ codersdk/countries.go # Helper binary targets. Built with go build -o to avoid caching # link-stage executables in GOCACHE. Each binary is a real Make # target so parallel -j builds serialize correctly instead of # racing on the same output path. _gen/bin/apitypings: $(wildcard scripts/apitypings/*.go) $(wildcard codersdk/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/apitypings _gen/bin/auditdocgen: $(wildcard scripts/auditdocgen/*.go) $(wildcard enterprise/audit/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/auditdocgen _gen/bin/check-scopes: $(wildcard scripts/check-scopes/*.go) $(RBAC_GO_FILES) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/check-scopes # clidocgen reflects over the full CLI tree, so it must rebuild when its # command definitions, flag types, or embedded template change. _gen/bin/clidocgen: $(CLIDOCGEN_INPUTS) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/clidocgen _gen/bin/docsmanifestgen: $(DOCSMANIFESTGEN_INPUTS) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/docsmanifestgen # configdocgen reflects over codersdk.DeploymentValues to produce the # configuration reference page. _gen/bin/configdocgen: $(wildcard scripts/configdocgen/*.go) $(wildcard codersdk/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/configdocgen _gen/bin/dbdump: $(wildcard coderd/database/gen/dump/*.go) $(DBDUMP_INPUTS) | _gen @mkdir -p _gen/bin go build -o $@ ./coderd/database/gen/dump _gen/bin/examplegen: $(wildcard scripts/examplegen/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/examplegen _gen/bin/gensite: $(wildcard scripts/gensite/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/gensite _gen/bin/apikeyscopesgen: $(wildcard scripts/apikeyscopesgen/*.go) $(RBAC_GO_FILES) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/apikeyscopesgen # scopesdocgen reads the RBAC scope catalog to produce the API key scopes # reference page. _gen/bin/scopesdocgen: $(wildcard scripts/scopesdocgen/*.go) $(wildcard scripts/docgenenv/*.go) $(RBAC_GO_FILES) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/scopesdocgen _gen/bin/aibridgepricesgen: $(wildcard scripts/aibridgepricesgen/*.go) scripts/aibridgepricesgen/curation.json | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/aibridgepricesgen _gen/bin/metricsdocgen: $(wildcard scripts/metricsdocgen/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/metricsdocgen _gen/bin/metricsdocgen-scanner: $(wildcard scripts/metricsdocgen/scanner/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/metricsdocgen/scanner _gen/bin/modeloptionsgen: $(wildcard scripts/modeloptionsgen/*.go) $(wildcard codersdk/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/modeloptionsgen _gen/bin/typegen: $(TYPEGEN_INPUTS) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/typegen # Shared temp directory for atomic writes. Lives at the project root # so all targets share the same filesystem, and is gitignored. # Order-only prerequisite: recipes that need it depend on | _gen _gen: mkdir -p _gen # Don't print the commands in the file unless you specify VERBOSE. This is # essentially the same as putting "@" at the start of each line. ifndef VERBOSE .SILENT: endif # Create the output directories if they do not exist. $(shell mkdir -p build site/out/bin) GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,) VERSION := $(shell ./scripts/version.sh) POSTGRES_VERSION ?= 17 POSTGRES_IMAGE ?= us-docker.pkg.dev/coder-v2-images-public/public/postgres:$(POSTGRES_VERSION) # CI test jobs set this to "none": nothing reads the statement log there. TEST_POSTGRES_LOG_STATEMENT ?= all # Limit parallel Make jobs in pre-commit/pre-push. Defaults to # nproc/4 (min 2) since test, lint, and build targets have internal # parallelism. Override: make pre-push PARALLEL_JOBS=8 PARALLEL_JOBS ?= $(shell n=$$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 8); echo $$(( n / 4 > 2 ? n / 4 : 2 ))) # Use the highest ZSTD compression level in release builds to # minimize artifact size. For non-release CI builds (e.g. main # branch preview), use multithreaded level 6 which is ~99% faster # at the cost of ~30% larger archives. ifeq ($(CODER_RELEASE),true) ZSTDFLAGS := -22 --ultra else ZSTDFLAGS := -6 -T0 endif # Common paths to exclude from find commands, this rule is written so # that it can be it can be used in a chain of AND statements (meaning # you can simply write `find . $(FIND_EXCLUSIONS) -name thing-i-want`). # Note, all find statements should be written with `.` or `./path` as # the search path so that these exclusions match. FIND_EXCLUSIONS= \ -not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' -o -path '*/.terraform/*' -o -path './_gen/*' \) -prune \) # Source files used for make targets, evaluated on use. GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go') # All the shell files in the repo, excluding ignored files. SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh') MIGRATION_FILES := $(shell find ./coderd/database/migrations/ -maxdepth 1 $(FIND_EXCLUSIONS) -type f -name '*.sql') FIXTURE_FILES := $(shell find ./coderd/database/migrations/testdata/fixtures/ $(FIND_EXCLUSIONS) -type f -name '*.sql') # Ensure we don't use the user's git configs which might cause side-effects GIT_FLAGS = GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null # All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix. OS_ARCHES := \ linux_amd64 linux_arm64 linux_armv7 \ darwin_amd64 darwin_arm64 \ windows_amd64.exe windows_arm64.exe # Archive formats and their corresponding ${OS}_${ARCH} combos. ARCHIVE_TAR_GZ := linux_amd64 linux_arm64 linux_armv7 ARCHIVE_ZIP := \ darwin_amd64 darwin_arm64 \ windows_amd64 windows_arm64 # All package formats we build and the ${OS}_${ARCH} combos we build them for. PACKAGE_FORMATS := apk deb rpm PACKAGE_OS_ARCHES := linux_amd64 linux_armv7 linux_arm64 # All architectures we build Docker images for (Linux only). DOCKER_ARCHES := amd64 arm64 armv7 # Computed variables based on the above. CODER_SLIM_BINARIES := $(addprefix build/coder-slim_$(VERSION)_,$(OS_ARCHES)) CODER_FAT_BINARIES := $(addprefix build/coder_$(VERSION)_,$(OS_ARCHES)) CODER_ALL_BINARIES := $(CODER_SLIM_BINARIES) $(CODER_FAT_BINARIES) CODER_TAR_GZ_ARCHIVES := $(foreach os_arch, $(ARCHIVE_TAR_GZ), build/coder_$(VERSION)_$(os_arch).tar.gz) CODER_ZIP_ARCHIVES := $(foreach os_arch, $(ARCHIVE_ZIP), build/coder_$(VERSION)_$(os_arch).zip) CODER_ALL_ARCHIVES := $(CODER_TAR_GZ_ARCHIVES) $(CODER_ZIP_ARCHIVES) CODER_ALL_PACKAGES := $(foreach os_arch, $(PACKAGE_OS_ARCHES), $(addprefix build/coder_$(VERSION)_$(os_arch).,$(PACKAGE_FORMATS))) CODER_ARCH_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_$(VERSION)_linux_$(arch).tag) CODER_ARCH_IMAGES_PUSHED := $(addprefix push/, $(CODER_ARCH_IMAGES)) CODER_MAIN_IMAGE := build/coder_$(VERSION)_linux.tag CODER_SLIM_NOVERSION_BINARIES := $(addprefix build/coder-slim_,$(OS_ARCHES)) CODER_FAT_NOVERSION_BINARIES := $(addprefix build/coder_,$(OS_ARCHES)) CODER_ALL_NOVERSION_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_linux_$(arch).tag) build/coder_linux.tag CODER_ALL_NOVERSION_IMAGES_PUSHED := $(addprefix push/, $(CODER_ALL_NOVERSION_IMAGES)) # If callers are only building Docker images and not the packages and archives, # we can skip those prerequisites as they are not actually required and only # specified to avoid concurrent write failures. ifdef DOCKER_IMAGE_NO_PREREQUISITES CODER_ARCH_IMAGE_PREREQUISITES := else CODER_ARCH_IMAGE_PREREQUISITES := \ build/coder_$(VERSION)_%.apk \ build/coder_$(VERSION)_%.deb \ build/coder_$(VERSION)_%.rpm \ build/coder_$(VERSION)_%.tar.gz endif clean: rm -rf build/ site/build/ site/out/ rm -rf _gen/bin mkdir -p build/ git restore site/out/ .PHONY: clean build-slim: $(CODER_SLIM_BINARIES) .PHONY: build-slim build-fat build-full build: $(CODER_FAT_BINARIES) .PHONY: build-fat build-full build release: $(CODER_FAT_BINARIES) $(CODER_ALL_ARCHIVES) $(CODER_ALL_PACKAGES) $(CODER_ARCH_IMAGES) build/coder_helm_$(VERSION).tgz .PHONY: release build/coder-slim_$(VERSION)_checksums.sha1: site/out/bin/coder.sha1 cp "$<" "$@" site/out/bin/coder.sha1: $(CODER_SLIM_BINARIES) pushd ./site/out/bin openssl dgst -r -sha1 coder-* | tee coder.sha1 popd build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CODER_SLIM_BINARIES) pushd ./site/out/bin # Group binaries by architecture so that zstd's long-distance matching # window can deduplicate code shared across operating systems. tar cf "../../../build/$(@F)" $$(ls coder-* | sort -t- -k3) popd # delete the uncompressed binaries from the embedded dir rm -f site/out/bin/coder-* site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar.zst cp "$<" "$@" build/coder-slim_$(VERSION).tar.zst: build/coder-slim_$(VERSION).tar zstd $(ZSTDFLAGS) \ --force \ --long \ --no-progress \ -o "build/coder-slim_$(VERSION).tar.zst" \ "build/coder-slim_$(VERSION).tar" # Redirect from version-less targets to the versioned ones. There is a similar # target for slim binaries below. # # Called like this: # make build/coder_linux_amd64 # make build/coder_windows_amd64.exe $(CODER_FAT_NOVERSION_BINARIES): build/coder_%: build/coder_$(VERSION)_% rm -f "$@" ln "$<" "$@" # Same as above, but for slim binaries. # # Called like this: # make build/coder-slim_linux_amd64 # make build/coder-slim_windows_amd64.exe $(CODER_SLIM_NOVERSION_BINARIES): build/coder-slim_%: build/coder-slim_$(VERSION)_% rm -f "$@" ln "$<" "$@" # "fat" binaries always depend on the site and the compressed slim binaries. $(CODER_FAT_BINARIES): \ site/out/index.html \ site/out/bin/coder.sha1 \ site/out/bin/coder.tar.zst # This is a handy block that parses the target to determine whether it's "slim" # or "fat", which OS was specified and which architecture was specified. # # It populates the following variables: mode, os, arch_ext, arch, ext (without # dot). define get-mode-os-arch-ext = mode="$$([[ "$@" = build/coder-slim* ]] && echo "slim" || echo "fat")" os="$$(echo $@ | cut -d_ -f3)" arch_ext="$$(echo $@ | cut -d_ -f4)" if [[ "$$arch_ext" == *.* ]]; then arch="$$(echo $$arch_ext | cut -d. -f1)" ext="$${arch_ext#*.}" else arch="$$arch_ext" ext="" fi endef # This task handles all builds, for both "fat" and "slim" binaries. It parses # the target name to get the metadata for the build, so it must be specified in # this format: # build/coder(-slim)?_${version}_${os}_${arch}(.exe)? # # You should probably use the non-version targets above instead if you're # calling this manually. $(CODER_ALL_BINARIES): go.mod go.sum \ $(GO_SRC_FILES) \ $(shell find ./examples/templates) \ site/static/error.html $(get-mode-os-arch-ext) if [[ "$$os" != "windows" ]] && [[ "$$ext" != "" ]]; then echo "ERROR: Invalid build binary extension" 1>&2 exit 1 fi if [[ "$$os" == "windows" ]] && [[ "$$ext" != exe ]]; then echo "ERROR: Windows binaries must have an .exe extension." 1>&2 exit 1 fi build_args=( \ --os "$$os" \ --arch "$$arch" \ --version "$(VERSION)" \ --output "$@" \ ) if [ "$$mode" == "slim" ]; then build_args+=(--slim) fi ./scripts/build_go.sh "$${build_args[@]}" if [[ "$$mode" == "slim" ]]; then dot_ext="" if [[ "$$ext" != "" ]]; then dot_ext=".$$ext" fi cp "$@" "./site/out/bin/coder-$$os-$$arch$$dot_ext" if [[ "$${CODER_SIGN_GPG:-0}" == "1" ]]; then cp "[email protected]" "./site/out/bin/coder-$$os-$$arch$$dot_ext.asc" fi fi # This task builds all archives. It parses the target name to get the metadata # for the build, so it must be specified in this format: # build/coder_${version}_${os}_${arch}.${format} # # The following OS/arch/format combinations are supported: # .tar.gz: linux_amd64, linux_arm64, linux_armv7 # .zip: darwin_amd64, darwin_arm64, windows_amd64, windows_arm64 # # This depends on all fat binaries because it's difficult to do dynamic # dependencies due to the .exe requirement on Windows. These targets are # typically only used during release anyways. $(CODER_ALL_ARCHIVES): $(CODER_FAT_BINARIES) $(get-mode-os-arch-ext) bin_ext="" if [[ "$$os" == "windows" ]]; then bin_ext=".exe" fi ./scripts/archive.sh \ --format "$$ext" \ --os "$$os" \ --output "$@" \ "build/coder_$(VERSION)_$${os}_$${arch}$${bin_ext}" # This task builds all packages. It parses the target name to get the metadata # for the build, so it must be specified in this format: # build/coder_${version}_linux_${arch}.${format} # # Supports apk, deb, rpm for all linux targets. # # This depends on all Linux fat binaries and archives because it's difficult to # do dynamic dependencies due to the extensions in the filenames. These targets # are typically only used during release anyways. # # Packages need to run after the archives are built, otherwise they cause tar # errors like "file changed as we read it". CODER_PACKAGE_DEPS := $(foreach os_arch, $(PACKAGE_OS_ARCHES), build/coder_$(VERSION)_$(os_arch) build/coder_$(VERSION)_$(os_arch).tar.gz) $(CODER_ALL_PACKAGES): $(CODER_PACKAGE_DEPS) $(get-mode-os-arch-ext) ./scripts/package.sh \ --arch "$$arch" \ --format "$$ext" \ --version "$(VERSION)" \ --output "$@" \ "build/coder_$(VERSION)_$${os}_$${arch}" # This task builds a Windows amd64 installer. Depends on makensis. build/coder_$(VERSION)_windows_amd64_installer.exe: build/coder_$(VERSION)_windows_amd64.exe ./scripts/build_windows_installer.sh \ --version "$(VERSION)" \ --output "$@" \ "$<" # Redirect from version-less Docker image targets to the versioned ones. # # Called like this: # make build/coder_linux_amd64.tag $(CODER_ALL_NOVERSION_IMAGES): build/coder_%: build/coder_$(VERSION)_% .PHONY: $(CODER_ALL_NOVERSION_IMAGES) # Redirect from version-less push Docker image targets to the versioned ones. # # Called like this: # make push/build/coder_linux_amd64.tag $(CODER_ALL_NOVERSION_IMAGES_PUSHED): push/build/coder_%: push/build/coder_$(VERSION)_% .PHONY: $(CODER_ALL_NOVERSION_IMAGES_PUSHED) # This task builds all Docker images. It parses the target name to get the # metadata for the build, so it must be specified in this format: # build/coder_${version}_${os}_${arch}.tag # # Supports linux_amd64, linux_arm64, linux_armv7. # # Images need to run after the archives and packages are built, otherwise they # cause errors like "file changed as we read it". $(CODER_ARCH_IMAGES): build/coder_$(VERSION)_%.tag: build/coder_$(VERSION)_% $(CODER_ARCH_IMAGE_PREREQUISITES) $(get-mode-os-arch-ext) image_tag="$$(./scripts/image_tag.sh --arch "$$arch" --version "$(VERSION)")" ./scripts/build_docker.sh \ --arch "$$arch" \ --target "$$image_tag" \ --version "$(VERSION)" \ "build/coder_$(VERSION)_$${os}_$${arch}" echo "$$image_tag" > "$@" # Multi-arch Docker image. This requires all architecture-specific images to be # built AND pushed. $(CODER_MAIN_IMAGE): $(CODER_ARCH_IMAGES_PUSHED) image_tag="$$(./scripts/image_tag.sh --version "$(VERSION)")" ./scripts/build_docker_multiarch.sh \ --target "$$image_tag" \ --version "$(VERSION)" \ $(foreach img, $^, "$$(cat "$(img:push/%=%)")") echo "$$image_tag" > "$@" # Push a Docker image. $(CODER_ARCH_IMAGES_PUSHED): push/%: % image_tag="$$(cat "$<")" docker push "$$image_tag" .PHONY: $(CODER_ARCH_IMAGES_PUSHED) # Push the multi-arch Docker manifest. push/$(CODER_MAIN_IMAGE): $(CODER_MAIN_IMAGE) image_tag="$$(cat "$<")" docker manifest push "$$image_tag" .PHONY: push/$(CODER_MAIN_IMAGE) # Helm charts that are available charts = coder provisioner ai-gateway # Shortcut for Helm chart package. $(foreach chart,$(charts),build/$(chart)_helm.tgz): build/%_helm.tgz: build/%_helm_$(VERSION).tgz rm -f "$@" ln "$<" "$@" # Helm chart package. $(foreach chart,$(charts),build/$(chart)_helm_$(VERSION).tgz): build/%_helm_$(VERSION).tgz: ./scripts/helm.sh \ --version "$(VERSION)" \ --chart $* \ --output "$@" node_modules/.installed: package.json pnpm-lock.yaml pnpm-workspace.yaml ./scripts/pnpm_install.sh touch "$@" offlinedocs/node_modules/.installed: offlinedocs/package.json offlinedocs/pnpm-lock.yaml offlinedocs/pnpm-workspace.yaml (cd offlinedocs/ && ../scripts/pnpm_install.sh) touch "$@" site/node_modules/.installed: site/package.json site/pnpm-lock.yaml site/pnpm-workspace.yaml (cd site/ && ../scripts/pnpm_install.sh) touch "$@" scripts/apidocgen/node_modules/.installed: scripts/apidocgen/package.json scripts/apidocgen/pnpm-lock.yaml scripts/apidocgen/pnpm-workspace.yaml (cd scripts/apidocgen && ../../scripts/pnpm_install.sh) touch "$@" SITE_GEN_FILES := \ site/src/api/typesGenerated.ts \ site/src/api/appFamiliesGenerated.ts \ site/src/api/rbacresourcesGenerated.ts \ site/src/api/countriesGenerated.ts \ site/src/api/chatModelOptionsGenerated.json \ site/src/theme/icons.json site/out/index.html: \ site/node_modules/.installed \ site/static/install.sh \ $(SITE_GEN_FILES) \ $(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/ pnpm build 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 build/coder_docs_$(VERSION).tgz: offlinedocs/out/index.html tar -czf "$@" -C offlinedocs/out . install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT) install_dir="$$(go env GOPATH)/bin" output_file="$${install_dir}/coder$(GOOS_BIN_EXT)" mkdir -p "$$install_dir" cp "$<" "$$output_file" .PHONY: install # Only wildcard the go files in the develop directory to avoid rebuilds # when project files are changd. Technically changes to some imports may # not be detected, but it's unlikely to cause any issues. build/.bin/develop: go.mod go.sum $(wildcard scripts/develop/*.go) CGO_ENABLED=0 go build -o $@ ./scripts/develop BOLD := $(shell tput bold 2>/dev/null) GREEN := $(shell tput setaf 2 2>/dev/null) RED := $(shell tput setaf 1 2>/dev/null) YELLOW := $(shell tput setaf 3 2>/dev/null) DIM := $(shell tput dim 2>/dev/null || tput setaf 8 2>/dev/null) RESET := $(shell tput sgr0 2>/dev/null) fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/biome fmt/markdown fmt/docs-manifest .PHONY: fmt # Subset of fmt that does not require Go or Node toolchains. fmt-light: fmt/shfmt fmt/terraform fmt/markdown .PHONY: fmt-light fmt/go: ifdef FILE # Format single file if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.go ]] && ! grep -q "DO NOT EDIT" "$(FILE)"; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET) $(FILE)"; \ ./scripts/format_go_file.sh "$(FILE)"; \ fi else go mod tidy echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET)" # VS Code users should check out # https://github.com/mvdan/gofumpt#visual-studio-code find . $(FIND_EXCLUSIONS) -type f -name '*.go' -print0 | \ xargs -0 grep -E --null -L '^// Code generated .* DO NOT EDIT\.$$' | \ xargs -0 ./scripts/format_go_file.sh endif .PHONY: fmt/go fmt/ts: site/node_modules/.installed ifdef FILE # Format single TypeScript/JavaScript file if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.ts ]] || [[ "$(FILE)" == *.tsx ]] || [[ "$(FILE)" == *.js ]] || [[ "$(FILE)" == *.jsx ]]; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET) $(FILE)"; \ (cd site/ && pnpm exec biome format --write "../$(FILE)"); \ fi else echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET)" cd site # Avoid writing files in CI to reduce file write activity ifdef CI pnpm run check --linter-enabled=false else pnpm run check:fix endif endif .PHONY: fmt/ts fmt/biome: site/node_modules/.installed ifdef FILE # Format single file with biome if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.ts ]] || [[ "$(FILE)" == *.tsx ]] || [[ "$(FILE)" == *.js ]] || [[ "$(FILE)" == *.jsx ]]; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET) $(FILE)"; \ (cd site/ && pnpm exec biome format --write "../$(FILE)"); \ fi else echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET)" cd site/ # Avoid writing files in CI to reduce file write activity ifdef CI pnpm run format:check else pnpm run format endif endif .PHONY: fmt/biome fmt/terraform: $(wildcard *.tf) ifdef FILE # Format single Terraform file if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.tf ]] || [[ "$(FILE)" == *.tfvars ]]; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/terraform$(RESET) $(FILE)"; \ terraform fmt "$(FILE)"; \ fi else echo "$(GREEN)==>$(RESET) $(BOLD)fmt/terraform$(RESET)" terraform fmt -recursive endif .PHONY: fmt/terraform fmt/shfmt: $(SHELL_SRC_FILES) ifdef FILE # Format single shell script if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.sh ]]; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET) $(FILE)"; \ shfmt -w "$(FILE)"; \ fi else echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)" # Only do diff check in CI, errors on diff. ifdef CI shfmt -d $(SHELL_SRC_FILES) else shfmt -w $(SHELL_SRC_FILES) endif endif .PHONY: fmt/shfmt fmt/markdown: node_modules/.installed ifdef FILE # Format single markdown file if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.md ]]; then \ echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET) $(FILE)"; \ pnpm exec markdown-table-formatter "$(FILE)"; \ fi else echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET)" pnpm format-docs endif .PHONY: fmt/markdown # Formats the YAML sidebar sources under docs/manifest: canonical key order, # two-space indentation, and quoting only where YAML needs it. fmt/docs-manifest: _gen/bin/docsmanifestgen echo "$(GREEN)==>$(RESET) $(BOLD)fmt/docs-manifest$(RESET)" _gen/bin/docsmanifestgen fmt .PHONY: fmt/docs-manifest # Formats the sidebar sources and rebuilds docs/manifest.json from them and # the committed generated fragments. Run this after editing the sidebar. It # skips regenerating the CLI and REST API fragments, which make gen does. gen/docs-manifest: fmt/docs-manifest site/node_modules/.installed | _gen $(build-docs-manifest) .PHONY: gen/docs-manifest # Note: we don't run zizmor in the lint target because it takes a while. # GitHub Actions linters are run in a separate CI job (lint-actions) that only # triggers when workflow files change, so we skip them here when CI=true. LINT_ACTIONS_TARGETS := $(if $(CI),,lint/actions/actionlint) lint: lint/shellcheck lint/go lint/go/new-code lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/docs-html lint/docs-manifest lint/docs-redirects lint/style-claims lint/check-scopes lint/check-experiment-keys lint/migrations lint/bootstrap lint/architecture lint/emdash lint/agents lint/mise-versions lint/docs-gen-filter $(LINT_ACTIONS_TARGETS) .PHONY: lint # Fast lint subset for lightweight hooks. Some targets use mise-managed tools. lint-light: lint/shellcheck lint/markdown lint/helm lint/bootstrap lint/migrations lint/actions/actionlint lint/typos lint/emdash lint/docs-redirects lint/style-claims lint/mise-versions .PHONY: lint-light lint/site-icons: ./scripts/check_site_icons.sh .PHONY: lint/site-icons lint/ts: site/node_modules/.installed cd site/ pnpm lint .PHONY: lint/ts # Cap cold-cache golangci-lint on high-core hosts to stay below memory limits. GO_LINT_CONCURRENCY := $(shell n=$$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1); echo $$(( n < 8 ? n : 8 ))) GO_LINT_MEMLIMIT ?= 8GiB # --allow-serial-runners makes lint/go and lint/go/new-code wait for each # other's golangci-lint lock when `make -j lint` starts them together. lint/go: ./scripts/check_golangci_exclusions.sh GOMEMLIMIT="$${GOMEMLIMIT:-$(GO_LINT_MEMLIMIT)}" golangci-lint run --allow-serial-runners --concurrency="$(GO_LINT_CONCURRENCY)" paralleltestctx -custom-funcs="testutil.Context,chatdTestContext" ./... go run ./scripts/intxcheck ./... .PHONY: lint/go # Revision whose merge base with HEAD bounds the lines lint/go/new-code checks. GO_LINT_NEW_CODE_BASE ?= origin/main # Rules the existing tree does not pass yet, applied only to changed lines. # golangci-lint matches changed lines against symlink-resolved file paths # made relative to PWD, so a checkout reached through a symlink would # silently report nothing; `pwd -P` resolves the working directory first. lint/go/new-code: cd "$$(pwd -P)" GOMEMLIMIT="$${GOMEMLIMIT:-$(GO_LINT_MEMLIMIT)}" golangci-lint run --allow-serial-runners --concurrency="$(GO_LINT_CONCURRENCY)" \ --config=.golangci.new-code.yaml --new-from-merge-base="$(GO_LINT_NEW_CODE_BASE)" .PHONY: lint/go/new-code lint/examples: | _gen/bin/examplegen _gen/bin/examplegen -lint .PHONY: lint/examples # Use shfmt to determine the shell files, takes editorconfig into consideration. lint/shellcheck: $(SHELL_SRC_FILES) echo "--- shellcheck" shellcheck --external-sources $(SHELL_SRC_FILES) .PHONY: lint/shellcheck lint/bootstrap: bash scripts/check_bootstrap_quotes.sh .PHONY: lint/bootstrap lint/emdash: bash scripts/check_emdash.sh .PHONY: lint/emdash # Fails when docs Markdown contains invalid inline HTML the docs site drops or # mangles: swallowed angle-bracket placeholders (e.g. <region>), void-element # end tags (</br>), capitalized or unregistered component tags (e.g. <Image>), # and unclosed container tags. Also fails on table header cells with no text. lint/docs-html: echo "--- check for invalid inline HTML and empty table headers in docs" go run ./scripts/docshtmlcheck .PHONY: lint/docs-html # Fails when the YAML sidebar sources under docs/manifest are unformatted or # invalid: unknown or misordered keys, missing pages, overlays that match no # generated route, source files that nothing references, or a page description # (in the sources, a generated fragment, or page front matter) that doesn't end # with a period. lint/docs-manifest: _gen/bin/docsmanifestgen echo "--- check docs sidebar sources" _gen/bin/docsmanifestgen check .PHONY: lint/docs-manifest # Fails when docs/redirects.json, the redirects the docs site applies for pages # that moved or were removed, is malformed, points at a page that is not in # docs/manifest.json, hides a live page, or has duplicate, chained, or looping # rules. Also fails when a route that worked on the base branch or on the live # site for the target branch no longer resolves. The live page list needs # network access; pass -offline to skip it. Passes when the file does not # exist. See scripts/docsredirectscheck/README.md. lint/docs-redirects: echo "--- check docs/redirects.json" go run ./scripts/docsredirectscheck .PHONY: lint/docs-redirects # Fails when the style guide claims a prose rule is enforced by tooling that is # not enabled, when an enabled rule has no style guide section, or when the # coverage tables on the style guide landing page drift from the annotations. # Vale checks a subset of the guide and runs advisory, so the guide's own claims # about what is enforced are the only signal an author has; this keeps them # true. See scripts/styleclaims/README.md. lint/style-claims: echo "--- check docs style guide enforcement claims" go run ./scripts/styleclaims .PHONY: lint/style-claims # Fails when documented --experiments and CODER_EXPERIMENTS values are not in # codersdk.ExperimentsKnown. lint/check-experiment-keys: echo "--- check documented experiment keys" go run ./scripts/checkexperimentkeys .PHONY: lint/check-experiment-keys lint/architecture: ./scripts/check_architecture.sh .PHONY: lint/architecture lint/agents: ./scripts/check_agents_structure.sh .PHONY: lint/agents lint/helm: cd helm/ make lint .PHONY: lint/helm lint/markdown: node_modules/.installed pnpm lint-docs .PHONY: lint/markdown lint/actions: lint/actions/actionlint lint/actions/zizmor .PHONY: lint/actions lint/actions/actionlint: mise exec "go:github.com/rhysd/actionlint/cmd/actionlint" -- actionlint .PHONY: lint/actions/actionlint # zizmor uses GH_TOKEN to fetch imported workflows from GitHub; without it, # external action references are skipped silently. lint/actions/zizmor: @set -euo pipefail; \ if [ -z "$${GH_TOKEN:-}" ] && command -v gh >/dev/null 2>&1; then \ GH_TOKEN="$$(gh auth token 2>/dev/null || true)"; \ export GH_TOKEN; \ fi; \ mise exec zizmor -- zizmor \ --strict-collection \ --persona=regular \ . .PHONY: lint/actions/zizmor lint/mise-versions: ./scripts/check_mise_versions.sh .PHONY: lint/mise-versions # Fails when the docs-gen filter in .github/workflows/ci.yaml misses a docs # file make gen writes. lint/docs-gen-filter: go run ./scripts/docsgenfiltercheck $(GEN_FILES) .PHONY: lint/docs-gen-filter # Verify api_key_scope enum contains all RBAC <resource>:<action> values. lint/check-scopes: coderd/database/dump.sql | _gen/bin/check-scopes _gen/bin/check-scopes .PHONY: lint/check-scopes # Verify migrations do not hardcode the public schema. lint/migrations: ./scripts/check_pg_schema.sh "Migrations" $(MIGRATION_FILES) ./scripts/check_pg_schema.sh "Fixtures" $(FIXTURE_FILES) .PHONY: lint/migrations lint/typos: typos --config .github/workflows/typos.toml .PHONY: lint/typos # Vale (prose linter). # # Invoked through `mise exec` like actionlint and zizmor above, so the # version pinned in mise.toml ("aqua:errata-ai/vale") is the single source # of truth and mise downloads the right OS/arch build. Always pass the full # aqua key: the bare `vale` short name ignores the pin and resolves to the # latest release. # `vale sync` pulls the packages listed in .vale.ini's Packages directive # into StylesPath (docs/.style/styles/). The .vale-synced sentinel makes # sync idempotent across `make lint/prose` calls and lets warm checkouts # skip the re-sync entirely. Make rebuilds this target when `.vale.ini` # changes. docs/.style/.vale-synced: .vale.ini @echo "$(GREEN)==>$(RESET) $(BOLD)vale sync$(RESET)" mise exec "aqua:errata-ai/vale" -- vale sync @touch $@ # Vale exits non-zero only on error-level alerts. `--no-exit` keeps the # target green while the un-overridden Google error-level rules still # produce a baseline error count; real failures (bad config, missing # files) still propagate. Once the baseline error count reaches zero, drop # `--no-exit` and surface error-level violations as real failures. See # DOCS-40. lint/prose: docs/.style/.vale-synced @echo "$(GREEN)==>$(RESET) $(BOLD)lint/prose$(RESET)" mise exec "aqua:errata-ai/vale" -- vale --no-exit docs/ @echo "$(GREEN)==>$(RESET) Vale checks a subset of the style guide and never fails this target." @echo " Coverage: docs/.style/style-guide/README.md#what-the-tooling-checks-and-what-it-doesnt" .PHONY: lint/prose # pre-commit and pre-push mirror CI checks locally. # # pre-commit runs checks that don't need external services (Docker, # Playwright). This is the git pre-commit hook default since Docker # and browser issues in the local environment would otherwise block # all commits. # # pre-push adds heavier checks: Go tests, JS tests, and site build. # Storybook tests are deliberately excluded: the vitest browser run # has repeatedly stalled or failed for developers running pre-push, |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |