Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: swap Makefile for Maru #602

Merged
merged 7 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/actions/install-uds-cli/action.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions .github/workflows/nightly-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ jobs:
- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

mjnagel marked this conversation as resolved.
Show resolved Hide resolved
- 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
Expand All @@ -40,7 +43,7 @@ jobs:

- name: Run e2e tests
run: |
make test-e2e-ghcr
build/uds run test:test-e2e-ghcr
env:
GITHUB_TOKEN: secrets.GITHUB_TOKEN

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/nightly-uds-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ 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: make build-cli-linux-amd ARCH=amd64
run: uds run build-cli-linux-amd

- name: Make UDS-CLI executable
run: |
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ jobs:
- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

- 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
Expand Down Expand Up @@ -72,7 +75,7 @@ jobs:

- name: Run e2e tests
run: |
make test-e2e
build/uds run test:test-e2e
env:
GITHUB_TOKEN: secrets.GITHUB_TOKEN

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/scan-codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ jobs:
- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

- 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
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test-e2e-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ jobs:
- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

- 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
build/uds run test:test-e2e-no-ghcr-write

- name: Save logs
if: always()
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "make schema test-schema"
run: uds run schema:test-schema

- name: Save logs
if: always()
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

- name: Run unit tests
run: make test-unit
run: uds run test:test-unit

- name: Save logs
if: always()
Expand Down
23 changes: 16 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand All @@ -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
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).

### 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

Expand All @@ -54,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 `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).
72 changes: 0 additions & 72 deletions Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## Table of Contents

1. [Install](#install)
1. [Contributing](CONTRIBUTING.md)
1. [Quickstart](#quickstart)
- [Create](#bundle-create)
- [Deploy](#bundle-deploy)
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions hack/test-generate-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/pkg/bundle/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
83 changes: 83 additions & 0 deletions tasks.yaml
Original file line number Diff line number Diff line change
@@ -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
UncleGedd marked this conversation as resolved.
Show resolved Hide resolved

variables:
UncleGedd marked this conversation as resolved.
Show resolved Hide resolved
- 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
UncleGedd marked this conversation as resolved.
Show resolved Hide resolved

- name: build-args
description: generates the build args for building UDS CLI
actions:
- cmd: |
cat <<EOF
-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}'
EOF
setVariables:
- name: BUILD_ARGS

- name: build-cli-linux-amd
description: build the CLI for Linux AMD64
actions:
- task: get-versions
- task: build-args
- cmd: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="${BUILD_ARGS}" -o build/uds main.go

- name: build-cli-linux-arm
description: build the CLI for Linux ARM64
actions:
- task: get-versions
- task: build-args
- cmd: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="${BUILD_ARGS}" -o build/uds-arm main.go

- name: build-cli-mac-intel
description: build the CLI for Mac Intel
actions:
- task: get-versions
- task: build-args
- cmd: GOOS=darwin GOARCH=amd64 go build -ldflags="${BUILD_ARGS}" -o build/uds-mac-intel main.go

- name: build-cli-mac-apple
description: build the CLI for Mac Apple
actions:
- task: get-versions
- task: build-args
- cmd: GOOS=darwin GOARCH=arm64 go build -ldflags="${BUILD_ARGS}" -o build/uds-mac-apple main.go
Loading
Loading