agones.dev/agones@v1.53.0/build/includes/website.mk (about)

     1  # Copyright 2018 Google LLC All Rights Reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  
    16  #  __        __   _         _ _
    17  #  \ \      / /__| |__  ___(_) |_ ___
    18  #   \ \ /\ / / _ \ '_ \/ __| | __/ _ \
    19  #    \ V  V /  __/ |_) \__ \ | |_  __/
    20  #     \_/\_/ \___|_.__/|___/_|\__\___|
    21  #
    22  
    23  #
    24  # Website targets
    25  #
    26  
    27  # generate the latest website
    28  site-server: ARGS ?=-F
    29  site-server: ENV ?= RELEASE_VERSION="$(base_version)" RELEASE_BRANCH=main
    30  site-server: ensure-build-image
    31  	docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) -p 1313:1313 $(build_tag) bash -c \
    32  	"$(git_safe) && $(ENV) hugo server --watch --baseURL=http://localhost:1313/ --bind=0.0.0.0 $(ARGS)"
    33  
    34  site-static: ensure-build-image
    35  	-docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) rm -r ./public
    36  	-mkdir $(agones_path)/site/public
    37  	# for some reason, this only work locally
    38  	# postcss-cli@8.3.1 broke things, so pinning the version
    39  	docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) \
    40  		bash -c "npm list postcss-cli || npm install postcss-cli@11.0.0"
    41  	# autoprefixer 10.0.0 broke things, so pinning the version
    42  	docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) \
    43  		bash -c "npm list autoprefixer || npm install autoprefixer@10.4.20"
    44  	docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
    45          "$(git_safe) && $(ENV) hugo --config=config.toml $(ARGS)"
    46  
    47  site-gen-app-yaml: SERVICE ?= default
    48  site-gen-app-yaml:
    49  	docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
    50  			"SERVICE=$(SERVICE) envsubst < app.yaml > .app.yaml"
    51  
    52  site-deploy: site-gen-app-yaml site-static
    53  	docker run --network=cloudbuild -t --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) \
    54  	-e GO111MODULE=on -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \
    55  	'printenv && cd  ./site && \
    56      gcloud app deploy .app.yaml --no-promote --quiet --version=$$SHORT_SHA'
    57  
    58  site-static-preview:
    59  	$(MAKE) site-static ARGS="-F" ENV="RELEASE_VERSION=$(base_version) RELEASE_BRANCH=main"
    60  
    61  site-deploy-preview: site-static-preview
    62  	$(MAKE) site-deploy SERVICE=preview
    63  
    64  hugo-test: site-static-preview
    65  	for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; \
    66  		do echo "Html Test: Attempt $$i" && \
    67  		  docker run --rm -t -e "TERM=xterm-256color" $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
    68  			"mkdir -p /tmp/website && cp -r $(mount_path)/site/public /tmp/website/site && htmltest -c $(mount_path)/site/htmltest.yaml /tmp/website" && \
    69  	break || sleep 60 && false; done
    70  
    71  site-test:
    72  	# generate actual html and run test against - provides a more accurate tests
    73  	$(MAKE) test-gen-api-docs
    74  	$(MAKE) hugo-test
    75  
    76  # generate site images, if they don't exist
    77  site-images: $(site_path)/static/diagrams/gameserver-states.dot.png
    78  site-images: $(site_path)/static/diagrams/eviction-decision.dot.png
    79  site-images: ${site_path}/static/diagrams/system-diagram.dot.png
    80  site-images: $(site_path)/static/diagrams/gameserver-lifecycle.puml.png
    81  site-images: $(site_path)/static/diagrams/gameserver-reserved.puml.png
    82  site-images: $(site_path)/static/diagrams/canary-testing.puml.png
    83  site-images: $(site_path)/static/diagrams/allocation-player-capacity-tracking.puml.png
    84  site-images: $(site_path)/static/diagrams/allocation-player-capacity-list.puml.png
    85  site-images: $(site_path)/static/diagrams/reusing-gameservers.puml.png
    86  site-images: $(site_path)/static/diagrams/high-density-label-lock.puml.png
    87  site-images: $(site_path)/static/diagrams/high-density-counters.puml.png
    88  
    89  # generate pngs from dot files
    90  %.dot.png: %.dot
    91  	docker run -i --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
    92  	  'dot -Tpng /dev/stdin' < $< > $@.tmp && mv $@.tmp $@
    93  
    94  # general pngs from puml files
    95  %.puml.png: %.puml
    96  	docker run -i --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
    97  		'plantuml -pipe' < $< > $@
    98  
    99  # Path to a file and docker command
   100  REL_PATH := content/en/docs/Reference/agones_crd_api_reference.html
   101  GEN_API_DOCS := docker run -e FILE="$(mount_path)/site/$(REL_PATH)" -e VERSION=${base_version} --rm -i $(common_mounts) $(build_tag) bash -c "/go/src/agones.dev/agones/site/gen-api-docs.sh"
   102  
   103  # generate Agones CRD reference docs
   104  gen-api-docs: ensure-build-image
   105  	$(GEN_API_DOCS)
   106  
   107  # test generated Agones CRD reference docs
   108  test-gen-api-docs: expected_docs := $(site_path)/$(REL_PATH)
   109  test-gen-api-docs: ensure-build-image
   110  	cp $(expected_docs) /tmp/generated.html
   111  	sort /tmp/generated.html > /tmp/generated.html.sorted
   112  	$(GEN_API_DOCS)
   113  	sort $(expected_docs) > /tmp/result.sorted
   114  	diff -bB /tmp/result.sorted /tmp/generated.html.sorted
   115  
   116  # Remove feature expiry/publish version shortcodes update in site/content/en/docs
   117  feature-shortcode-update: ensure-build-image
   118  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   119  		go run build/scripts/feature-shortcode-update/main.go -version=$(version)
   120  
   121  # update SDKS/Install version. Specify the release stage ('before', 'after', or 'patch').
   122  sdk-update-version: ensure-build-image
   123  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   124  		go run build/scripts/sdk-update-version/main.go -release-stage=$(release_stage) -version=$(version)
   125  
   126  # delete "data-proofer-ignore" attribute from previous release blog.
   127  del-data-proofer-ignore: FILENAME ?= ""
   128  del-data-proofer-ignore: ensure-build-image
   129  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   130  		go run build/scripts/remove-data-proofer-ignore/main.go -file=$(FILENAME)
   131  
   132  # update release version and replicate data between dev and prod in site/config.toml for
   133  # release_stage=minor or release_stage=patch
   134  site-config-update-version: ensure-build-image
   135  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   136  		go run build/scripts/site-config-update-version/main.go -release-stage=$(release_stage)
   137  
   138  # Delete old release version in site/layouts/partials/navbar.html.
   139  update-navbar-version: FILENAME ?= ""
   140  update-navbar-version: ensure-build-image
   141  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   142  		go run build/scripts/update-navbar-version/main.go -file=$(FILENAME)
   143  
   144  # bump examples image
   145  bump-image: ensure-build-image
   146  	docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
   147  		go run build/scripts/bump-image/main.go -imageName=$(IMAGENAME) -version=$(VERSION)