From 43b8dee131d5a5e8a92657bef226d088218ea082 Mon Sep 17 00:00:00 2001 From: unclegedd Date: Thu, 9 May 2024 17:06:07 -0500 Subject: [PATCH] chore: swap Makefile for Maru --- .github/workflows/nightly-ghcr.yaml | 4 +- .github/workflows/nightly-uds-core.yaml | 2 +- .github/workflows/release.yaml | 4 +- .github/workflows/scan-codeql.yaml | 2 +- .github/workflows/test-e2e-pr.yaml | 4 +- .github/workflows/test-schema.yaml | 2 +- .github/workflows/test-unit.yaml | 2 +- Makefile | 72 --------------------- hack/test-generate-schema.sh | 1 + src/pkg/bundle/deploy_test.go | 3 + src/test/e2e/main_test.go | 3 +- tasks.yaml | 83 +++++++++++++++++++++++++ tasks/dev.yaml | 19 ++++++ tasks/schema.yaml | 14 +++++ tasks/tests.yaml | 38 +++++++++++ zarf.schema.json | 35 +++++++++++ 16 files changed, 204 insertions(+), 84 deletions(-) delete mode 100644 Makefile create mode 100644 tasks.yaml create mode 100644 tasks/dev.yaml create mode 100644 tasks/schema.yaml create mode 100644 tasks/tests.yaml diff --git a/.github/workflows/nightly-ghcr.yaml b/.github/workflows/nightly-ghcr.yaml index 0f69ec9a..a507c055 100644 --- a/.github/workflows/nightly-ghcr.yaml +++ b/.github/workflows/nightly-ghcr.yaml @@ -26,7 +26,7 @@ jobs: uses: ./.github/actions/golang - name: Build UDS-CLI binary - run: make build-cli-linux-amd ARCH=amd64 + run: uds run build-cli-linux-amd - name: Setup K3d uses: ./.github/actions/k3d @@ -40,7 +40,7 @@ jobs: - name: Run e2e tests run: | - make test-e2e-ghcr + uds run test:test-e2e-ghcr env: GITHUB_TOKEN: secrets.GITHUB_TOKEN diff --git a/.github/workflows/nightly-uds-core.yaml b/.github/workflows/nightly-uds-core.yaml index 225fd991..ac83fe2e 100644 --- a/.github/workflows/nightly-uds-core.yaml +++ b/.github/workflows/nightly-uds-core.yaml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 - name: Build UDS-CLI binary - run: make build-cli-linux-amd ARCH=amd64 + run: uds run build-cli-linux-amd - name: Make UDS-CLI executable run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ff802e48..b5e21b98 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,7 +25,7 @@ jobs: - name: Build CLI run: | - make build-cli-linux-amd + uds run build-cli-linux-amd # Upload the contents of the build directory for later stages to use - name: Upload build artifacts @@ -72,7 +72,7 @@ jobs: - name: Run e2e tests run: | - make test-e2e + uds run test:test-e2e env: GITHUB_TOKEN: secrets.GITHUB_TOKEN diff --git a/.github/workflows/scan-codeql.yaml b/.github/workflows/scan-codeql.yaml index 9e2a91fc..b9b095f3 100644 --- a/.github/workflows/scan-codeql.yaml +++ b/.github/workflows/scan-codeql.yaml @@ -42,7 +42,7 @@ jobs: uses: ./.github/actions/golang - name: Build UDS CLI - run: make build-cli-linux-amd + run: uds run build-cli-linux-amd - name: Initialize CodeQL uses: github/codeql-action/init@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 diff --git a/.github/workflows/test-e2e-pr.yaml b/.github/workflows/test-e2e-pr.yaml index a5cae0b6..0e4bf172 100644 --- a/.github/workflows/test-e2e-pr.yaml +++ b/.github/workflows/test-e2e-pr.yaml @@ -31,14 +31,14 @@ jobs: uses: ./.github/actions/golang - name: Build UDS-CLI binary - run: make build-cli-linux-amd ARCH=amd64 + run: uds run build-cli-linux-amd - name: Setup K3d uses: ./.github/actions/k3d - name: Run e2e tests run: | - make test-e2e-no-ghcr-write + uds run test:test-e2e-no-ghcr-write - name: Save logs if: always() diff --git a/.github/workflows/test-schema.yaml b/.github/workflows/test-schema.yaml index 0fc71d44..9bcdb13f 100644 --- a/.github/workflows/test-schema.yaml +++ b/.github/workflows/test-schema.yaml @@ -16,7 +16,7 @@ jobs: uses: ./.github/actions/golang - name: Docs and schemas - run: "make schema test-schema" + run: uds run schema:schema schema:test-schema - name: Save logs if: always() diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index c5f257da..56e9fa7e 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -31,7 +31,7 @@ jobs: uses: ./.github/actions/golang - name: Run unit tests - run: make test-unit + run: uds run test:test-unit - name: Save logs if: always() diff --git a/Makefile b/Makefile deleted file mode 100644 index b663ca74..00000000 --- a/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# SPDX-FileCopyrightText: 2023-Present The UDS Authors - -ARCH ?= amd64 -CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"UnknownVersion") -K9S_VERSION=$(shell go list -f '{{.Version}}' -m github.com/derailed/k9s) -CRANE_VERSION=$(shell go list -f '{{.Version}}' -m github.com/google/go-containerregistry) -SYFT_VERSION=$(shell go list -f '{{.Version}}' -m github.com/anchore/syft) -ARCHIVER_VERSION=$(shell go list -f '{{.Version}}' -m github.com/mholt/archiver/v3) -HELM_VERSION=$(shell go list -f '{{.Version}}' -m helm.sh/helm/v3) -BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/uds-cli/src/config.CLIVersion=$(CLI_VERSION)' \ - -X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf' \ - -X 'github.com/derailed/k9s/cmd.version=$(K9S_VERSION)' \ - -X 'github.com/google/go-containerregistry/cmd/crane/cmd.Version=$(CRANE_VERSION)' \ - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.syftVersion=$(SYFT_VERSION)' \ - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.archiverVersion=$(ARCHIVER_VERSION)' \ - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.helmVersion=$(HELM_VERSION)' - -.PHONY: help -help: ## Display this help information - @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | sort | awk 'BEGIN {FS = ":.*?## "}; \ - {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -build-cli-linux-amd: ## Build the CLI for Linux AMD64 - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(BUILD_ARGS)" -o build/uds main.go - -build-cli-linux-arm: ## Build the CLI for Linux ARM64 - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(BUILD_ARGS)" -o build/uds-arm main.go - -build-cli-mac-intel: ## Build the CLI for Mac Intel - GOOS=darwin GOARCH=amd64 go build -ldflags="$(BUILD_ARGS)" -o build/uds-mac-intel main.go - -build-cli-mac-apple: ## Build the CLI for Mac Apple - GOOS=darwin GOARCH=arm64 go build -ldflags="$(BUILD_ARGS)" -o build/uds-mac-apple main.go - -test-unit: ## Run Unit Tests - cd src/pkg && go test ./... -failfast -v -timeout 5m - -test-e2e: ## Run End to End (e2e) tests - cd src/test/e2e && go test -failfast -v -timeout 30m - -test-e2e-ghcr: ## Run End to End (e2e) tests with GHCR (contains writes) - cd src/test/e2e && go test -failfast -v -timeout 30m -run ".*GHCR.*" - -test-e2e-no-ghcr-write: ## Run End to End (e2e) tests without GHCR - cd src/test/e2e && go test -failfast -v -timeout 30m -skip ".*GHCR.*" - -test-e2e-runner: ## Run End to End (e2e) tests for task runner only - cd src/test/e2e && go test -failfast -v -timeout 30m -run TestTaskRunner - -schema: ## Update JSON schema for uds-bundle.yaml - ./hack/generate-schema.sh - -test-schema: ## Test if the schema has been modified - $(MAKE) schema - ./hack/test-generate-schema.sh - -local-registry: ## Run a local docker registry - docker run -p 5000:5000 --restart=always --name registry registry:2 - -clean: ## Clean up build artifacts - rm -rf build - -clean-test-artifacts: ## removes bundles and zarf packages that have been created from previous test runs - find src/test -type f -name '*.tar.zst' -delete - -push-test-artifacts: ## Push artifacts that UDS CLI tests rely on to GHCR - cd hack && ./push-test-artifacts.sh - -lint: ## Run golangci-lint on the project - golangci-lint run ./src/... diff --git a/hack/test-generate-schema.sh b/hack/test-generate-schema.sh index 835e420c..5cd42e4d 100755 --- a/hack/test-generate-schema.sh +++ b/hack/test-generate-schema.sh @@ -11,6 +11,7 @@ check_git_status() { } check_git_status uds.schema.json +check_git_status zarf.schema.json check_git_status tasks.schema.json exit 0 diff --git a/src/pkg/bundle/deploy_test.go b/src/pkg/bundle/deploy_test.go index 3cf07c4a..6658f710 100644 --- a/src/pkg/bundle/deploy_test.go +++ b/src/pkg/bundle/deploy_test.go @@ -227,6 +227,9 @@ func TestLoadVariablesPrecedence(t *testing.T) { // Run test cases for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + // unset arch var that gets applied automatically when doing 'uds run' so it doesn't get in the way + os.Unsetenv("UDS_ARCH") + // Set for select test cases to test precedence of env vars os.Unsetenv("UDS_FOO") if tc.loadEnvVar { diff --git a/src/test/e2e/main_test.go b/src/test/e2e/main_test.go index b20e908e..a15b5758 100644 --- a/src/test/e2e/main_test.go +++ b/src/test/e2e/main_test.go @@ -68,8 +68,7 @@ func doAllTheThings(m *testing.M) (int, error) { e2e.ApplianceModeKeep = os.Getenv(applianceModeKeepEnvVar) == "true" e2e.RunClusterTests = os.Getenv(skipK8sEnvVar) != "true" - // Validate that the UDS binary exists. If it doesn't that means the dev hasn't built it, usually by running - // `make build-cli` + // Validate that the UDS binary exists. If it doesn't that means the dev hasn't built it _, err = os.Stat(e2e.UDSBinPath) if err != nil { return 1, fmt.Errorf("zarf binary %s not found", e2e.UDSBinPath) diff --git a/tasks.yaml b/tasks.yaml new file mode 100644 index 00000000..35b1a57b --- /dev/null +++ b/tasks.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2023-Present The UDS Authors + +includes: + - test: tasks/tests.yaml + - schema: tasks/schema.yaml + +variables: + - name: K9S_VERSION + - name: CRANE_VERSION + - name: SYFT_VERSION + - name: ARCHIVER_VERSION + - name: HELM_VERSION + - name: CLI_VERSION + - name: BUILD_ARGS + +tasks: + # build tasks + - name: get-versions + description: gets versions of UDS CLI + vendored tools + actions: + - cmd: go list -f '{{.Version}}' -m github.com/derailed/k9s + setVariables: + - name: K9S_VERSION + - cmd: go list -f '{{.Version}}' -m github.com/anchore/syft + setVariables: + - name: SYFT_VERSION + - cmd: go list -f '{{.Version}}' -m github.com/google/go-containerregistry + setVariables: + - name: CRANE_VERSION + - cmd: go list -f '{{.Version}}' -m github.com/mholt/archiver/v3 + setVariables: + - name: ARCHIVER_VERSION + - cmd: go list -f '{{.Version}}' -m helm.sh/helm/v3 + setVariables: + - name: HELM_VERSION + - cmd: git describe --tags 2>/dev/null || echo "UnknownVersion" + setVariables: + - name: CLI_VERSION + + - name: build-args + description: generates the build args for building UDS CLI + actions: + - cmd: | + cat <