diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5cbab39 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,84 @@ +name: "Publish container image" + +on: + push: + branches: + - main + tags: + - v* + + release: + types: + - published + + workflow_dispatch: + +jobs: + publish: + name: Publish container images + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + + - name: Unshallow + run: git fetch --prune --tags --unshallow + + - name: Describe the current state + run: git describe --tags --always + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{raw}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Package Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + shell: bash diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d19c362 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Created by https://www.toptal.com/developers/gitignore/api/go +# Edit at https://www.toptal.com/developers/gitignore?templates=go + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +# End of https://www.toptal.com/developers/gitignore/api/go diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..a2c4c85 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,4 @@ +# https://help.github.com/articles/about-codeowners/ +# https://git-scm.com/docs/gitignore#_pattern_format + +* @grafana/grafana-build-tools diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3d4caa4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at conduct@grafana.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dcb97f2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,96 @@ +FROM registry.hub.docker.com/library/golang:1.21.3 as go-build + + COPY go.env /usr/local/go + + RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0 + RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.20.0 + RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet-deps@v0.20.0 + RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet-lint@v0.20.0 + + # The grafana/xk6 image only exists for amd64, so we need to build it for + # the target architecture. + RUN env GOBIN=/build go install go.k6.io/xk6/cmd/xk6@v0.9.2 + + # The grafana/k6 image only exists for amd64, so we need to build it for + # the architecture we are targeting. The simplest way to build k6 is to + # (ab)use xk6 to build a binary without any extensions. In the future, if + # we wanted additional extensions, this is the place to add them. + RUN /build/xk6 build v0.46.0 --output /build/k6 + + # Add wire + RUN env GOBIN=/build go install github.com/google/wire/cmd/wire@v0.5.0 + + # Add bingo + RUN env GOBIN=/build go install github.com/bwplotka/bingo@v0.8.0 + + # Add enumer + RUN env GOBIN=/build go install github.com/dmarkham/enumer@v1.5.7 + + # Add protoc-gen-go + RUN env GOBIN=/build go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 + + # Add protoc-gen-go-grpc + RUN env GOBIN=/build go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 + + # Add buf + RUN env GOBIN=/build go install github.com/bufbuild/buf/cmd/buf@v1.26.1 + + # Add mage + RUN git clone --depth 1 --branch v1.15.0 https://github.com/magefile/mage mage && \ + cd mage && \ + env GOBIN=/build go run bootstrap.go + + # Add nilaway + # This hasn't been released yet, so pin it to a specific version for reproducibility + RUN env GOBIN=/build go install go.uber.org/nilaway/cmd/nilaway@v0.0.0-20231117175943-a267567c6fff + + # Add golangci-lint + COPY --from=registry.hub.docker.com/golangci/golangci-lint:v1.55.2 /usr/bin/golangci-lint /build + + # Add shellcheck + COPY --from=registry.hub.docker.com/koalaman/shellcheck:v0.9.0 /bin/shellcheck /build + +FROM registry.hub.docker.com/library/debian:stable-slim as build + + COPY --from=go-build /usr/local/go /usr/local/go + + ENV PATH="/usr/local/go/bin:${PATH}" + + RUN apt-get update && \ + apt-get install -y \ + build-essential \ + libgpgme-dev \ + libassuan-dev \ + libdevmapper-dev \ + pkg-config \ + git + + # skopeo is used to inspect container registries. This can be used to + # inspect the available versions without pulling the repos. + RUN git clone https://github.com/containers/skopeo && \ + cd skopeo && \ + make GOBIN=/build DISABLE_DOCS=1 bin/skopeo && \ + mkdir -p /build && \ + cp bin/skopeo /build/ + +FROM registry.hub.docker.com/library/debian:stable-slim + + RUN apt-get update && \ + apt-get install -y \ + build-essential \ + docker.io \ + file \ + git \ + pkg-config \ + libgpgme11 \ + && \ + rm -rf /var/lib/apt/lists + + COPY --from=go-build /usr/local/go /usr/local/go + ENV PATH="/usr/local/go/bin:${PATH}" + + # Keep tools in /usr/local/bin. That makes it a little bit easier to see + # what comes from the image vs stuff coming from the base image. + COPY --from=go-build /build/* /usr/local/bin/ + + COPY image-test /usr/local/bin diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3e7759b --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020 Grafana Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..479d964 --- /dev/null +++ b/Makefile @@ -0,0 +1,112 @@ +.DEFAULT_GOAL := build + +S := @ + +ROOTDIR := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) + +IMAGE_REPO := ghcr.io/grafana +IMAGE_NAME := build-tools +IMAGE_TAG ?= $(shell $(ROOTDIR)/scripts/image-tag) +IMAGE := $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) +LATEST_IMAGE := $(IMAGE_REPO)/$(IMAGE_NAME):latest + +LOCAL_ARCH := $(strip $(shell $(ROOTDIR)/scripts/local-machine)) + +DOCKER_BUILDKIT ?= 1 +export DOCKER_BUILDKIT + +# All arches we build images for. Usually set by CI. Set this if you're building +# locally. Be aware if you drop an arch then the "latest" tag won't include it, +# so you will break users who are running that arch. Probably just don't push if +# you're running locally. +PUSH_ARCHES ?= $(LOCAL_ARCH) + +##@ Development + +BUILD_TARGETS := + +define build-target +.PHONY: build-$(1) +build-$(1): + @set -e + docker build . -f Dockerfile -t "$(IMAGE)-$(1)" + +BUILD_TARGETS += build-$(1) +endef + +$(foreach BUILD_ARCH,$(PUSH_ARCHES),$(eval $(call build-target,$(BUILD_ARCH)))) + +.PHONY: build +build: $(BUILD_TARGETS) +build: ## build the image + @true + +.PHONY: test +test: build-$(LOCAL_ARCH) +test: ## test the image + $(S) docker run --rm $(IMAGE)-$(LOCAL_ARCH) image-test + +# Run the image from the first of the PUSH_ARCHES, assuming it'll run on this +# machine since it was built here (this target depends on 'build') +.PHONY: shell +shell: build-$(LOCAL_ARCH) +shell: ## run the image in a container + $(S) docker run -it --rm $(IMAGE)-$(LOCAL_ARCH) /bin/bash + +##@ Publish + +.PHONY: push-dev +push-dev: build test +push-dev: ## push the image to the registry + $(S) for arch in $(PUSH_ARCHES); do \ + set -xe ; \ + docker push $(IMAGE)-$$arch ; \ + done + +.PHONY: push +push: build test push-dev +push: ## tag latest and push the to the registry + $(S) for arch in $(PUSH_ARCHES); do \ + set -xe ; \ + docker tag $(IMAGE)-$$arch $(LATEST_IMAGE)-$$arch ; \ + docker push $(LATEST_IMAGE)-$$arch ; \ + done + +# Make ":latest" and ":version" manifests for all images. +# +# This doesn't have a dependency as it runs in a separate pipeline, but it does +# rely on the images having been built and pushed +.PHONY: push-manifest +push-manifest: + $(S) for tag in "$(LATEST_IMAGE)" "$(IMAGE)"; do \ + set -xe ; \ + echo "Building manifest for $$tag" ; \ + docker manifest create --amend $$tag $(foreach arch,$(PUSH_ARCHES),$$tag-$(arch)) ; \ + docker manifest inspect $$tag ; \ + docker manifest push $$tag ; \ + done + +##@ Helpers + +.PHONY: image-prefix +image-prefix: ## print out the image prefix (registry and project) + $(S) echo $(IMAGE_REPO) + +.PHONY: image-name +image-name: ## print out the image name + $(S) echo $(IMAGE_NAME) + +# Print out the tag. If we're pushing multiple arches, assume this is the +# manifest (without version), otherwise the scheme is the version with the arch +# appended. +.PHONY: tag +tag: ## print out the tag + $(S) if [ -z $(MULTI_ARCH) ] || [ $(N_ARCHES) -gt 1 ]; then \ + echo $(IMAGE_TAG) ;\ + else \ + echo $(IMAGE_TAG)-$(PUSH_ARCHES) ;\ + fi + +.PHONY: help +help: ## display this help. + $(S) awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) diff --git a/README.md b/README.md new file mode 100644 index 0000000..86e5fbd --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Go tools image + +This image is used to build Go projects. It contains the Go compiler (from the official golang container) as well as additional tools that help with building projects. + +## Updating + +First you need to confirm that the image is building and that the changes are present: + +1. update [`Dockerfile`](Dockerfile) and add all the changes you want to add to this base image. +2. run `make build` and make sure it passes. +3. run `make shell` and test your changes are indeed present. +4. run `make test` to make sure all components are working. + +Once you confirmed the build passes and the changes are as expected do the following: + +1. create a commit with `Makefile`, `Dockerfile` and `image-test` changes. +2. push the changes and create a new pull request. + +After the PR gets reviewed you need to check all the different places where `grafana-build-tools` is used and update accordingly. Here [`git grep`](http://git-scm.com/docs/git-grep) is your friend: + +* `git grep grafana-build-tools` will list all places where `grafana-build-tools` is used. +* `git grep grafana-build-tools:$OLDVERSION` same as before, but more restrictive. diff --git a/go.env b/go.env new file mode 100644 index 0000000..c2a87b2 --- /dev/null +++ b/go.env @@ -0,0 +1,15 @@ +# This file contains the initial defaults for go command configuration. +# Values set by 'go env -w' and written to the user's go/env file override these. +# The environment overrides everything else. + +# Use the Go module mirror and checksum database by default. +# See https://proxy.golang.org for details. +GOPROXY=https://proxy.golang.org,direct +GOSUMDB=sum.golang.org + +# Avoid using proxies for anything in the grafana organization. +GOPRIVATE=github.com/grafana + +# DO NOT download Go toolchains. We want to use the one from the image. +# See https://go.dev/doc/toolchain for details. +GOTOOLCHAIN=local diff --git a/image-test b/image-test new file mode 100755 index 0000000..f143f27 --- /dev/null +++ b/image-test @@ -0,0 +1,69 @@ +#!/bin/sh +# This script is used to test that all the expected components are present in +# the image and they are able to run. + +set -eu + +echo '=== Go' +go version +if test "$(go env GOTOOLCHAIN)" != "local" ; then + echo "E: unexpected value for GOTOOLCHAIN." + exit 1 +fi + +echo '=== jsonnet' +jsonnet --version +jsonnetfmt --version +jsonnet-deps --version +jsonnet-lint --version + +echo '=== k6' +# Note that we _know_ xk6 works because it was used to build the k6 binary. +# That said, there doesn't seem to be an equivalent of `k6 version` for xk6, +# so we just check that the binary exists. +command -v xk6 +k6 version + +echo '=== wire' +wire help + +echo '=== bingo' +bingo version + +echo '=== enumer' +enumer -help + +echo '=== proto-gen-go' +protoc-gen-go --version + +echo '=== protoc-gen-go-grpc' +protoc-gen-go-grpc --version + +echo '=== buf' +buf --version + +echo '=== mage' +mage -version + +echo '=== nilaway' +nilaway -help + +echo '=== golangci-lint' +golangci-lint version + +echo '=== shellcheck' +shellcheck --version + +echo '=== gcc' +gcc --version + +echo '=== file' +file --version +# Make sure we have the magic file database +file "$(command -v file)" + +echo '=== git' +git version + +echo '=== pkg-config' +pkg-config --help diff --git a/scripts/image-tag b/scripts/image-tag new file mode 100755 index 0000000..43ac441 --- /dev/null +++ b/scripts/image-tag @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +set -eu + +# Are we building locally? +suffix= +if test -z "${CI:-}" ; then + suffix=-local +fi + +version="$(git describe --tags --dirty)" + +tag="${version}${suffix}" + +printf '%s' "${tag}" diff --git a/scripts/local-machine b/scripts/local-machine new file mode 100755 index 0000000..42ec757 --- /dev/null +++ b/scripts/local-machine @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +set -eu + +machine=$(uname --machine) + +case "${machine}" in + x86_64) + echo amd64 + ;; + aarch64) + echo arm64 + ;; + *) + echo "${machine}" + ;; +esac