Skip to content

Commit

Permalink
chore: swap Makefile for Maru
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd committed May 9, 2024
1 parent 96aaaaa commit 43b8dee
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nightly-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-uds-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scan-codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-e2e-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
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: uds run schema:schema schema:test-schema

- name: Save logs
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
72 changes: 0 additions & 72 deletions Makefile

This file was deleted.

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

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 <<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
19 changes: 19 additions & 0 deletions tasks/dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2023-Present The UDS Authors

tasks:
- name: lint
description: runs the linter (requires golangci-lint)
actions:
- cmd: golangci-lint run ./src/...

- name: clean
description: removes the build dir
actions:
- cmd: rm -rf build

- name: local-registry
description: run a local docker registry
actions:
- cmd: |
docker run -p 5000:5000 --restart=always --name registry registry:2
14 changes: 14 additions & 0 deletions tasks/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2023-Present The UDS Authors

tasks:
- name: schema
description: updates the JSON schema
actions:
- cmd: ./hack/generate-schema.sh

- name: test-schema
description: tests if the schema has been modified
actions:
- cmd: ./uds run schema
- cmd: ./hack/test-generate-schema.sh
38 changes: 38 additions & 0 deletions tasks/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2023-Present The UDS Authors

tasks:
- name: test-unit
description: run all the unit tests
actions:
- cmd: cd src/pkg && go test ./... -failfast -v -timeout 5m

- name: test-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
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
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
description: run e2e tests for task runner only
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -run TestTaskRunner

- name: push-test-artifacts
description: push artifacts that UDS CLI tests rely on to GHCR
actions:
- cmd: ./hack/push-test-artifacts.sh

- name: clean-test-artifacts
description: removes bundles and zarf packages that have been created from previous test runs
actions:
- cmd: find src/test -type f -name '*.tar.zst' -delete
35 changes: 35 additions & 0 deletions zarf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,41 @@
},
"type": "array",
"description": "List of local values file paths or remote URLs to include in the package; these will be merged together when deployed"
},
"variables": {
"items": {
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/ZarfChartVariable"
},
"type": "array",
"description": "[alpha] List of variables to set in the Helm chart"
}
},
"additionalProperties": false,
"type": "object",
"patternProperties": {
"^x-": {}
}
},
"ZarfChartVariable": {
"required": [
"name",
"description",
"path"
],
"properties": {
"name": {
"pattern": "^[A-Z0-9_]+$",
"type": "string",
"description": "The name of the variable"
},
"description": {
"type": "string",
"description": "A brief description of what the variable controls"
},
"path": {
"type": "string",
"description": "The path within the Helm chart values where this variable applies"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 43b8dee

Please sign in to comment.