github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/ABTaskFile (about) 1 name: build_tasks 2 description: Choria Build Tasks 3 4 commands: 5 - name: dependencies 6 type: parent 7 description: Manage dependencies 8 aliases: [d] 9 commands: 10 - name: update 11 description: Update dependencies 12 type: exec 13 aliases: [up] 14 dir: "{{ AppDir }}" 15 flags: 16 - name: verbose 17 description: Log verbosely 18 short: v 19 bool: true 20 - name: proxy 21 description: Enable using go proxy 22 bool: true 23 default: "true" 24 script: | 25 . "{{ BashHelperPath }}" 26 27 ab_announce Updating all dependencies 28 echo 29 30 {{ if eq .Flags.proxy false }} 31 export GOPROXY=direct 32 ab_say Disabling go mod proxy 33 {{ end }} 34 35 go get -u -n -a -t {{- if .Flags.verbose }} -d -x {{ end }} ./... 36 37 ab_say Running go mod tidy 38 39 go mod tidy 40 41 - name: generate 42 type: parent 43 aliases: [gen] 44 description: Performs 'go generate' tasks 45 commands: 46 - name: all 47 description: Generates all files 48 type: exec 49 dir: "{{ AppDir }}" 50 command: go generate 51 52 - name: plugins 53 description: Generate plugin files 54 type: exec 55 dir: "{{ AppDir }}" 56 flags: 57 - name: clean 58 description: Removes existing plugin stubs 59 bool: true 60 script: | 61 . "{{ BashHelperPath }}" 62 63 {{ if .Flags.clean }} 64 ab_announce Deleting existing plugin stubs 65 rm -f plugin_*_*.go 66 {{ end }} 67 go generate -run plugin 68 69 - name: config 70 description: Generate configuration related files 71 type: exec 72 dir: "{{ AppDir }}" 73 command: go generate -run config 74 75 - name: clients 76 description: Generate rpc clients related files 77 type: exec 78 dir: "{{ AppDir }}" 79 command: go generate -run client 80 81 - name: imocks 82 description: Generate inter/imocks related files 83 type: exec 84 dir: "{{ AppDir }}" 85 banner: Regenerating mocks in inter/imocks 86 command: go generate -run imocks 87 88 - name: test 89 type: parent 90 aliases: [t] 91 description: Perform various tests 92 commands: 93 - name: unit 94 type: exec 95 description: Run ginkgo unit tests 96 aliases: [u] 97 arguments: 98 - name: dir 99 description: Directory to test 100 default: . 101 flags: 102 - name: update 103 description: Updates the ginkgo runtime 104 bool: true 105 script: | 106 set -e 107 108 . "{{ BashHelperPath }}" 109 110 {{ if .Flags.update }} 111 ab_say Updating ginkgo binary 112 go install github.com/onsi/ginkgo/v2/ginkgo 113 {{ end }} 114 115 ginkgo -r --skip Integration {{ .Arguments.dir | escape }} 116 117 - name: integration 118 type: exec 119 dir: "{{ AppDir }}" 120 aliases: [i] 121 description: Run ginkgo integration tests 122 command: ginkgo -r integration 123 124 - name: lint 125 type: exec 126 dir: "{{ AppDir }}" 127 flags: 128 - name: vet 129 description: Perform go vet 130 bool: true 131 default: true 132 - name: staticcheck 133 description: Perform staticcheck 134 bool: true 135 default: true 136 - name: update 137 description: Updates lint dependencies 138 bool: true 139 script: | 140 set -e 141 142 . "{{ BashHelperPath }}" 143 144 {{ if .Flags.update }} 145 ab_say Updating linting tools 146 go install github.com/client9/misspell/cmd/misspell@latest 147 go install honnef.co/go/tools/cmd/staticcheck@latest 148 {{ else }} 149 echo ">>> Run with --update to install required commands" 150 echo 151 {{ end }} 152 153 ab_say Formatting source files 154 go fmt ./... 155 156 ab_say Tidying go mod 157 go mod tidy 158 159 ab_say Checking spelling 160 find . -type f -name "*.go" | xargs misspell -error -locale US -i flavour 161 find docs/content -type f -name "*.md" | xargs misspell -error -locale US 162 163 {{ if .Flags.vet }} 164 ab_say Performing go vet 165 go vet ./... 166 {{ end }} 167 168 {{ if .Flags.staticcheck }} 169 ab_say Running staticcheck 170 staticcheck ./... 171 {{ end }} 172 173 - name: docs 174 type: parent 175 description: Documentation related commands 176 commands: 177 - name: serve 178 description: Serves documentation locally 179 type: exec 180 dir: "{{ AppDir }}" 181 flags: 182 - name: port 183 description: The port to listen on 184 default: "8081" 185 command: hugo serve -p {{ .Flags.port }} -s docs 186 187 - name: build 188 type: parent 189 aliases: [b] 190 description: Code build steps 191 commands: 192 - name: binary 193 description: Build a basic test binary 194 type: exec 195 dir: "{{ AppDir }}" 196 aliases: [bin] 197 banner: | 198 >>> 199 >>> Building 'go-choria' locally 200 >>> 201 >>> Target: {{ if .Flags.target }}{{ .Flags.target }}{{else}}host{{end}} 202 >>> provisioning.jwt: {{ .Flags.provisioning }} 203 >>> Default Collective: {{.Flags.collective}} 204 >>> 205 flags: 206 - name: target 207 description: Target platform to build for 208 enum: ["linux/amd64", "linux/arm64"] 209 short: T 210 - name: provisioning 211 description: Path to the default provisioning.jwt 212 default: /etc/choria/provisioning.jwt 213 - name: collective 214 description: Sets the default collective 215 default: mcollective 216 - name: verbose 217 description: Logs packages being build 218 bool: true 219 short: v 220 script: | 221 set -e 222 223 . "{{ BashHelperPath }}" 224 225 {{ if eq .Flags.target "linux/amd64" }} 226 export GOOS=linux 227 export GOARCH=amd64 228 {{ else if eq .Flags.target "linux/arm64" }} 229 export GOOS=linux 230 export GOARCH=arm64 231 {{ end }} 232 233 {{ if .Flags.verbose }} 234 ab_say Packages being build 235 {{ end }} 236 237 go build \ 238 {{ if .Flags.verbose }}-v{{ end }} \ 239 -ldflags="-s -w \ 240 -X 'github.com/choria-io/go-choria/build.Version=0.0.$(date +%s)' \ 241 -X 'github.com/choria-io/go-choria/build.DefaultCollectives={{.Flags.collective}}' \ 242 {{ if .Flags.provisioning }}-X 'github.com/choria-io/go-choria/build.ProvisionJWTFile={{ .Flags.provisioning }}'{{ end }} \ 243 " -o go-choria 244 245 ab_say Build completed 246 247 echo 248 ls -l go-choria 249 echo 250 file go-choria 251 echo 252 253 - name: release-docker 254 description: Builds release docker container 255 type: exec 256 dir: "{{ AppDir }}" 257 aliases: [rd] 258 flags: 259 - name: repo 260 description: YUM Repository to use 261 default: https://yum.eu.choria.io/release/el/release.repo 262 - name: push 263 description: Push the built images 264 default: false 265 bool: true 266 script: | 267 set -e 268 269 . "{{ BashHelperPath }}" 270 271 ab_announce Building release docker container using {{ .Flags.repo }} 272 273 TAG=$(git tag --points-at HEAD|sed -e s/^v//) 274 if [ -z "${TAG}" ] 275 then 276 ab_panic HEAD is not a tag 277 fi 278 279 docker pull almalinux:8 280 281 docker build \ 282 --no-cache \ 283 --build-arg REPO={{ .Flags.repo | escape }} \ 284 --tag "choria/choria:${TAG}" \ 285 --tag "choria/choria:latest" \ 286 --tag "registry.choria.io/choria/choria:${TAG}" \ 287 --tag "registry.choria.io/choria/choria:latest" \ 288 . 289 290 {{ if .Flags.push }} 291 ab_say Pushing built containers 292 docker push "choria/choria:${TAG}" 293 docker push "choria/choria:latest" 294 docker push "registry.choria.io/choria/choria:${TAG}" 295 docker push "registry.choria.io/choria/choria:latest" 296 {{ else }} 297 ab_say Skipping container push 298 {{ end }}