From 43b8dee131d5a5e8a92657bef226d088218ea082 Mon Sep 17 00:00:00 2001 From: unclegedd Date: Thu, 9 May 2024 17:06:07 -0500 Subject: [PATCH 1/7] 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 < Date: Thu, 9 May 2024 17:29:54 -0500 Subject: [PATCH 2/7] try using brew to install uds cli --- .github/actions/install-uds-cli/action.yaml | 13 +++++++++++++ .github/workflows/nightly-ghcr.yaml | 3 +++ .github/workflows/nightly-uds-core.yaml | 6 ++++++ .github/workflows/release.yaml | 5 ++++- .github/workflows/scan-codeql.yaml | 3 +++ .github/workflows/test-e2e-pr.yaml | 3 +++ .github/workflows/test-schema.yaml | 5 ++++- .github/workflows/test-unit.yaml | 3 +++ tasks/schema.yaml | 2 +- 9 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .github/actions/install-uds-cli/action.yaml diff --git a/.github/actions/install-uds-cli/action.yaml b/.github/actions/install-uds-cli/action.yaml new file mode 100644 index 00000000..85468f8f --- /dev/null +++ b/.github/actions/install-uds-cli/action.yaml @@ -0,0 +1,13 @@ +name: Install UDS CLI +description: installs uds-cli from brew +runs: + using: composite + steps: + - name: Set up Homebrew + uses: Homebrew/actions/setup-homebrew@4b34604e75af8f8b23b454f0b5ffb7c5d8ce0056 # master + + - name: Install UDS CLI + shell: bash + run: | + brew tap defenseunicorns/tap + brew install uds diff --git a/.github/workflows/nightly-ghcr.yaml b/.github/workflows/nightly-ghcr.yaml index a507c055..af4d193e 100644 --- a/.github/workflows/nightly-ghcr.yaml +++ b/.github/workflows/nightly-ghcr.yaml @@ -25,6 +25,9 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Build UDS-CLI binary run: uds run build-cli-linux-amd diff --git a/.github/workflows/nightly-uds-core.yaml b/.github/workflows/nightly-uds-core.yaml index ac83fe2e..e8f3705b 100644 --- a/.github/workflows/nightly-uds-core.yaml +++ b/.github/workflows/nightly-uds-core.yaml @@ -24,6 +24,12 @@ jobs: with: fetch-depth: 0 + - name: Setup golang + uses: ./.github/actions/golang + + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Build UDS-CLI binary run: uds run build-cli-linux-amd diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b5e21b98..a8cfcbbc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,6 +23,9 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Build CLI run: | uds run build-cli-linux-amd @@ -72,7 +75,7 @@ jobs: - name: Run e2e tests run: | - uds run test:test-e2e + build/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 b9b095f3..882c5528 100644 --- a/.github/workflows/scan-codeql.yaml +++ b/.github/workflows/scan-codeql.yaml @@ -41,6 +41,9 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Build UDS CLI run: uds run build-cli-linux-amd diff --git a/.github/workflows/test-e2e-pr.yaml b/.github/workflows/test-e2e-pr.yaml index 0e4bf172..997e88d4 100644 --- a/.github/workflows/test-e2e-pr.yaml +++ b/.github/workflows/test-e2e-pr.yaml @@ -30,6 +30,9 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Build UDS-CLI binary run: uds run build-cli-linux-amd diff --git a/.github/workflows/test-schema.yaml b/.github/workflows/test-schema.yaml index 9bcdb13f..910ecab2 100644 --- a/.github/workflows/test-schema.yaml +++ b/.github/workflows/test-schema.yaml @@ -15,8 +15,11 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Docs and schemas - run: uds run schema:schema schema:test-schema + run: uds run schema:test-schema - name: Save logs if: always() diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index 56e9fa7e..f238289b 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -30,6 +30,9 @@ jobs: - name: Setup golang uses: ./.github/actions/golang + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli + - name: Run unit tests run: uds run test:test-unit diff --git a/tasks/schema.yaml b/tasks/schema.yaml index 3c14effc..b1e9ee28 100644 --- a/tasks/schema.yaml +++ b/tasks/schema.yaml @@ -10,5 +10,5 @@ tasks: - name: test-schema description: tests if the schema has been modified actions: - - cmd: ./uds run schema + - task: schema - cmd: ./hack/test-generate-schema.sh From d1679d223cb8a781cb475f77f5dbee74aab0ce4f Mon Sep 17 00:00:00 2001 From: unclegedd Date: Fri, 10 May 2024 07:10:41 -0500 Subject: [PATCH 3/7] use built UDS binary where appropriate, update docs --- .github/workflows/nightly-ghcr.yaml | 2 +- .github/workflows/test-e2e-pr.yaml | 2 +- CONTRIBUTING.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightly-ghcr.yaml b/.github/workflows/nightly-ghcr.yaml index af4d193e..b0056ec1 100644 --- a/.github/workflows/nightly-ghcr.yaml +++ b/.github/workflows/nightly-ghcr.yaml @@ -43,7 +43,7 @@ jobs: - name: Run e2e tests run: | - uds run test:test-e2e-ghcr + build/uds run test:test-e2e-ghcr env: GITHUB_TOKEN: secrets.GITHUB_TOKEN diff --git a/.github/workflows/test-e2e-pr.yaml b/.github/workflows/test-e2e-pr.yaml index 997e88d4..8af887ad 100644 --- a/.github/workflows/test-e2e-pr.yaml +++ b/.github/workflows/test-e2e-pr.yaml @@ -41,7 +41,7 @@ jobs: - name: Run e2e tests run: | - uds run test:test-e2e-no-ghcr-write + build/uds run test:test-e2e-no-ghcr-write - name: Save logs if: always() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0dc58758..49d6f04a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ Please ensure there is a Gitub issue for your proposed change, this helps the UD 1. **Open a PR** against the `main` branch of this repo ### Building the app -Today, we use `make` to build UDS CLI. To build the app, check out the [Makefile](Makefile) and find the appropriate build target for your system, and run it from the root of the repo (ex. `make build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running the E2E tests). +We use UDS CLI's `run` feature (ie. vendored [Maru](https://github.com/defenseunicorns/maru-runner)) to build UDS CLI; this means that you'll need to have the `uds` binary [installed](./README.md#install) on your system in order to build the app. To build the app, check out the [tasks](tasks.yaml) with `uds run --list`, find the appropriate build target for your system, and run it from the root of the repo (ex. `uds run build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running [E2E Tests](#running-tests). ### Testing @@ -54,7 +54,7 @@ E2E tests reside in the `src/test/e2e` directory. They use bundles located in th We prefer to use Testify's [require](https://github.com/stretchr/testify/tree/master/require) package for assertions in tests. This package provides a rich set of assertion functions that make tests more readable and easier to debug. See other tests in this repo for examples. #### Running Tests -- **Unit Tests**: To run unit tests, run `make test-unit` from the root of the repo. This will run all unit tests in the `src` directory. +- **Unit Tests**: To run unit tests, run `uds run test:test-unit` from the root of the repo. This will run all unit tests in the `src` directory. -- **E2E Tests**: To run E2E tests, you'll need build UDS CLI locally, and re-build any time you make a change to the source code; this is because the binary in the `build` directory is used to drive the tests. To run the entire suite of E2E tests locally, run `make test-e2e-no-ghcr-write` (note that this intentionally skips the tests that involve writing to GHCR). +- **E2E Tests**: To run E2E tests, you'll need build UDS CLI locally, and re-build any time you make a change to the source code; this is because the binary in the `build` directory is used to drive the tests. To run the entire suite of E2E tests locally, run `uds run test:test-e2e-no-ghcr-write` (note that this intentionally skips the tests that involve writing to GHCR). From a77af9f41c3c9ea8b72f7e231e5beccfc67e561c Mon Sep 17 00:00:00 2001 From: unclegedd Date: Fri, 10 May 2024 07:20:53 -0500 Subject: [PATCH 4/7] more docs --- CONTRIBUTING.md | 19 ++++++++++++++----- README.md | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 49d6f04a..fdd2ca55 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,13 @@ Welcome :unicorn: to the UDS CLI! If you'd like to contribute, please reach out Below are some notes on our core software design philosophies that should help guide contributors. +## Table of Contents +1. [Code Quality and Standards](#code-quality-and-standards) +1. [How to Contribute](#how-to-contribute) + - [Building the app](#building-the-app) + - [Pre-Commit Hooks and Linting](#pre-commit-hooks-and-linting) + - [Testing](#testing) + ## Code Quality and Standards Fundamentally, software engineering is a communication problem; we write code for each other, not a computer. When working on this project (or any project!) keep your fellow humans in mind and write clearly and concisely. Below are some general guidelines for code quality and standards that make UDS CLI :sparkles: @@ -12,10 +19,7 @@ Fundamentally, software engineering is a communication problem; we write code fo - **Prefer readability over being clever**: We have a strong preference for code readabilty in UDS CLI. Specifically, this means things like: naming variables appropriately, keeping functions to a reasonable size and avoiding complicated solutions when simple ones exist. -- **User experience is paramount**: UDS CLI doesn't have a pretty UI (yet), but the core user-centered design principles that apply when building a frontend also apply to this CLI tool. First and foremost, features in UDS CLI should enhance workflows and make life easier for end users; if a feature doesn't accomplish this, it will be dropped. - -### Pre-Commit Hooks and Linting -In this repo you can optionally use [pre-commit](https://pre-commit.com/) hooks for automated validation and linting, but if not CI will run these checks for you. +- **User experience is paramount**: UDS CLI doesn't have a pretty UI (yet), but the core user-centered design principles that apply when building a frontend also apply to this CLI tool. First and foremost, features in UDS CLI should enhance workflows and make life easier for end users; if a feature doesn't accomplish this, it will be dropped. ### Continuous Delivery Continuous Delivery is core to our development philosophy. Check out [https://minimumcd.org](https://minimumcd.org/) for a good baseline agreement on what that means. @@ -38,7 +42,12 @@ Please ensure there is a Gitub issue for your proposed change, this helps the UD 1. **Open a PR** against the `main` branch of this repo ### Building the app -We use UDS CLI's `run` feature (ie. vendored [Maru](https://github.com/defenseunicorns/maru-runner)) to build UDS CLI; this means that you'll need to have the `uds` binary [installed](./README.md#install) on your system in order to build the app. To build the app, check out the [tasks](tasks.yaml) with `uds run --list`, find the appropriate build target for your system, and run it from the root of the repo (ex. `uds run build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running [E2E Tests](#running-tests). +We use UDS CLI's `run` feature (ie. vendored [Maru](https://github.com/defenseunicorns/maru-runner)) to build UDS CLI; this means that you'll need to have the `uds` binary [installed](./README.md#install) on your system in order to build the app. + +To build the app, check out the [tasks](tasks.yaml) with `uds run --list`, find the appropriate build target for your system, and run it from the root of the repo (ex. `uds run build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running [E2E Tests](#running-tests). + +### Pre-Commit Hooks and Linting +In this repo you can optionally use [pre-commit](https://pre-commit.com/) hooks for automated validation and linting, but if not CI will run these checks for you ### Testing diff --git a/README.md b/README.md index ccf36dd4..9d362e7c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ ## Table of Contents 1. [Install](#install) +1. [Contributing](CONTRIBUTING.md) 1. [Quickstart](#quickstart) - [Create](#bundle-create) - [Deploy](#bundle-deploy) @@ -34,6 +35,8 @@ brew tap defenseunicorns/tap && brew install uds ``` UDS CLI Binaries are also included with each [Github Release](https://github.com/defenseunicorns/uds-cli/releases) +## Contributing +Build instructions and contributing docs are located in [CONTRIBUTING.md](CONTRIBUTING.md). ## Quickstart The UDS-CLI's flagship feature is deploying multiple, independent Zarf packages. To create a `UDSBundle` of Zarf packages, create a `uds-bundle.yaml` file like so: From 0fbbc423e446cffc48c389bc85a5c1b35ea78cfa Mon Sep 17 00:00:00 2001 From: unclegedd Date: Fri, 10 May 2024 10:35:08 -0500 Subject: [PATCH 5/7] remove vars and test prefix --- .github/workflows/nightly-ghcr.yaml | 2 +- .github/workflows/release.yaml | 2 +- .github/workflows/test-e2e-pr.yaml | 2 +- .github/workflows/test-unit.yaml | 2 +- CONTRIBUTING.md | 4 ++-- tasks.yaml | 9 --------- tasks/tests.yaml | 10 +++++----- 7 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nightly-ghcr.yaml b/.github/workflows/nightly-ghcr.yaml index b0056ec1..2fb6ba62 100644 --- a/.github/workflows/nightly-ghcr.yaml +++ b/.github/workflows/nightly-ghcr.yaml @@ -43,7 +43,7 @@ jobs: - name: Run e2e tests run: | - build/uds run test:test-e2e-ghcr + build/uds run test:e2e-ghcr env: GITHUB_TOKEN: secrets.GITHUB_TOKEN diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a8cfcbbc..ff0601e0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -75,7 +75,7 @@ jobs: - name: Run e2e tests run: | - build/uds run test:test-e2e + build/uds run test:e2e env: GITHUB_TOKEN: secrets.GITHUB_TOKEN diff --git a/.github/workflows/test-e2e-pr.yaml b/.github/workflows/test-e2e-pr.yaml index 8af887ad..fecb2381 100644 --- a/.github/workflows/test-e2e-pr.yaml +++ b/.github/workflows/test-e2e-pr.yaml @@ -41,7 +41,7 @@ jobs: - name: Run e2e tests run: | - build/uds run test:test-e2e-no-ghcr-write + build/uds run test:e2e-no-ghcr-write - name: Save logs if: always() diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index f238289b..8fef8905 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -34,7 +34,7 @@ jobs: uses: ./.github/actions/install-uds-cli - name: Run unit tests - run: uds run test:test-unit + run: uds run test:unit - name: Save logs if: always() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fdd2ca55..639a8f03 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ E2E tests reside in the `src/test/e2e` directory. They use bundles located in th We prefer to use Testify's [require](https://github.com/stretchr/testify/tree/master/require) package for assertions in tests. This package provides a rich set of assertion functions that make tests more readable and easier to debug. See other tests in this repo for examples. #### Running Tests -- **Unit Tests**: To run unit tests, run `uds run test:test-unit` from the root of the repo. This will run all unit tests in the `src` directory. +- **Unit Tests**: To run unit tests, run `uds run test:unit` from the root of the repo. This will run all unit tests in the `src` directory. -- **E2E Tests**: To run E2E tests, you'll need build UDS CLI locally, and re-build any time you make a change to the source code; this is because the binary in the `build` directory is used to drive the tests. To run the entire suite of E2E tests locally, run `uds run test:test-e2e-no-ghcr-write` (note that this intentionally skips the tests that involve writing to GHCR). +- **E2E Tests**: To run E2E tests, you'll need build UDS CLI locally, and re-build any time you make a change to the source code; this is because the binary in the `build` directory is used to drive the tests. To run the entire suite of E2E tests locally, run `uds run test:e2e-no-ghcr-write` (note that this intentionally skips the tests that involve writing to GHCR). diff --git a/tasks.yaml b/tasks.yaml index 35b1a57b..0cef8bcf 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -5,15 +5,6 @@ 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 diff --git a/tasks/tests.yaml b/tasks/tests.yaml index a7e80020..606c967b 100644 --- a/tasks/tests.yaml +++ b/tasks/tests.yaml @@ -2,27 +2,27 @@ # SPDX-FileCopyrightText: 2023-Present The UDS Authors tasks: - - name: test-unit + - name: unit description: run all the unit tests actions: - cmd: cd src/pkg && go test ./... -failfast -v -timeout 5m - - name: test-e2e + - name: e2e description: run all the e2e tests actions: - cmd: cd src/test/e2e && go test -failfast -v -timeout 30m - - name: test-e2e-no-ghcr-write + - name: e2e-no-ghcr-write description: run e2e tests without writing to GHCR actions: - cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -skip ".*GHCR.*" - - name: test-e2e-ghcr + - name: e2e-ghcr description: run e2e tests that write to GHCR actions: - cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -run ".*GHCR.*" - - name: test-e2e-runner + - name: e2e-runner description: run e2e tests for task runner only actions: - cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -run TestTaskRunner From 39cae590baf4cc14d36889058133a6756cd7b1e8 Mon Sep 17 00:00:00 2001 From: unclegedd Date: Fri, 10 May 2024 10:38:51 -0500 Subject: [PATCH 6/7] list all --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 639a8f03..517a04f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ Please ensure there is a Gitub issue for your proposed change, this helps the UD ### Building the app We use UDS CLI's `run` feature (ie. vendored [Maru](https://github.com/defenseunicorns/maru-runner)) to build UDS CLI; this means that you'll need to have the `uds` binary [installed](./README.md#install) on your system in order to build the app. -To build the app, check out the [tasks](tasks.yaml) with `uds run --list`, find the appropriate build target for your system, and run it from the root of the repo (ex. `uds run build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running [E2E Tests](#running-tests). +To build the app, check out the [tasks](tasks.yaml) with `uds run --list-all`, find the appropriate build target for your system, and run it from the root of the repo (ex. `uds run build-cli-mac-apple`). This will create a binary in the `build` directory that you can use to test your changes (note that this binary is automatically used when running [E2E Tests](#running-tests). ### Pre-Commit Hooks and Linting In this repo you can optionally use [pre-commit](https://pre-commit.com/) hooks for automated validation and linting, but if not CI will run these checks for you From 90bd24d5a7521298b92313518b44c54c99b030d8 Mon Sep 17 00:00:00 2001 From: unclegedd Date: Fri, 10 May 2024 17:11:57 -0500 Subject: [PATCH 7/7] address pr comments --- tasks.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks.yaml b/tasks.yaml index 0cef8bcf..047cdd72 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -4,6 +4,7 @@ includes: - test: tasks/tests.yaml - schema: tasks/schema.yaml + - dev: tasks/dev.yaml tasks: # build tasks @@ -11,21 +12,27 @@ tasks: description: gets versions of UDS CLI + vendored tools actions: - cmd: go list -f '{{.Version}}' -m github.com/derailed/k9s + mute: true setVariables: - name: K9S_VERSION - cmd: go list -f '{{.Version}}' -m github.com/anchore/syft + mute: true setVariables: - name: SYFT_VERSION - cmd: go list -f '{{.Version}}' -m github.com/google/go-containerregistry + mute: true setVariables: - name: CRANE_VERSION - cmd: go list -f '{{.Version}}' -m github.com/mholt/archiver/v3 + mute: true setVariables: - name: ARCHIVER_VERSION - cmd: go list -f '{{.Version}}' -m helm.sh/helm/v3 + mute: true setVariables: - name: HELM_VERSION - cmd: git describe --tags 2>/dev/null || echo "UnknownVersion" + mute: true setVariables: - name: CLI_VERSION