Skip to content

Commit

Permalink
Merge pull request #9 from losisin/add-Makefile
Browse files Browse the repository at this point in the history
Add makefile
  • Loading branch information
losisin authored Oct 25, 2023
2 parents 5891804 + f8c02b7 commit 603ab0b
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ on:
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ubuntu-latest
env:
VERBOSE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand All @@ -24,9 +30,13 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
args: --timeout 5m0s
- name: Run fmt
run: go fmt ./...
- name: Run vet
run: go vet ./...
- name: Run tests
run: go test -v ./...
run: make test-all
- name: Install plugin
run: make install
- name: Run plugin
run: helm schema -help
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
flags: unittests
5 changes: 5 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ builds:
goarch:
- amd64
- arm64
ldflags:
- -s -w
-X main.Version={{ .Tag }}
-X main.GitCommit={{ .Commit }}
-X main.BuildDate={{ .Date }}
binary: schema

archives:
Expand Down
105 changes: 105 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
SHELL := /bin/bash

BINNAME := schema
PLUGIN_SHORTNAME := json-schema

BUILD_DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S UTC' 2> /dev/null)
GIT_HASH := $(shell git rev-parse HEAD 2> /dev/null)

GOPATH ?= $(shell go env GOPATH)
PATH := $(GOPATH)/bin:$(PATH)
GO_BUILD_ENV_VARS = $(if $(GO_ENV_VARS),$(GO_ENV_VARS),CGO_ENABLED=0)
GO_BUILD_ARGS = -buildvcs=false -ldflags "-X main.GitCommit=${GIT_HASH}"

HELM_PLUGINS = $(shell helm env HELM_PLUGINS)
HELM_PLUGIN_DIR = $(HELM_PLUGINS)/$(PLUGIN_SHORTNAME)

.PHONY: build \
install \
verify \
tidy \
fmt \
vet \
check \
test-unit \
test-coverage \
test-all \
clean \
help

build: ## Build the plugin
@echo "Building plugin..."
@${GO_BUILD_ENV_VARS} go build -o $(BINNAME) ${GO_BUILD_ARGS}
@ls -la

install: build ## Install the plugin
@echo "Installing plugin..."
@mkdir -p $(HELM_PLUGIN_DIR)
@cp $(BINNAME)* $(HELM_PLUGIN_DIR)
@cp plugin.yaml $(HELM_PLUGIN_DIR)

verify: ## Verify the plugin
@echo
@echo "Verifying plugin..."
@go mod verify

tidy: ## Tidy the plugin
@echo
@echo "Tidying plugin..."
@go mod tidy

fmt: ## Format the plugin
@echo
@echo "Formatting plugin..."
@go fmt ./...

vet: ## Vet the plugin
@echo
@echo "Vetting plugin..."
@go vet ./...

check: verify tidy fmt vet ## Verify, tidy, fmt and vet the plugin

test-unit: ## Run unit tests
@echo
@echo "Running unit tests..."
@go test -short ./...

test-coverage: ## Run tests with coverage
@echo
@echo "Running tests with coverage..."
@go test -v -race -covermode=atomic -coverprofile=cover.out ./...

test-all: test-unit test-coverage ## Includes test-unit and test-coverage

clean: ## Clean the plugin
@echo "Cleaning plugin..."
@rm -rf $(BINNAME) $(HELM_PLUGIN_DIR)

help: ## Show this help message
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " build Build the plugin"
@echo " install Install the plugin"
@echo " verify Verify the plugin"
@echo " tidy Tidy the plugin"
@echo " fmt Format the plugin"
@echo " vet Vet the plugin"
@echo " check Includes verify, tidy, fmt, vet"
@echo " test-unit Run unit tests"
@echo " test-coverage Run tests with coverage"
@echo " test-all Includes test-unit, test-coverage"
@echo " clean Clean the plugin"
@echo " help Show this help message"
@echo ""
@echo "Variables:"
@echo " GOPATH The GOPATH to use (default: \$$GOPATH)"
@echo " PATH The PATH to use (default: \$$GOPATH/bin:\$$PATH)"
@echo " HELM_PLUGINS The HELM_PLUGINS directory (default: \$$HELM_PLUGINS)"
@echo " HELM_PLUGIN_DIR The HELM_PLUGIN_DIR directory (default: \$$HELM_PLUGIN_DIR)"
@echo " BINNAME The name of the binary to build (default: $(BINNAME))"
@echo " PLUGIN_SHORTNAME The short name of the plugin (default: $(PLUGIN_SHORTNAME))"
@echo ""

default: help
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# helm values schema json plugin

[![ci](https://github.com/losisin/helm-values-schema-json/actions/workflows/ci.yaml/badge.svg)](https://github.com/losisin/helm-values-schema-json/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/losisin/helm-values-schema-json/graph/badge.svg?token=0QQVCFJH84)](https://codecov.io/gh/losisin/helm-values-schema-json)
[![Static Badge](https://img.shields.io/badge/licence%20-%20MIT-green)](https://github.com/losisin/helm-values-schema-json/blob/add-Makefile/LICENSE)
[![GitHub release (with filter)](https://img.shields.io/github/v/release/losisin/helm-values-schema-json)](https://github.com/losisin/helm-values-schema-json/releases)


Helm plugin for generating `values.schema.json` from single or multiple values files. Works only with Helm3 charts.

## Install
Expand Down

0 comments on commit 603ab0b

Please sign in to comment.