From cd0815852208fa3ea5d6c47d37d2f1f01e2af42e Mon Sep 17 00:00:00 2001 From: Daichi Sakaue Date: Thu, 10 Oct 2024 15:25:35 +0900 Subject: [PATCH] Install tools with aqua Signed-off-by: Daichi Sakaue --- .github/actions/aqua/action.yaml | 14 ++++++++++++++ .github/workflows/ci.yaml | 3 +++ Makefile | 13 ++++++------- aqua.yaml | 13 +++++++++++++ e2e/Makefile | 7 +++---- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .github/actions/aqua/action.yaml create mode 100644 aqua.yaml diff --git a/.github/actions/aqua/action.yaml b/.github/actions/aqua/action.yaml new file mode 100644 index 0000000..02f2e19 --- /dev/null +++ b/.github/actions/aqua/action.yaml @@ -0,0 +1,14 @@ +name: "Setup tools" +description: "Setup tools with aqua" +inputs: + github_token: + description: "GitHub Token" + required: true +runs: + using: composite + steps: + - uses: aquaproj/aqua-installer@6ce1f8848ec8e61f14d57bd5d7597057a6dd187c # v3.0.1 + with: + aqua_version: v2.25.1 + env: + GITHUB_TOKEN: ${{ inputs.github_token }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 31f7938..df33b35 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,9 @@ jobs: with: path: cache key: cache-files-go-${{ hashFiles('go.mod') }}-${{ hashFiles('Makefile') }} + - uses: ./.github/actions/aqua + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Setup tools run: make setup - name: Run code check diff --git a/Makefile b/Makefile index c6c7b17..068a9a0 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ JQ_VERSION := 1.7.1 KIND_VERSION := 0.22.0 KUBECTL_VERSION := 1.29.3 KUSTOMIZE_VERSION := 5.3.0 -YQ_VERSION := 4.43.1 # Test tools CUSTOMCHECKER := $(TOOLS_DIR)/custom-checker @@ -18,7 +17,6 @@ KIND := $(TOOLS_DIR)/kind KUBECTL := $(TOOLS_DIR)/kubectl KUSTOMIZE := $(TOOLS_DIR)/kustomize STATICCHECK := $(TOOLS_DIR)/staticcheck -YQ := $(TOOLS_DIR)/yq .PHONY: all all: help @@ -30,7 +28,12 @@ help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) .PHONY: setup -setup: $(CUSTOMCHECKER) $(HELM_BINARY) $(KIND) $(JQ) $(KUBECTL) $(KUSTOMIZE) $(STATICCHECK) $(YQ) ## Install necessary tools +setup: $(CUSTOMCHECKER) $(HELM_BINARY) $(KIND) $(JQ) $(KUBECTL) $(KUSTOMIZE) $(STATICCHECK) ## Install necessary tools + if ! which aqua; then \ + echo 'setup needs aqua.'; \ + exit 1; \ + fi + aqua install -l $(HELM) repo add cilium https://helm.cilium.io/ $(HELM) repo update cilium @@ -63,10 +66,6 @@ $(KUSTOMIZE): $(STATICCHECK): GOBIN=$(TOOLS_DIR) go install honnef.co/go/tools/cmd/staticcheck@latest -$(YQ): - mkdir -p $(TOOLS_DIR) - wget -qO $@ https://github.com/mikefarah/yq/releases/download/v$(YQ_VERSION)/yq_linux_amd64 - chmod +x $@ .PHONY: clean clean: diff --git a/aqua.yaml b/aqua.yaml new file mode 100644 index 0000000..deaf6c2 --- /dev/null +++ b/aqua.yaml @@ -0,0 +1,13 @@ +--- +# aqua - Declarative CLI Version Manager +# https://aquaproj.github.io/ +# checksum: +# enabled: true +# require_checksum: true +# supported_envs: +# - all +registries: +- type: standard + ref: v4.231.0 # renovate: depName=aquaproj/aqua-registry +packages: +- name: mikefarah/yq@v4.44.3 diff --git a/e2e/Makefile b/e2e/Makefile index ced9aaa..33af733 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -9,7 +9,6 @@ HELM := $(TOOLS_DIR)/helm --repository-cache $(CACHE_DIR)/helm/repository --repo KIND := $(TOOLS_DIR)/kind KUBECTL := $(TOOLS_DIR)/kubectl KUSTOMIZE := $(TOOLS_DIR)/kustomize -YQ := $(TOOLS_DIR)/yq ##@ Basic @@ -38,9 +37,9 @@ start: run-test-pod-%: cat testdata/template/ubuntu.yaml | \ - $(YQ) '.metadata.name = "$*"' | \ - $(YQ) '.spec.selector.matchLabels = {"test": "$*"}' | \ - $(YQ) '.spec.template.metadata.labels = {"test": "$*"}' | \ + yq '.metadata.name = "$*"' | \ + yq '.spec.selector.matchLabels = {"test": "$*"}' | \ + yq '.spec.template.metadata.labels = {"test": "$*"}' | \ $(KUBECTL) apply -f - .PHONY: install-test-pod