Skip to content

Commit

Permalink
Merge pull request #10 from danielvrog/main
Browse files Browse the repository at this point in the history
Add Makefile and Dockefile
  • Loading branch information
scpsx authored Jun 22, 2022
2 parents aaf8810 + 72e0b24 commit 61e11b2
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/golang-build-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: golang-build-test-coverage
# TODO: build on MR and merge to master
on:
push:
branches-ignore:
- master
- main
pull_request:
branches:
- master
- main
release:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
main
main.tmpl
config
bin/*
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG GO_VERSION=1.16
FROM golang:${GO_VERSION} AS builder
COPY . /terra-crust
WORKDIR /terra-crust
RUN make compile


FROM golang:${GO_VERSION}
ARG ARCH=amd64
WORKDIR /opt/
COPY --from=builder /terra-crust/bin/terra-crust-linux-${ARCH} ./
RUN mv terra-crust-linux-${ARCH} terra-crust
CMD ["./terra-crust"]
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
SHELL := /bin/bash
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

export GO_VERSION ?= $(shell grep -E "^go " go.mod | awk -F' ' '{print $$2}' )
export GOLANGCI_LINT_VERSION=v1.41.1
export MAIN_GO=internal/cmd/main.go

.PHONY: help
help: ## Show this help message.

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


get-go-dependancies: ## Get dependancies as devlared in the project
$(info)
$(info ========[ $@ ]========)
go get -v -t -d ./...

get-linter: ## Get golangci-lint
$(info)
$(info ========[ $@ ]========)
@if ! golangci-lint --version 2>/dev/null; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION};\
fi;\

lint: get-linter ## Run linter
$(info)
$(info ========[ $@ ]========)
golangci-lint run --fast --enable-all -D scopelint -D gocyclo -D godot -D funlen -D lll -D gocognit -D gofumpt -D wsl -D gomnd --skip-dirs-use-default

test: ## Run go tests
$(info)
$(info ========[ $@ ]========)
go test ./...

build: get-go-dependancies lint ## Build
$(info)
$(info ========[ $@ ]========)
go build -v ${MAIN_GO}


compile: build ## Compile binaries for multiple OSs and architectures
$(info)
$(info ========[ $@ ]========)
@for os in "linux" "darwin"; do \
for arch in "amd64" "arm64"; do \
echo "$${os} - $${arch}"; \
GOOS=$${os} GOARCH=$${arch} go build -o bin/terra-crust-$${os}-$${arch} ${MAIN_GO}; \
done \
done

build-docker: ## Build a docker image
$(info)
$(info ========[ $@ ]========)
docker build -t appsflyer/terra-crust:$$(git rev-parse --short HEAD) .
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Build](https://github.com/danielvrog/terra-crust/actions/workflows/golang-build-test-coverage.yml/badge.svg?branch=main) [![Go Report Card](https://goreportcard.com/badge/github.com/AppsFlyer/terra-crust)](https://goreportcard.com/report/github.com/AppsFlyer/terra-crust) [![codecov](https://codecov.io/gh/AppsFlyer/terra-crust/branch/main/graph/badge.svg)](https://codecov.io/gh/AppsFlyer/terra-crust)

<img src="./docs/images/logo/terra-crust.png" width="400">

----
Expand Down Expand Up @@ -25,13 +27,13 @@ At the end of the flow it will run Terraform FMT to format the files.
## Output Examples:

### Variables:
![](/img/vars.jpg)
![](/docs/images/vars.jpg)

### Locals:
![](/img/locals.jpg)
![](/docs/images/locals.jpg)

### Main:
![](/img/main.jpg)
![](/docs/images/main.jpg)

## Commands:
### Create Main:
Expand Down
Binary file added docs/images/locals.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/main.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/vars.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 61e11b2

Please sign in to comment.