Skip to content

Commit

Permalink
Compile and unittest first example application.
Browse files Browse the repository at this point in the history
Added necessary tools and Makefile to build and test an
example application.

Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
  • Loading branch information
Paul Hewlett authored and eccles committed Dec 21, 2021
1 parent 2d0f50b commit b0e419c
Show file tree
Hide file tree
Showing 29 changed files with 180 additions and 199 deletions.
13 changes: 0 additions & 13 deletions .bash_history

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
.bash_history
87 changes: 0 additions & 87 deletions Dockerfile

This file was deleted.

13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

PWD := $(shell pwd )

.PHONY: help
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Expand All @@ -10,6 +13,10 @@ tools-check: ## Check that all tools are available
tools-install: ## Ensure that all tools are available
@./scripts/tools/install.sh

.PHONY: builder
builder: ## Create builder image
@./scripts/builder-create.sh
.PHONY: unittests
unittests: ## unittest all source code
@./scripts/unittests.sh

.PHONY: build
build: ## Compile all source code
@./scripts/build.sh
1 change: 1 addition & 0 deletions vendor/.gitignore → bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!README.md
!.gitignore
4 changes: 4 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Compiled Binaries
=================

All compiled binaries are stored in this directory.
12 changes: 12 additions & 0 deletions cmd/hello/hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import "fmt"
import "rsc.io/quote"

func Hello() string {
return quote.Go()
}

func main() {
fmt.Println(Hello())
}
10 changes: 10 additions & 0 deletions cmd/hello/hello_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import "testing"

func TestHello(t *testing.T) {
want := "Don't communicate by sharing memory, share memory by communicating."
if got := Hello(); got != want {
t.Errorf("Hello() = %q, want %q", got, want)
}
}
1 change: 1 addition & 0 deletions credentials/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!README.md
!.gitignore
5 changes: 5 additions & 0 deletions credentials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Credentials
============

Store secrets in this directory which has 0700 permissions.

10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/eccles/hestia

go 1.17

require rsc.io/quote v1.5.2

require (
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
rsc.io/sampler v1.3.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
11 changes: 0 additions & 11 deletions grpc-gateway

This file was deleted.

Binary file added hello
Binary file not shown.
45 changes: 0 additions & 45 deletions scripts/ansible

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
#
# Builds all golang binaries
. scripts/source/log
. scripts/source/environment

go install -v ./...
8 changes: 0 additions & 8 deletions scripts/builder-create.sh

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/builder.sh

This file was deleted.

13 changes: 13 additions & 0 deletions scripts/source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Sourced scripts
===============

All files in this directory are sourced in all scripts called from the
root of the repo.

Most scripts will always have these 2 lines at top of the script:

```bash
. scripts/source/log
. scripts/source/environment
```
14 changes: 14 additions & 0 deletions scripts/source/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# set environment variables
#
# this file is sourced - do not execute directly
#
# usually these values are set in $HOME/.profile
#
export GOROOT=$HOME/.local/go
if [ ! -s ${GOROOT} ]
then
mkdir -p ${GOROOT}
fi
export PATH=${GOROOT}/bin:${PATH}
export GOBIN=$(pwd)/bin
4 changes: 4 additions & 0 deletions scripts/log → scripts/source/log
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ log_warn() {
log_error() {
echo -e "`date`: ${COLOUR_BLINK}${COLOUR_RED}$* ...${COLOUR_RESET}"
}
log_fatal() {
echo -e "`date`: ${COLOUR_BLINK}${COLOUR_RED}$* ...${COLOUR_RESET}"
exit 100
}
File renamed without changes.
7 changes: 0 additions & 7 deletions scripts/tools-check.sh

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/tools-install.sh

This file was deleted.

6 changes: 4 additions & 2 deletions scripts/tools/check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
#
# Checks that all tools are available
. ./scripts/tools/ansible
. scripts/source/log
. scripts/source/environment
. scripts/tools/source/golang

ansible_check
golang_check
6 changes: 4 additions & 2 deletions scripts/tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# Installs necessary tools
#
. ./scripts/tools/ansible
. ./scripts/source/log
. ./scripts/source/environment
. ./scripts/tools/source/golang

ansible_install
golang_install
File renamed without changes.
Loading

0 comments on commit b0e419c

Please sign in to comment.