Skip to content

Commit 635060c

Browse files
Racer159ericwyles
andauthored
refactor!: de-zarfify maru-runner (#73)
## Description This PR removes Zarf as a dependency of Maru, and proposes the following breaking changes to the library API surface: 1. Creating a simple registration system for `./` prefixed apps 2. Not reaching into os.Env within library code (i.e. when processing `RUN_<VAR>`) This also proposes the following feature breaking changes: 1. Drop support for `files`. ## Related Issue Fixes #23 Fixes #60 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [X] Other (security config, docs update, etc) ## Checklist before merging - [X] Test, docs, adr added or updated as needed - [X] [Contributor Guide Steps](https://github.com/defenseunicorns/maru-runner/blob/main/CONTRIBUTING.md) followed --------- Co-authored-by: Eric Wyles <[email protected]>
1 parent 927c9c1 commit 635060c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1619
-3242
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Create a report to help us improve
44
title: ''
5-
labels: possible-bug
5+
labels: 'possible-bug 🐛'
66
assignees: ''
77
---
88

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature request
33
about: Suggest an idea for this project
44
title: ''
5-
labels: 'enhancement'
5+
labels: 'enhancement'
66
assignees: ''
77
---
88

.github/ISSUE_TEMPLATE/tech_debt.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Tech debt
33
about: Record something that should be investigated or refactored in the future.
44
title: ''
5-
labels: 'tech-debt'
5+
labels: 'tech-debt 💳'
66
assignees: ''
77
---
88

@@ -12,7 +12,7 @@ A clear and concise description of what should be changed/researched. Ex. This p
1212

1313
### Links to any relevant code
1414

15-
(optional) i.e. - <https://github.com/defenseunicorns/uds-template-capability/blob/main/README.md?plain=1#L1>
15+
(optional) i.e. - <https://github.com/defenseunicorns/maru-runner/blob/main/README.md?plain=1#L1>
1616

1717
### Additional context
1818

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Dependency Review
2+
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.4
13+
14+
- name: Dependency Review
15+
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2

.github/workflows/test-schema.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: ./.github/actions/golang
1717

1818
- name: Docs and schemas
19-
run: "make schema test-schema"
19+
run: make test-schema
2020

2121
- name: Save logs
2222
if: always()

.github/workflows/test-unit-pr.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- "**.md"
6+
- "**.jpg"
7+
- "**.png"
8+
- "**.gif"
9+
- "**.svg"
10+
- "adr/**"
11+
- "docs/**"
12+
- "CODEOWNERS"
13+
- "goreleaser.yml"
14+
15+
# Abort prior jobs in the same workflow / PR
16+
concurrency:
17+
group: unit-runner-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
26+
27+
- name: Setup golang
28+
uses: ./.github/actions/golang
29+
30+
- name: Run unit tests
31+
run: |
32+
make test-unit

.goreleaser.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ builds:
1414
- linux
1515
- darwin
1616
ldflags:
17-
- -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion={{.Tag}}' -X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf'
17+
- -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion={{.Tag}}'
1818
goarch:
1919
- amd64
2020
- arm64

.grype.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
ignore:
2-
# This vulnerability does not affect this project as we do not instantiate a rekor client
3-
- vulnerability: GHSA-2h5h-59f5-c5x9
4-
5-
# This vulnerability does not affect this project as we do not instantiate a rekor client
6-
- vulnerability: GHSA-frqx-jfcm-6jjr

Makefile

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# SPDX-FileCopyrightText: 2023-Present The UDS Authors
2+
# SPDX-FileCopyrightText: 2023-Present the Maru Authors
33

44
ARCH ?= amd64
55
CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"UnknownVersion")
6-
BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion=$(CLI_VERSION)' \
7-
-X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf'
6+
BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion=$(CLI_VERSION)'
7+
SRC_FILES ?= $(shell find . -type f -name "*.go")
8+
9+
BUILD_CLI_FOR_SYSTEM := build-cli
10+
UNAME_S := $(shell uname -s)
11+
UNAME_P := $(shell uname -p)
12+
ifeq ($(UNAME_S),Darwin)
13+
ifeq ($(UNAME_P),i386)
14+
BUILD_CLI_FOR_SYSTEM := $(addsuffix -mac-intel,$(BUILD_CLI_FOR_SYSTEM))
15+
endif
16+
ifeq ($(UNAME_P),arm)
17+
BUILD_CLI_FOR_SYSTEM := $(addsuffix -mac-apple,$(BUILD_CLI_FOR_SYSTEM))
18+
endif
19+
else ifeq ($(UNAME_S),Linux)
20+
ifeq ($(UNAME_P),x86_64)
21+
BUILD_CLI_FOR_SYSTEM := $(addsuffix -linux-amd,$(BUILD_CLI_FOR_SYSTEM))
22+
endif
23+
ifeq ($(UNAME_P),aarch64)
24+
BUILD_CLI_FOR_SYSTEM := $(addsuffix -linux-arm,$(BUILD_CLI_FOR_SYSTEM))
25+
endif
26+
endif
827

928
.PHONY: help
1029
help: ## Display this help information
1130
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
1231
| sort | awk 'BEGIN {FS = ":.*?## "}; \
1332
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1433

34+
.PHONY: build
35+
build: ## Build the CLI for the current machine's OS and architecture
36+
$(MAKE) $(BUILD_CLI_FOR_SYSTEM)
37+
1538
build-cli-linux-amd: ## Build the CLI for Linux AMD64
1639
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(BUILD_ARGS)" -o build/maru main.go
1740

@@ -24,14 +47,18 @@ build-cli-mac-intel: ## Build the CLI for Mac Intel
2447
build-cli-mac-apple: ## Build the CLI for Mac Apple
2548
GOOS=darwin GOARCH=arm64 go build -ldflags="$(BUILD_ARGS)" -o build/maru-mac-apple main.go
2649

50+
.PHONY: test-unit
51+
test-unit: ## Run unit tests
52+
cd src/pkg && go test ./... -failfast -v -timeout 30m
53+
54+
.PHONY: test-e2e
2755
test-e2e: ## Run End to End (e2e) tests
2856
cd src/test/e2e && go test -failfast -v -timeout 30m
2957

3058
schema: ## Update JSON schema for maru tasks
3159
./hack/generate-schema.sh
3260

33-
test-schema: ## Test if the schema has been modified
34-
$(MAKE) schema
61+
test-schema: schema ## Test if the schema has been modified
3562
./hack/test-generate-schema.sh
3663

3764
clean: ## Clean up build artifacts

README.md

+2-27
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
[![Build Status](https://img.shields.io/github/actions/workflow/status/defenseunicorns/maru-runner/release.yaml)](https://github.com/defenseunicorns/maru-runner/actions/workflows/release.yaml)
66
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/maru-runner/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/maru-runner)
77

8-
Maru is a task runner that enables developers to automate builds and perform common shell tasks. It
9-
uses [Zarf](https://zarf.dev/) under the hood to perform tasks and shares a syntax similar to `zarf.yaml` manifests.
10-
Many [Zarf Actions features](https://docs.zarf.dev/ref/actions/) are also available in
11-
the runner.
8+
Maru is a task runner that enables developers to automate builds and perform common shell tasks and shares a syntax similar to `zarf.yaml` `actions`.
9+
Many [Zarf Actions features](https://docs.zarf.dev/ref/actions/) are also available in the runner.
1210

1311
## Table of Contents
1412

@@ -20,7 +18,6 @@ the runner.
2018
- [Task](#task)
2119
- [Cmd](#cmd)
2220
- [Variables](#variables)
23-
- [Files](#files)
2421
- [Wait](#wait)
2522
- [Includes](#includes)
2623
- [Task Inputs and Reusable Tasks](#task-inputs-and-reusable-tasks)
@@ -260,28 +257,6 @@ Variable precedence is as follows, from least to most specific:
260257

261258
That is to say, variables set via the `--set` flag take precedence over all other variables. The exception to this precedence order is when a variable is modified using `setVariable`, which will change the value of the variable during runtime.
262259

263-
### Files
264-
265-
The `files` key is used to copy local or remote files to the current working directory
266-
267-
```yaml
268-
tasks:
269-
- name: copy-local
270-
files:
271-
- source: /tmp/foo
272-
target: foo
273-
- name: copy-remote
274-
files:
275-
- source: https://cataas.com/cat
276-
target: cat.jpeg
277-
```
278-
279-
Files blocks can also use the following attributes:
280-
281-
- `executable`: boolean value indicating if the file is executable
282-
- `shasum`: SHA string to verify the integrity of the file
283-
- `symlinks`: list of strings referring to symlink the file to
284-
285260
### Wait
286261

287262
The `wait`key is used to block execution while waiting for a resource, including network responses and K8s operations

0 commit comments

Comments
 (0)