Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
fighting the war against ALL CAPS
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Jan 24, 2021
1 parent 2f11b1b commit 1aa0054
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 115 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI Build

# This is a generic CI pipeline that assumes project is to be built as a container image
# Note. CI build only builds 'latest' image, not a versioned release
# Note. REGISTRY_PASSWORD must be set and change the IMAGE_NAME

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
IMAGE_REG: ghcr.io
IMAGE_NAME: kubeview
IMAGE_TAG: latest

jobs:
ci-build:
name: Code Check & CI build
runs-on: ubuntu-latest

steps:
# Checkout code from repo
- name: Checkout repo
uses: actions/checkout@v2

# Ensures Go is configured properly
- uses: actions/setup-go@v2
with:
go-version: '^1.15.7'

# Validate code
- name: Check code for linting and format errors
run: make lint

# Build image
- name: Build the container image
run: make image IMAGE_REPO=$GITHUB_ACTOR/$IMAGE_NAME

# Only when pushing to default branch (e.g. master or main), then push image to registry
- name: Push to container registry
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login $IMAGE_REG -u $GITHUB_ACTOR --password-stdin
make push IMAGE_REPO=$GITHUB_ACTOR/$IMAGE_NAME
41 changes: 0 additions & 41 deletions .github/workflows/docker-ci-build.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/gofmt-action.sh

This file was deleted.

1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linters-settings:
linters:
enable:
- golint
- gofmt
issues:
include:
- EXC0002
6 changes: 3 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# This file might sound important but...
# It is only used by the hosting on GitHub Pages, it has no other importance to the Smilr project
# It is only used by the hosting on GitHub Pages, it has no other importance to the project
#

title: "KubeView"
title: 'KubeView'
remote_theme: benc-uk/theme-msdark
favicon: /web/client/src/assets/logo.png
buttons:
Expand All @@ -18,4 +18,4 @@ buttons:
href: /web/client
- b3:
text: Deployment
href: /deployments/helm/
href: /deployments/helm/
10 changes: 5 additions & 5 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ RUN npm run build
# ================================================================================================
FROM golang:1.15-alpine as go-build
WORKDIR /build
ARG goPackage="github.com/benc-uk/kubeview/cmd/server"
ARG version="0.0.0"
ARG buildInfo="Not set"
ARG GO_PACKAGE="github.com/benc-uk/kubeview/cmd/server"
ARG VERSION="0.0.0"
ARG BUILD_INFO="Not set"

ENV PORT 8000

Expand All @@ -47,9 +47,9 @@ COPY cmd/ ./cmd
# Disabling cgo results in a fully static binary that can run without C libs
# Also inject version and build details
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-X main.version=$version -X 'main.buildInfo=$buildInfo'" \
-ldflags "-X main.version=$VERSION -X 'main.buildInfo=$BUILD_INFO'" \
-o server \
$goPackage
$GO_PACKAGE

# ================================================================================================
# === Stage 3: Bundle server exe and Vue dist in runtime image ===================================
Expand Down
68 changes: 27 additions & 41 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,49 @@ VERSION := 0.1.20
BUILD_INFO := Manual build from makefile

# Most likely want to override these when calling `make image`
DOCKER_REG ?= ghcr.io
DOCKER_REPO ?= benc-uk/kubeview
DOCKER_TAG ?= latest
DOCKER_PREFIX := $(DOCKER_REG)/$(DOCKER_REPO)
IMAGE_REG ?= ghcr.io
IMAGE_REPO ?= benc-uk/kubeview
IMAGE_TAG ?= latest
IMAGE_PREFIX := $(IMAGE_REG)/$(IMAGE_REPO)

.PHONY: help image push build-frontend build-server lint lint-fix
.DEFAULT_GOAL := help

.PHONY: image push build-frontend build-server lint lint-ci format format-ci

################################################################################
# Lint - check everything
help: ## This help message :)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'


################################################################################
lint: $(FRONTEND_DIR)/node_modules
lint: $(FRONTEND_DIR)/node_modules ## Lint & format, will not fix but sets exit code on error
go get github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run $(SERVER_DIR)/...
cd $(FRONTEND_DIR); npm run lint-ci
cd $(FRONTEND_DIR); npm run lint


################################################################################
# Lint - will try to fix errors & modify code
################################################################################
lint-fix: $(FRONTEND_DIR)/node_modules
lint-fix: $(FRONTEND_DIR)/node_modules ## Lint & format, will try to fix errors and modify code
go get github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run $(SERVER_DIR)/... --fix
cd $(FRONTEND_DIR); npm run lint
cd $(FRONTEND_DIR); npm run lint-fix

################################################################################
# Format - check everything
################################################################################
format: $(FRONTEND_DIR)/node_modules
@test -z `gofmt -l $(SERVER_DIR)` || (gofmt -d $(SERVER_DIR) && exit 1)
cd $(FRONTEND_DIR); npm run format-ci

################################################################################
# Format - will try to fix errors & modify code
################################################################################
format-fix: $(FRONTEND_DIR)/node_modules
gofmt -w $(SERVER_DIR)
cd $(FRONTEND_DIR); npm run format

################################################################################
# Build combined Docker image (API server plus frontend)
################################################################################
image:
image: ## Build combined container image (API server plus frontend)
docker build --file ./build/Dockerfile \
--build-arg buildInfo="$(BUILD_INFO)" \
--build-arg version="$(VERSION)" \
--tag $(DOCKER_REG)/$(DOCKER_REPO):$(DOCKER_TAG) .
--build-arg BUILD_INFO="$(BUILD_INFO)" \
--build-arg VERSION="$(VERSION)" \
--tag $(IMAGE_PREFIX):$(IMAGE_TAG) .

################################################################################
# Push combined Docker image
################################################################################
push:
docker push $(DOCKER_REG)/$(DOCKER_REPO):$(DOCKER_TAG)

################################################################################
# Build & bundle Frontend / Vue.js
push: ## Push combined container image
docker push $(IMAGE_PREFIX):$(IMAGE_TAG)


################################################################################
build-frontend: $(FRONTEND_DIR)/node_modules
build-frontend: $(FRONTEND_DIR)/node_modules ## Build & bundle Frontend / Vue.js
cd $(FRONTEND_DIR); npm run build

$(FRONTEND_DIR)/node_modules: $(FRONTEND_DIR)/package.json
Expand All @@ -73,10 +60,9 @@ $(FRONTEND_DIR)/node_modules: $(FRONTEND_DIR)/package.json
$(FRONTEND_DIR)/package.json:
@echo "package.json was modified"


################################################################################
# Build server
################################################################################
build-server:
build-server: ## Build Go API server
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-X main.version=\"$(VERSION)\" -X 'main.buildInfo=\"$(BUILD_INFO)\"'" \
-o server $(SERVER_DIR)/...
6 changes: 2 additions & 4 deletions web/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"lint-ci": "vue-cli-service lint --no-fix",
"format": "prettier --write src",
"format-ci": "prettier --check src"
"lint-fix": "vue-cli-service lint && prettier --write src",
"lint": "vue-cli-service lint --no-fix && prettier --check src"
},
"dependencies": {
"bootstrap-vue": "^2.21.2",
Expand Down

0 comments on commit 1aa0054

Please sign in to comment.