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

Pre-commit and linting #112

Merged
merged 6 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ trim_trailing_whitespace = true
max_line_length = 120
tab_width = 4

[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ stages:
only:
- master
- merge_requests
- tags
- tags

compile:
only:
only:
- branches
- merge_requests
- tags
Expand Down Expand Up @@ -42,7 +42,7 @@ package:
- echo "PACKAGE_JOB_ID=$CI_JOB_ID" >> job.env
artifacts:
reports:
dotenv: job.env
dotenv: job.env
paths:
- build/

Expand All @@ -54,7 +54,7 @@ e2e:
artifacts: true
tags:
- bigbang
- packages
- packages
before_script:
- yum install openssh-clients -y
- eval $(ssh-agent -s)
Expand Down
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: detect-aws-credentials
args:
- "--allow-missing-credentials"
- id: detect-private-key
exclude: "^examples/big-bang/template/bigbang/values.yaml$"
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/sirosen/fix-smartquotes
rev: 0.2.0
hooks:
- id: fix-smartquotes
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.4.0
hooks:
- id: go-fmt
# Commenting this one out for now since it fails
## Normally we wouldn't need to do a local hook but we need to modify the shell script that gets run to first change directories into the `cli` folder
# - repo: local
# hooks:
# - id: golangci-lint
# name: golangci-lint
# entry: hooks/run-golangci-lint.sh
# types: [ go ]
# language: script
# pass_filenames: false
# description: "Runs `golangci-lint`, requires https://github.com/golangci/golangci-lint"
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
},

]
}
}
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ Here's what a typical "day in the life" of a Zarf developer might look like. Kee

This section dives deeper into how we test Zarf

### Pre-Commit Hooks and Linting

In this repo we use [pre-commit](https://pre-commit.com/) hooks for automated validation and linting. The CI pipeline will validate that all of the hooks pass so we strongly recommend that you install the hooks locally or you'll be spending a lot of time manually fixing issues that could be fixed automatically very quickly.

#### Pre-Commit Prerequisites

1. Install [pre-commit](https://pre-commit.com/)
1. Install [go](https://golang.org/)
1. Install [golangci-lint](https://github.com/golangci/golangci-lint)
1. Run `pre-commit install` in the repo to install the pre-commit hooks. This will make the hooks run automatically each time you `git commit`. If you want to skip the hooks for any reason you can run `git commit --no-verify` to skip them.

> **HINT:** *Consider [automatically enabling the hooks in every Git repository](https://pre-commit.com/#automatically-enabling-pre-commit-on-repositories)*

### End2End Testing

Our E2E tests utilize [Terratest](https://terratest.gruntwork.io/). They create real infrastructure in AWS that the tests get run on. By doing this we are able to make the test environments ephemeral and allow them to be run in parallel so that we can do more testing more quickly.
Expand All @@ -50,4 +63,4 @@ We're still working on building out the test suite. If you want to help check ou
- [#99](https://github.com/defenseunicorns/zarf/issues/99): Writing additional tests
- [#100](https://github.com/defenseunicorns/zarf/issues/100): Each test should be runnable locally
- [#101](https://github.com/defenseunicorns/zarf/issues/101): Run E2E tests on multiple distros
- [#102](https://github.com/defenseunicorns/zarf/issues/102): Make the E2E tests more efficient
- [#102](https://github.com/defenseunicorns/zarf/issues/102): Make the E2E tests more efficient
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ General usage steps below. For various ways to use Zarf, see [the examples fold

[![asciicast](https://asciinema.org/a/427846.svg)](https://asciinema.org/a/427846)
### 2. Create the zarf cluster
- Move the `zarf`, `zarf-init.tar.zst` files to the system you will install the cluster to.
- Move the `zarf`, `zarf-init.tar.zst` files to the system you will install the cluster to.
- Login or sudo/su to root.
- Run `./zarf init` and follow the wizard.
[![asciicast](https://asciinema.org/a/427721.svg)](https://asciinema.org/a/427721)

### 3. Add resources to the zarf cluster
### 3. Add resources to the zarf cluster
- Following step 1b, make any necessary edits to the `zarf.yaml` file.
- Then run `./zarf package create` to produce an `zarf-package-*.tar.zst` package.
- Move the `zarf-package` into the same folder on the running zarf cluster as in step 2a.
Expand All @@ -43,10 +43,10 @@ This tool utilizes software pulled from multiple sources and _some_ of them requ
- [Iron Bank](https://registry1.dso.mil/) : Platform One's authorized, hardened, and approved container repository. ([product](https://p1.dso.mil/#/products/iron-bank/) | [pages](https://ironbank.dso.mil/) | [register](https://login.dso.mil/register))

#### Local Environment
- MacOS or Linux Operating System
- MacOS or Linux Operating System
- [`make`](https://www.gnu.org/software/make/) : We use Makefiles for build automation
- [`vagrant`](https://www.vagrantup.com/) : Easy creation and management of clean dev/test environments
- [`go`](https://golang.org/) : The programming language. Right now we are using v1.16.x
- [`go`](https://golang.org/) : The programming language. Right now we are using v1.16.x

---

Expand Down Expand Up @@ -126,7 +126,7 @@ All OS options:
- centos7
- centos8
- ubuntu
- debian
- debian
- rocky

In less than a minute, you'll have a kubernetes cluster running all the pre-requisites needed to host and deploy multiple other downstream clusters.
Expand Down
2 changes: 1 addition & 1 deletion assets/manifests/common/traefik-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ spec:
redirectRegex:
regex: ^http://(.*)
replacement: https://${1}
permanent: true
permanent: true
2 changes: 1 addition & 1 deletion assets/manifests/logging/pgl-stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ spec:
extraVolumeMounts:
- name: journal
mountPath: /var/log/journal
readOnly: true
readOnly: true
image:
pullPolicy: Never
2 changes: 1 addition & 1 deletion assets/misc/k9s-theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ k9s:
bgColor: *background
indicator:
fgColor: *foreground
bgColor: *purple
bgColor: *purple
2 changes: 1 addition & 1 deletion assets/scripts/k3s-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ rm -f /usr/local/bin/k9s
rm -f /usr/local/bin/k3s-remove.sh
rm -fr zarf-pki

echo -e '\033[0m'
echo -e '\033[0m'
2 changes: 1 addition & 1 deletion assets/scripts/k3s.service
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ RestartSec=5s
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s server --write-kubeconfig-mode=700
ExecStart=/usr/local/bin/k3s server --write-kubeconfig-mode=700
2 changes: 1 addition & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ build
.env
.image-cache/
.DS_Store
bundle/
bundle/
1 change: 0 additions & 1 deletion cli/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ release-from-tag:
- echo "Creating a release for $CI_COMMIT_TAG"
- release-cli create --name "Zarf CLI ${CI_COMMIT_TAG}" --tag-name "${CI_COMMIT_TAG}" --description "CLI for Zarf"
--assets-link "{\"name\":\"zarf\",\"url\":\"https://repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/-/jobs/${JOB_ID}/artifacts/raw/zarf\"}"

Loading