github.com/vugu/vugu@v0.3.6-0.20240430171613-3f6f402e014b/Taskfile.yaml (about) 1 # Taskfile for 'vugu' 2 # 3 # The Taskfile builds vugu, runs all the tests and lints the source code. 4 5 version: '3' 6 7 # TODO: Warning this task file assumes Linux is the OS. The Taskfile will need to reworked to strip the Linux only shell cmds 8 tasks: 9 # Build everything, run all the tests (using go, tinygo and tinygo in docker) and lint the codebase 10 all: 11 preconditions: 12 - task: check-cmds-exist 13 cmds: 14 - task: clean-vgform 15 - task: clean-wasm-test-suite 16 - task: build 17 - task: test 18 - task: test-wasm 19 - task: lint 20 21 22 # Build the vugu packages and the vugugen and vugufmt commands 23 build: 24 cmds: 25 # note we now use the full package names 26 # we have to run go generate in the vgform package 27 - go generate github.com/vugu/vugu/vgform 28 # build and install the vugu package 29 - go install github.com/vugu/vugu 30 # build and install the vugugen command 31 - go install github.com/vugu/vugu/cmd/vugugen 32 # build and install the vugufmt command 33 - go install github.com/vugu/vugu/cmd/vugufmt 34 35 36 # Run all of the tests - except the wasm-test-suite. The wasm-test-suite currently takes circa 35 minutes to execute. 37 # Some of the tests (e.g. in the devutil package) are build using tinygo, so a locally installed tiny go is a prerequisite. 38 test: 39 # it's a precondition is that tinygo is available 40 preconditions: 41 - task: check-cmds-exist 42 - sh: command -v tinygo 43 msg: "tinygo not found. Please see https://tinygo.org/getting-started/install/ for how to install locally" 44 cmds: 45 # run all of the tests EXCEPT the wasm-test-suite (we use go list ./... to list all the packages and then ignore wasm-test-suite via the "-v" in the grep) 46 - go test `go list ./... | grep -v wasm-test-suite` 47 48 49 # Run just the wasm-test-suite tests. This can take up to 35 minutes to complete. 50 # The wasm-test suite builds all of the tests three times - once using go, once using tinygo and once using tinygo installed in a docker container 51 # Therefore docker is a prerequisite to run these tests along with tinygo. 52 # The docker container that is started is named `wasm-test-suite`. It will be stopped and removed once the tests are complete. 53 # The tests are servered by a small Go http server - the wasm-test-suite-srv executeable. This is build prior to the tests being run. It is installed in the 54 # 'wasm-test-suite' container 55 test-wasm: 56 dir: 57 # This task must be executed from the local "wasm-test-suite/docker" directory. The contents of the Dockerfile rely on this. 58 # The 'wasm-test-suite-srv' executable will be put into the "wasm-test-suite/docker" directory. 59 ./wasm-test-suite/docker 60 # the precondition is docker and tinygo are both available 61 preconditions: 62 - sh: command -v tinygo 63 msg: "tinygo not found. Please see https://tinygo.org/getting-started/install/ for how to install locally" 64 - sh: command -v docker 65 msg: "docker not found. Please see https://docs.docker.com/desktop/ for how to install locally" 66 cmds: 67 # build the wasm-test-suite-srv. Note we build via the package name. 68 - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./wasm-test-suite-srv github.com/vugu/vugu/wasm-test-suite/docker 69 # docker build and tag our image 70 - docker build -t vugu/wasm-test-suite:latest . 71 # we want to ignore any failures e.g. the wasm-test-suite container wasn't running so we have to use "cmd:" to be explicit which error 72 # we want to ignore. 73 - cmd: 'docker stop wasm-test-suite' 74 ignore_error: true 75 # ditto, be explit so it's clear we are ignoring any 'docker rm' error 76 - cmd: 'docker rm wasm-test-suite' 77 ignore_error: true 78 # start the container 79 - docker run -d -t -p 9222:9222 -p 8846:8846 --name wasm-test-suite vugu/wasm-test-suite:latest 80 # stop the container and cleanup once the task is complete 81 - defer: docker stop wasm-test-suite 82 # run the tests 83 # set the timeout for 35 minutes, as the tests can timeout between 20 and 35 minutes depending on the hardware 84 # and enable verbose output otherwise it looks like this hangs. 85 - go test -v -timeout=35m github.com/vugu/vugu/wasm-test-suite 86 87 88 # Run the linter 89 lint: 90 # we use 'golangci-lint' as a meta linter, so it's availability is a prerequisite. 91 preconditions: 92 - sh: command -v golangci-lint 93 msg: "glangci-lint not found. Please see https://golangci-lint.run/usage/install/#local-installation for how to install locally" 94 cmds: 95 - golangci-lint run . 96 97 98 # Remove all of the generated files in the vgform package 99 clean-vgform: 100 # both the 'find' and 'rm' commands are prerequisites 101 preconditions: 102 - task: check-cmds-exist 103 cmds: 104 # We need to delete one of these after (or if) PR261 is merged 105 # old version - uses the "_vgen" suffix 106 - find ./vgform -type f -name "*_vgen.go" -exec rm {} \; 107 # new version post PR261 uses the newer "_gen" suffix. 108 - find ./vgform -type f -name "*_gen.go" -exec rm {} \; 109 110 111 # Remove all of the generated files in the 'wasm-test-suite' package 112 clean-wasm-test-suite: 113 preconditions: 114 - task: check-cmds-exist 115 cmds: 116 # We need to delete one of these after (or if) PR261 is merged 117 # old version - uses the "_vgen" suffix 118 - find ./wasm-test-suite -type f -name "*_vgen.go" -exec rm {} \; 119 # new version post PR261 uses the newer "_gen" suffix. 120 - find ./wasm-test-suite -type f -name "*_gen.go" -exec rm {} \; 121 122 123 # Check that the (linux) tools we rely on are present. 124 # We will need to change these to check for he platform specific equivalents. 125 check-cmds-exist: 126 preconditions: 127 - sh: command -v find 128 msg: "find command not found." 129 - sh: command -v grep 130 msg: "grep command not found." 131 - sh: command -v rm 132 msg: "rm command not found." 133