Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Continuous Integration
on:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**/*.md'
push:
branches:
- main
paths-ignore:
- '**/*.md'

jobs:
report:
name: Report
runs-on: ubuntu-latest
outputs:
non_docs_changed: ${{ steps.fileschanged.outputs.non_doc_files_changed }}
steps:
- name: ref
run: echo ${{ github.ref }}
- name: event_name
run: echo ${{ github.event_name }}
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- id: fileschanged
run: |
case '${{ github.event_name }}' in
push)
firstCommit='${{ github.event.before }}'
lastCommit='${{ github.event.after }}'
;;
pull_request)
firstCommit='${{ github.event.pull_request.base.sha }}'
lastCommit='${{ github.event.pull_request.head.sha }}'
;;
esac
changedFiles=$(git diff --name-only --diff-filter=d "${firstCommit}" "${lastCommit}")
echo "Files changed: $changedFiles"
NON_MD_FILES=$(echo "$changedFiles" | grep -v '\.md$' || true)
if [ -n "$NON_MD_FILES" ]; then
echo "non_doc_files_changed=true" >> $GITHUB_OUTPUT
else
echo "non_doc_files_changed=false" >> $GITHUB_OUTPUT
fi
ci:
name: CI
runs-on: ubuntu-latest
needs: [ report ]
if: needs.report.outputs.non_docs_changed == 'true'
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.1.2
- name: vet
run: make vet
- name: Test
run: make test
- name: Build
run: make build-all
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release
on:
push:
tags:
- 'v*'

jobs:
report:
name: Report
runs-on: ubuntu-latest
steps:
- name: ref
run: echo ${{ github.ref }}
- name: event_name
run: echo ${{ github.event_name }}
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build for all platforms
run: |
make build-all
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*
38 changes: 34 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
.PHONY: all build
.PHONY: all build vet test


PLATFORMS ?= linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64

GOOS?=$(shell uname -s | tr '[:upper:]' '[:lower:]')
GOARCH?=$(shell uname -m)

BINDIR := dist
FILENAME := nekko

BINARY ?= $(BINDIR)/$(FILENAME)-$(GOOS)-$(GOARCH)

.PRECIOUS: $(foreach platform,$(PLATFORMS),$(BINDIR)/$(FILENAME)-$(subst /,-,$(platform)))

all: build
build: dist/nekko

dist/nekko:
go build -o $@ ./cmd/nekko
build-all: $(foreach platform,$(PLATFORMS),build-local-$(subst /,-,$(platform)))

build-local-%: $(BINDIR)/$(FILENAME)-%;

build: $(BINARY)

vet:
go vet ./...

test:
go test -v ./...

$(BINDIR):
mkdir -p $@

$(BINDIR)/$(FILENAME)-%: GOOS=$(word 1,$(subst -, ,$*))
$(BINDIR)/$(FILENAME)-%: GOARCH=$(word 2,$(subst -, ,$*))
$(BINDIR)/$(FILENAME)-%: $(BINDIR)
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ ./cmd/nekko
4 changes: 3 additions & 1 deletion cmd/nekko/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func runCommand(conf *config, logger *log.Logger, v *viper.Viper) (*cobra.Comman
flags.StringP("image", "i", "ghcr.io/nekkoai/onnx-eis", "Image to run the model, determined by runtime option, or can be set explicitly")
flags.StringP("command", "c", "", "Command to run inside the container (default determined by runtime)")

cmd.MarkFlagRequired("model")
if err := cmd.MarkFlagRequired("model"); err != nil {
return nil, err
}

bindFlags(cmd, v)

Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/onnxruntime/onnxruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (o *onnxRuntime) Content() (map[string][]byte, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to fetch: %s", resp.Status)
Expand Down