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: cleanup root level files and add SPDX check for Go files #2431

Merged
merged 45 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
15d19d0
cleanup refs to old docs dirs
Noxsios Apr 10, 2024
9e2b238
cleanup root
Noxsios Apr 10, 2024
e998095
spdx go
Noxsios Apr 10, 2024
f5185e0
normalize bash scripts and go fmt
Noxsios Apr 10, 2024
85551c0
goimports
Noxsios Apr 10, 2024
95da7af
cleanup makefile
Noxsios Apr 10, 2024
4b868c2
update contributing
Noxsios Apr 10, 2024
1362d7e
update lint workflow
Noxsios Apr 10, 2024
e533199
update contributing
Noxsios Apr 10, 2024
33ba67d
lets try these fonts
Noxsios Apr 10, 2024
2b9bc74
remove width change
Noxsios Apr 10, 2024
6656fb4
Merge branch 'main' into cleanup-docs-refs
Noxsios Apr 10, 2024
8c05250
add desc to root
Noxsios Apr 10, 2024
5dd340f
tweak theme colors and provide some redirects
Noxsios Apr 11, 2024
86f03ba
tweak colors
Noxsios Apr 11, 2024
67e9dee
tweak colors
Noxsios Apr 11, 2024
c7a3c7e
redirects
Noxsios Apr 11, 2024
ab41774
Merge branch 'main' into cleanup-docs-refs
Noxsios Apr 11, 2024
6641d2c
static astro cannot do dynamic redirects, using netlify redirects ins…
Noxsios Apr 11, 2024
0144f38
tweak netlify config
Noxsios Apr 11, 2024
7db5c91
trigger
Noxsios Apr 11, 2024
7509683
remove code from headers
Noxsios Apr 11, 2024
0d44b76
width instead of font
Noxsios Apr 11, 2024
2b7ca29
Merge branch 'main' into cleanup-docs-refs
Noxsios Apr 11, 2024
d3edd20
better openssf scorecard link
AustinAbro321 Apr 17, 2024
bbd4cff
rennovate hook for grype install
AustinAbro321 Apr 17, 2024
dfa7e24
pre-commit lint
AustinAbro321 Apr 17, 2024
8e12469
update docs-website references
AustinAbro321 Apr 17, 2024
d97715b
correct links
AustinAbro321 Apr 17, 2024
0929a67
broader file match
AustinAbro321 Apr 17, 2024
ec345fd
merge
AustinAbro321 Apr 17, 2024
4dfd50f
merge
AustinAbro321 Apr 17, 2024
779831d
fix pre-commit, comments
AustinAbro321 Apr 18, 2024
f0795b1
fix file match
AustinAbro321 Apr 18, 2024
fb5b0f7
Merge branch 'main' into cleanup-docs-refs
AustinAbro321 Apr 18, 2024
f50ba20
install revive
AustinAbro321 Apr 18, 2024
f2d3108
Merge branch 'cleanup-docs-refs' of github.com:defenseunicorns/zarf i…
AustinAbro321 Apr 18, 2024
51e6c58
save init package
AustinAbro321 Apr 18, 2024
bf1af11
update CODEOWNERS
Noxsios Apr 18, 2024
19db6f9
revert delete packages change
AustinAbro321 Apr 18, 2024
917d48c
Merge branch 'cleanup-docs-refs' of github.com:defenseunicorns/zarf i…
AustinAbro321 Apr 18, 2024
bd66c76
Merge branch 'main' into cleanup-docs-refs
Noxsios Apr 22, 2024
a666fc8
Merge branch 'main' into cleanup-docs-refs
Noxsios Apr 22, 2024
1b75669
Merge branch 'main' into cleanup-docs-refs
AustinAbro321 Apr 23, 2024
8ac69ff
skip checks for whitespace on autogen
AustinAbro321 Apr 23, 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
3 changes: 3 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ pre-commit install

# install goimports
go install golang.org/x/tools/cmd/goimports@latest

# install revive
go install github.com/mgechev/revive@latest
```

Now every time you commit, the hooks will run and format your code, linting can be called via `make lint-go`.
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion .github/actions/install-tools/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ runs:

- uses: anchore/sbom-action/download-syft@b6a39da80722a2cb0ef5d197531764a89b5d48c3 # v0.15.8

- run: "curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin --tag v0.64.2"
- name: install grype
env:
# renovate: datasource=github-tags depName=anchore/grype versioning=semver
VERSION: v0.74.6
run: "curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin $VERSION"
shell: bash

- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
2 changes: 1 addition & 1 deletion .github/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ paths-ignore:
- src/pkg/packager/network.go
- src/pkg/utils/network.go
- src/pkg/utils/credentials.go
- docs-website/**
- site/**
- build/**

query-filters:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scan-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Run Revive Action by pulling pre-built image
uses: docker://morphy/revive-action:v2.5.7@sha256:087d4e61077087755711ab7e9fae3cc899b7bb07ff8f6a30c3dfb240b1620ae8
with:
config: revive.toml
config: hack/revive.toml
# Exclude patterns, separated by semicolons (optional)
exclude: "src/cmd/viper.go"
# Path pattern (default: ./...)
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test-bigbang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ jobs:
name: build-artifacts
path: build/

- name: copy init package
run: |
sudo mkdir /mnt/zarf-tmp
sudo chown -R runner:runner /mnt/zarf-tmp
mv build/zarf-init* /mnt/zarf-tmp


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

Expand Down Expand Up @@ -101,8 +108,6 @@ jobs:
env:
IRON_BANK_ROBOT_USERNAME: ${{ secrets.IRON_BANK_ROBOT_USERNAME }}
run: |
sudo mkdir /mnt/zarf-tmp
sudo chown -R runner:runner /mnt/zarf-tmp
CI=true go test ./src/extensions/bigbang/test -failfast -v -timeout 30m
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved

- name: Save logs
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ repos:
- -w
language: system
pass_filenames: true
- id: lint
name: revive go lint
entry: revive
args:
- "-config"
- "hack/revive.toml"
- "-exclude"
- "src/cmd/viper.go"
files: .go$
language: system
pass_filenames: true
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.14.0
hooks:
Expand Down
30 changes: 0 additions & 30 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
* @defenseunicorns/zarf

# Docs & examples
/adr/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/docs/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/examples/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
*.md @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321

# Core code
/src/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/go.* @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
main.go @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321

# Init package
/packages/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/zarf.yaml @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321

# Docs Website
/docs-website/ @Racer159 @Noxsios @jeff-mccoy @lucasrod16 @AustinAbro321

# Privileged pipeline files
/.github/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/hack/ @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/.gitignore @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/.golangci.yml @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/.goreleaser.yml @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/.grype.yaml @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/Dockerfile @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/renovate.json @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321
/Makefile @jeff-mccoy @Racer159 @Noxsios @lucasrod16 @AustinAbro321

# Additional privileged files
/CODEOWNERS @jeff-mccoy @austenbryan
/cosign.pub @jeff-mccoy @austenbryan
/LICENSE @jeff-mccoy @austenbryan
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# Provide a default value for the operating system architecture used in tests, e.g. " APPLIANCE_MODE=true|false make test-e2e ARCH=arm64"
ARCH ?= amd64
KEY ?= ""
######################################################################################

# Figure out which Zarf binary we should use based on the operating system we are on
Expand Down Expand Up @@ -74,7 +73,7 @@ destroy: ## Run `zarf destroy` on the current cluster
rm -fr build

delete-packages: ## Delete all Zarf package tarballs in the project recursively
find . -type f -name 'zarf-package-*' -delete
find . -type f \( -name 'zarf-package-*' -o -name 'zarf-init-*' \) -delete

# Note: the path to the main.go file is not used due to https://github.com/golang/go/issues/51831#issuecomment-1074188363
.PHONY: build
Expand Down Expand Up @@ -219,11 +218,12 @@ test-docs-and-schema:

# INTERNAL: used to test for new CVEs that may have been introduced
test-cves:
go run main.go tools sbom scan . -o json --exclude './docs-website' --exclude './examples' | grype --fail-on low
go run main.go tools sbom scan . -o json --exclude './site' --exclude './examples' | grype --fail-on low

cve-report: ## Create a CVE report for the current project (must `brew install grype` first)
@test -d ./build || mkdir ./build
go run main.go tools sbom scan . -o json --exclude './docs-website' --exclude './examples' | grype -o template -t hack/.templates/grype.tmpl > build/zarf-known-cves.csv
go run main.go tools sbom scan . -o json --exclude './site' --exclude './examples' | grype -o template -t hack/grype.tmpl > build/zarf-known-cves.csv

lint-go: ## Run revive to lint the go code (must `brew install revive` first)
revive -config revive.toml -exclude src/cmd/viper.go -formatter stylish ./src/...
revive -config hack/revive.toml -exclude src/cmd/viper.go -formatter stylish ./src/...
hack/check-spdx-go.sh src >/dev/null || (echo "SPDX check for go failed, please run 'hack/check-spdx-go.sh src' to see the errors" && exit 1)
Noxsios marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Go version](https://img.shields.io/github/go-mod/go-version/defenseunicorns/zarf?filename=go.mod)](https://go.dev/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/defenseunicorns/zarf/release.yml)](https://github.com/defenseunicorns/zarf/actions/workflows/release.yml)
[![Zarf Documentation Status](https://api.netlify.com/api/v1/badges/fe846ae4-25fb-4274-9968-90782640ee9f/deploy-status)](https://app.netlify.com/sites/zarf-docs/deploys)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/zarf/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/zarf)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/zarf/badge)](https://securityscorecards.dev/viewer/?uri=github.com/defenseunicorns/zarf)

<img align="right" alt="zarf logo" src="site/src/assets/zarf-logo.png" height="256" />

Expand Down
63 changes: 63 additions & 0 deletions hack/check-spdx-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

set -euo pipefail

# Directory containing the Go files
DIRECTORY="$1"

# Array of paths to exclude from the check
EXCLUDE_PATHS=(
"src/cmd/tools/helm/repo_update.go"
"src/cmd/tools/helm/repo_remove.go"
"src/cmd/tools/helm/load_plugins.go"
"src/cmd/tools/helm/repo_list.go"
"src/cmd/tools/helm/flags.go"
"src/cmd/tools/helm/repo_add.go"
"src/cmd/tools/helm/dependency.go"
"src/cmd/tools/helm/repo_index.go"
"src/cmd/tools/helm/repo.go"
"src/cmd/tools/helm/dependency_build.go"
"src/cmd/tools/helm/dependency_update.go"
"src/cmd/tools/helm/root.go"
)

BLACK='\033[0;30m'
RED='\033[0;31m'
RESET='\033[0m'

# Function to check if a path is in the EXCLUDE_PATHS array
is_excluded() {
local path="$1"
for exclude in "${EXCLUDE_PATHS[@]}"; do
if [[ "$path" == "$exclude"* ]]; then
return 0 # 0 means true/success in shell script
fi
done
return 1 # 1 means false/failure in shell script
}

# Flag to track if any file meets the condition
found=0

# Use process substitution to avoid subshell issue with the 'found' variable
while IFS= read -r file; do
if is_excluded "$file"; then
echo -e "$BLACK$file$RESET"
continue
fi

# Use `head` to grab the first two lines and compare them directly
firstLine=$(head -n 1 "$file")
secondLine=$(head -n 2 "$file" | tail -n 1)

# Check if the lines do not match the specified strings
if [[ "$firstLine" != "// SPDX-License-Identifier: Apache-2.0" || "$secondLine" != "// SPDX-FileCopyrightText: 2021-Present The Zarf Authors" ]]; then
echo -e "$RED$file$RESET"
found=1
fi
done < <(find "$DIRECTORY" -type f -name "*.go")

# If any file met the condition, exit with status 1
if [ "$found" -eq 1 ]; then
exit 1
fi
4 changes: 3 additions & 1 deletion hack/check-zarf-docs-and-schema.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

set -euo pipefail

if [ -z "$(git status -s docs/ zarf.schema.json)" ]; then
echo "Success!"
Expand Down
4 changes: 3 additions & 1 deletion hack/create-zarf-schema.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

set -euo pipefail

# Create the json schema for the zarf.yaml
go run main.go internal gen-config-schema > zarf.schema.json
Expand Down
3 changes: 3 additions & 0 deletions hack/empty-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is here so it can be used during certain Zarf commands
# such as `internal gen-cli-docs` where we prefer an empty config
# as opposed to the init package config at the base of the repo
File renamed without changes.
8 changes: 5 additions & 3 deletions hack/lint-all-zarf-packages.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

ZARF_BIN=$1
LINT_SRC_TEST=$2
Expand All @@ -11,7 +13,7 @@ find "." -type f -name 'zarf.yaml' | while read -r yaml_file; do
if [[ "$dir" == *src/test/* ]] && [ "$LINT_SRC_TEST" != true ]; then
continue
fi
echo "Running 'zarf prepare lint' in directory: $dir"
$ZARF_BIN prepare lint "$dir"
echo "Running 'zarf dev lint' in directory: $dir"
$ZARF_BIN dev lint "$dir"
echo "---"
done
4 changes: 2 additions & 2 deletions revive.toml → hack/revive.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
errorCode = 1
warningCode = 1
formatter = "stylish"

[rule.blank-imports]
Expand Down
10 changes: 10 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@
"https:\\/\\/github.com\\/(?<depName>[\\w\\/\\-\\.\\+\\%]+?)\\/releases\\/download\\/(?<currentValue>[\\w\\/\\-\\.\\+\\%]+?)\\/"
],
"datasourceTemplate": "github-releases"
},
{
"fileMatch": [
"\\.*\\.ya?ml$"
],
"matchStrings": [
"# renovate: datasource=github-tags depName=anchore/grype versioning=semver\n\\s*VERSION: (?<currentValue>v[\\d.]+)"
],
"datasourceTemplate": "github-tags",
"depNameTemplate": "anchore/grype"
}
]
}
7 changes: 5 additions & 2 deletions site/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import remarkGemoji from "remark-gemoji";
// https://astro.build/config
export default defineConfig({
redirects: {
'/docs/zarf-overview': '/'
"/docs/zarf-overview": "/",
},
markdown: {
remarkPlugins: [remarkGemoji],
Expand Down Expand Up @@ -37,7 +37,10 @@ export default defineConfig({
src: "./src/assets/zarf-logo-header.svg",
replacesTitle: true,
},
customCss: ["./src/styles/custom.css"],
customCss: [
"./src/styles/custom.css",
"@fontsource/source-code-pro/400.css",
],
lastUpdated: true,
sidebar: [
{
Expand Down
9 changes: 9 additions & 0 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/starlight": "^0.21.2",
"@fontsource/source-code-pro": "^5.0.17",
"astro": "^4.5.12",
"mermaid": "^10.9.0",
"rehype-autolink-headings": "^7.1.0",
Expand Down
Loading
Loading