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

refactor!: de-zarfify maru-runner #73

Merged
merged 28 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ee56e77
chore: de-zarfify maru-runner
Racer159 May 8, 2024
d54329c
fix some linting
Racer159 May 10, 2024
fd48372
fix env var handling
Racer159 May 10, 2024
be0cace
fix variable loading
Racer159 May 10, 2024
a266924
remove files and fix list all
Racer159 May 10, 2024
3f1c8c3
remove zarf completely
Racer159 May 14, 2024
98440da
fix lint and little errors
Racer159 May 14, 2024
9ac65de
fix some nice-to-haves
Racer159 May 14, 2024
b35aca3
switch variables to internal
Racer159 May 17, 2024
e11cb0a
switch variables to internal
Racer159 May 17, 2024
a2e2a68
unit tests target
ericwyles May 17, 2024
5203fde
remove zarf specific things
Racer159 May 17, 2024
b0a70e8
remove text template
Racer159 May 17, 2024
abef76b
switch variables to have generics
Racer159 May 17, 2024
3fcc592
resolve lint and Makefile *isms
Racer159 May 17, 2024
44718d3
segment runaction logic out of runner
Racer159 May 17, 2024
a34b491
fix actions test
Racer159 May 17, 2024
d2e5df0
add cmd mutation check in case they are already set
Racer159 May 20, 2024
c831651
fix schema
Racer159 May 20, 2024
5a30461
test schema workflow
Racer159 May 20, 2024
226222d
fix schema workflow
Racer159 May 20, 2024
a1891ba
fix schema
Racer159 May 20, 2024
cc7912d
remove zarf grype ignores
Racer159 May 20, 2024
4e8b002
add dependency review workflow
Racer159 May 20, 2024
e1a8865
update more zarf references
Racer159 May 20, 2024
7d26500
fix issue templates
Racer159 May 20, 2024
fc47b74
fix lints
Racer159 May 20, 2024
5107679
update to released exec
Racer159 May 21, 2024
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: possible-bug
labels: 'possible-bug 🐛'
assignees: ''
---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'enhancement'
labels: 'enhancement'
assignees: ''
---

Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/tech_debt.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Tech debt
about: Record something that should be investigated or refactored in the future.
title: ''
labels: 'tech-debt'
labels: 'tech-debt 💳'
assignees: ''
---

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

### Links to any relevant code

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

### Additional context

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Dependency Review
on: pull_request

permissions:
contents: read

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.4

- name: Dependency Review
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
2 changes: 1 addition & 1 deletion .github/workflows/test-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: ./.github/actions/golang

- name: Docs and schemas
run: "make schema test-schema"
run: make test-schema

- name: Save logs
if: always()
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test-unit-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit Tests
on:
pull_request:
paths-ignore:
- "**.md"
- "**.jpg"
- "**.png"
- "**.gif"
- "**.svg"
- "adr/**"
- "docs/**"
- "CODEOWNERS"
- "goreleaser.yml"

# Abort prior jobs in the same workflow / PR
concurrency:
group: unit-runner-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Setup golang
uses: ./.github/actions/golang

- name: Run unit tests
run: |
make test-unit
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
- linux
- darwin
ldflags:
- -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion={{.Tag}}' -X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf'
- -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion={{.Tag}}'
goarch:
- amd64
- arm64
Expand Down
5 changes: 0 additions & 5 deletions .grype.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
ignore:
# This vulnerability does not affect this project as we do not instantiate a rekor client
- vulnerability: GHSA-2h5h-59f5-c5x9

# This vulnerability does not affect this project as we do not instantiate a rekor client
- vulnerability: GHSA-frqx-jfcm-6jjr
37 changes: 32 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2023-Present The UDS Authors
# SPDX-FileCopyrightText: 2023-Present the Maru Authors

ARCH ?= amd64
CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"UnknownVersion")
BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion=$(CLI_VERSION)' \
-X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf'
BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/maru-runner/src/config.CLIVersion=$(CLI_VERSION)'
SRC_FILES ?= $(shell find . -type f -name "*.go")

BUILD_CLI_FOR_SYSTEM := build-cli
UNAME_S := $(shell uname -s)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_P),i386)
BUILD_CLI_FOR_SYSTEM := $(addsuffix -mac-intel,$(BUILD_CLI_FOR_SYSTEM))
endif
ifeq ($(UNAME_P),arm)
BUILD_CLI_FOR_SYSTEM := $(addsuffix -mac-apple,$(BUILD_CLI_FOR_SYSTEM))
endif
else ifeq ($(UNAME_S),Linux)
ifeq ($(UNAME_P),x86_64)
BUILD_CLI_FOR_SYSTEM := $(addsuffix -linux-amd,$(BUILD_CLI_FOR_SYSTEM))
endif
ifeq ($(UNAME_P),aarch64)
BUILD_CLI_FOR_SYSTEM := $(addsuffix -linux-arm,$(BUILD_CLI_FOR_SYSTEM))
endif
endif

.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}'

.PHONY: build
build: ## Build the CLI for the current machine's OS and architecture
$(MAKE) $(BUILD_CLI_FOR_SYSTEM)

build-cli-linux-amd: ## Build the CLI for Linux AMD64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(BUILD_ARGS)" -o build/maru main.go

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

.PHONY: test-unit
test-unit: ## Run unit tests
cd src/pkg && go test ./... -failfast -v -timeout 30m

.PHONY: test-e2e
test-e2e: ## Run End to End (e2e) tests
cd src/test/e2e && go test -failfast -v -timeout 30m

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

test-schema: ## Test if the schema has been modified
$(MAKE) schema
test-schema: schema ## Test if the schema has been modified
./hack/test-generate-schema.sh

clean: ## Clean up build artifacts
Expand Down
29 changes: 2 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
[![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)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/maru-runner/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/maru-runner)

Maru is a task runner that enables developers to automate builds and perform common shell tasks. It
uses [Zarf](https://zarf.dev/) under the hood to perform tasks and shares a syntax similar to `zarf.yaml` manifests.
Many [Zarf Actions features](https://docs.zarf.dev/ref/actions/) are also available in
the runner.
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`.
Many [Zarf Actions features](https://docs.zarf.dev/ref/actions/) are also available in the runner.

## Table of Contents

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

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.

### Files

The `files` key is used to copy local or remote files to the current working directory

```yaml
tasks:
- name: copy-local
files:
- source: /tmp/foo
target: foo
- name: copy-remote
files:
- source: https://cataas.com/cat
target: cat.jpeg
```

Files blocks can also use the following attributes:

- `executable`: boolean value indicating if the file is executable
- `shasum`: SHA string to verify the integrity of the file
- `symlinks`: list of strings referring to symlink the file to

### Wait

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