Skip to content

Commit

Permalink
*: initial commits
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>

Co-authored-by: cardyok <[email protected]>
Co-authored-by: Hitoshi Mitake <[email protected]>
Co-authored-by: Xiang Li <[email protected]>
Co-authored-by: andi willow <[email protected]>
  • Loading branch information
5 people committed Aug 16, 2024
0 parents commit a7cdf53
Show file tree
Hide file tree
Showing 290 changed files with 50,916 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Store gpud binary

on:
push:
branches:
- main
pull_request:
branches: ["**"]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
kernel_version: [ "5.15.0-1065-aws", "6.8.0-1011-aws" ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y linux-headers-${{ matrix.kernel_version }}
- name: Build project
run: |
make
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: gpud-${{ matrix.kernel_version }}
path: bin/gpud
35 changes: 35 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#options
name: golangci-lint.run

on:
push:
branches: ["main"]
pull_request:
paths:
- .github/workflows/golangci-lint.yml
- "**.go"
- go.mod
- go.sum
branches: ["**"]

permissions:
contents: read
pull-requests: read

jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --config=.golangci.yml -v
82 changes: 82 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: goreleaser

# ref. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
on:
push:
branches:
- main
tags:
- "*"

permissions:
contents: write

jobs:
release:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
strategy:
matrix:
job:
- os: ubuntu-22.04
platform: linux
target: linux-x86_64

# - os: ubuntu-22.04
# platform: linux
# target: linux-arm64

- os: macos-latest
platform: darwin
target: darwin-x86_64

- os: macos-latest
platform: darwin
target: darwin-arm64

name: Release ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install OS dependencies
shell: bash
run: |
case ${{ matrix.job.target }} in
linux-arm64) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Show version information
shell: bash
run: |
gcc --version || true
go version
# https://github.com/goreleaser/goreleaser-action
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --config .goreleaser-${{ matrix.job.target }}.yaml
workdir: .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release latest
uses: softprops/action-gh-release@v1
if: ${{ github.ref == 'refs/heads/main' }}
with:
name: Latest release
tag_name: latest
draft: false
prerelease: false
body: Latest builds from the last commit
files: |
./dist/gpud-${{ matrix.job.target }}.tar.gz
32 changes: 32 additions & 0 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#options
name: tests-e2e

on:
push:
branches: ["main"]
pull_request:
paths:
- "**.go"
- go.mod
- go.sum
branches: ["**"]

permissions:
contents: read
pull-requests: read

jobs:
tests-e2e:
name: tests-e2e
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: run e2e tests
run: |
./scripts/tests-e2e.sh
32 changes: 32 additions & 0 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#options
name: tests-unit

on:
push:
branches: ["main"]
pull_request:
paths:
- "**.go"
- go.mod
- go.sum
branches: ["**"]

permissions:
contents: read
pull-requests: read

jobs:
tests-unit:
name: tests-unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: run unit tests
run: |
./scripts/tests-unit.sh
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

/vendor/
/.idea/
/bin/
36 changes: 36 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://golangci-lint.run/usage/configuration/
run:
concurrency: 4
timeout: 15m

# include test files or not, default is true
tests: true

linters-settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: lepton.ai/lepton
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US

linters:
fast: false
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- misspell
- unconvert
69 changes: 69 additions & 0 deletions .goreleaser-darwin-arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# https://goreleaser.com/customization/builds/
builds:

- id: gpud
binary: gpud
main: ./cmd/gpud
env:
- CGO_ENABLED=1
flags:
- -v

# TODO: set ".Env.Version" once stable
# - -X github.com/leptonai/gpud/cmd/gpud/version.ReleaseVersion={{.Version}}
ldflags:
- -s -w
- -X github.com/leptonai/gpud/version.GitCommit={{.Commit}}

goos:
- darwin
goarch:
- arm64

# https://goreleaser.com/customization/archive/
archives:

- id: gpud
format: tar.gz

# "builds" reference which build instances should be archived in this archive
builds:
- gpud

# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .Binary }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
draft: false
replace_existing_draft: true
make_latest: true
mode: replace

github:
owner: leptonai
name: gpud

header: |
## Some title ({{ .Date }})
Welcome to this new release!
name_template: "{{.ProjectName}}-v{{.Version}} {{.Env.USER}}"
Loading

0 comments on commit a7cdf53

Please sign in to comment.