Skip to content

Commit

Permalink
feat: added makefile for builds and updated pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-viles authored Oct 31, 2024
1 parent ebe0544 commit aef3670
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 29 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
version: latest
skip-cache: true
args: --timeout=3m --skip-dirs=charts

test-golang:
name: Run tests
runs-on: ubuntu-24.04
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,7 @@ jobs:

- name: Build binaries
run: |
for goos in darwin linux windows; do
for goarch in amd64 arm arm64; do
# Skip unsupported combinations
if [[ "$goos" == "darwin" && "$goarch" == "arm" ]]; then continue; fi
if [[ "$goos" == "windows" && ! "$goarch" == "amd64" ]]; then continue; fi
output_file="${{github.repository}}-$goos-$goarch"
if [[ "$goos" == "windows" ]]; then output_file="$output_file.exe"; fi
GOOS=$goos GOARCH=$goarch CGO_ENABLED=0 go build -o $output_file cmd/dogkat/main.go
files="$files\n$output_file"
done
done
echo "files=$files" >> $GITHUB_ENV
make all VERSION=${{ github.ref_name }}
- name: Release Notes
run: |
Expand All @@ -82,7 +69,13 @@ jobs:
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: false
files: ${{ env.files }}
files:
bin/dogkat-linux-amd64
bin/dogkat-linux-arm64
bin/dogkat-darwin-amd64
bin/dogkat-darwin-arm64
bin/dogkat-windows-amd64
bin/dogkat-windows-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

### Deprecated

## [ 2024/10/30 - v0.1.13 ]

### Changed/Added
* Updated modules
* Updated pipeline
* Updated app and chart versions

## [ 2024/09/19 - v0.1.12 ]

### Changed/Added
Expand Down
79 changes: 79 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Application version encoded in all the binaries.
VERSION = 0.0.0

# Base go module name.
MODULE := $(shell cat go.mod | grep -m1 module | awk '{print $$2}')

# Git revision.
REVISION := $(shell git rev-parse HEAD)

# Some sane defaults
SHELL = /usr/bin/env bash
BINDIR := $(CURDIR)/bin
BINNAME ?= dogkat
PREFIX = $(HOME)/bin

# Sources for building
SOURCES := $(shell find . -type f -name *.go) go.mod go.sum

# Golang info
GOPATH := $(shell go env GOPATH)
GOBIN := $(if $(shell go env GOBIN),$(shell go env GOBIN),$(GOPATH)/bin)

# Some flags for the build to set revision and versions
FLAGS=-trimpath -ldflags "-X $(MODULE)/pkg/constants.Version=$(VERSION) -X $(MODULE)/pkg/constants.Revision=$(REVISION)"

# The targets to build
TARGET_BINARIES := dogkat-linux-amd64 dogkat-linux-arm64 dogkat-darwin-amd64 dogkat-darwin-arm64 dogkat-windows-amd64 dogkat-windows-arm64

.PHONY: all
all: $(TARGET_BINARIES) # Make all depend on the binaries
# Create output directories (this can be simplified)
$(BINDIR):
mkdir -p $@

# Build linux-amd64
.PHONY: dogkat-linux-amd64
dogkat-linux-amd64: $(SOURCES) | $(BINDIR)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@ cmd/dogkat/main.go

# Build linux-arm64
.PHONY: dogkat-linux-arm64
dogkat-linux-arm64: $(SOURCES) | $(BINDIR)
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@ cmd/dogkat/main.go

# Build darwin-amd64
.PHONY: dogkat-darwin-amd64
dogkat-darwin-amd64: $(SOURCES) | $(BINDIR)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@ cmd/dogkat/main.go

# Build darwin-arm64
.PHONY: dogkat-darwin-arm64
dogkat-darwin-arm64: $(SOURCES) | $(BINDIR)
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@ cmd/dogkat/main.go

# Build windows-amd64
.PHONY: dogkat-windows-amd64
dogkat-windows-amd64: $(SOURCES) | $(BINDIR)
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@.exe cmd/dogkat/main.go

# Build windows-arm64
.PHONY: dogkat-windows-arm64
dogkat-windows-arm64: $(SOURCES) | $(BINDIR)
GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build $(FLAGS) -o $(BINDIR)/$@.exe cmd/dogkat/main.go

.PHONY: install
install:
@case $$(uname -s)-$$(uname -m) in \
Darwin-x86_64) sudo install -o root -g root -m 0755 $(BINDIR)/dogkat-darwin-amd64 $(PREFIX)/dogkat ;; \
Linux-x86_64) sudo install -o root -g root -m 0755 $(BINDIR)/dogkat-linux-amd64 $(PREFIX)/dogkat ;; \
Linux-aarch64) sudo install -o root -g root -m 0755 $(BINDIR)/dogkat-linux-arm64 $(PREFIX)/dogkat ;; \
MINGW64_NT-*) sudo install -o root -g root -m 0755 $(BINDIR)/dogkat-windows-amd64.exe $(PREFIX)/dogkat.exe ;; \
*) echo "Unsupported platform: $$(uname -s)-$$(uname -m)" ; exit 1 ;; \
esac

# Perform license checking.
# This must pass or you will be denied by CI.
.PHONY: license
license:
go run hack/check_license/main.go
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,32 @@ See below for a comprehensive list of tests and what can be confirmed using this

## Usage

For details on how to use the tool, run `e2e-test --help`
For details on how to use the tool, run `dogkat --help`

## Examples
### Examples

Test core workloads with a defined storage class:
#### Test core workloads with a defined storage class:

```shell
e2e-test validate core --storage-class longhorn
dogkat validate core --storage-class longhorn
```

Test Ingress with tls:
#### Test Ingress with tls:

```shell
e2e-test validate ingress --storage-class longhorn --ingress-class nginx --enable-tls --annotations cert-manager.io/cluster-issuer=letsencrypt
dogkat validate ingress --storage-class longhorn --ingress-class nginx --enable-tls --annotations cert-manager.io/cluster-issuer=letsencrypt
```

Test GPU
#### Test GPU

```shell
e2e-test validate gpu --number-of-gpus 1
dogkat validate gpu --number-of-gpus 1
```

#### Cleanup

```shell
dogkat delete
```

## Using The Chart
Expand Down
4 changes: 2 additions & 2 deletions charts/dogkat/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

apiVersion: v2
name: dogkat
version: 0.1.13
appVersion: 0.1.13
version: 0.1.14
appVersion: 0.1.14
type: application
maintainers:
- name: drew-viles
Expand Down
2 changes: 1 addition & 1 deletion charts/dogkat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dogkat

![Version: 0.1.13](https://img.shields.io/badge/Version-0.1.13-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.13](https://img.shields.io/badge/AppVersion-0.1.13-informational?style=flat-square)
![Version: 0.1.14](https://img.shields.io/badge/Version-0.1.14-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.14](https://img.shields.io/badge/AppVersion-0.1.14-informational?style=flat-square)

End-2-End testing for GPUs and some core resources

Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package cmd

import (
"fmt"
"github.com/drewbernetes/dogkat/pkg/constants"
"github.com/spf13/cobra"
)
Expand All @@ -30,7 +29,7 @@ func NewVersionCmd() *cobra.Command {
Short: "Print this command's version",
Long: "Print this command's version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(constants.Version)
constants.VersionPrint()
},
}
}
23 changes: 22 additions & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,25 @@ limitations under the License.

package constants

import (
"fmt"
"os"
"path"
)

var (

// Version is the release version
Version string

// Revision is the git revision set via the Makefile
Revision string

// Application is the name of the application set via the Makefile
Application = path.Base(os.Args[0])
)

const (
Version = "v0.1.13"
ChartName = "dogkat"
ReleaseName = "dogkat-testing"
RepoURL = "https://drewbernetes.github.io/dogkat"
Expand All @@ -34,3 +51,7 @@ const (
MetricsPrefix = "dogkat_test"
MetricsJobName = "dogkat_workloads"
)

func VersionPrint() {
fmt.Printf("%s/%s (revision/%s)\n", Application, Version, Revision)
}

0 comments on commit aef3670

Please sign in to comment.