mirror of
https://github.com/soypat/lneto.git
synced 2026-07-26 02:28:45 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# This workflow will build a golang project
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
||||
|
||||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.21
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: govulncheck
|
||||
uses: golang/govulncheck-action@v1
|
||||
with:
|
||||
go-version-input: 1.21
|
||||
go-package: ./...
|
||||
|
||||
- name: Test
|
||||
run: go test -v -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
- name: Codecov upload coverage
|
||||
shell: bash
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
RUN_ID: ${{ github.run_id }}
|
||||
run: |
|
||||
# Replace `linux` below with the appropriate OS
|
||||
# Options are `alpine`, `linux`, `macos`, `windows`
|
||||
# You will need to setup the environment variables below in github
|
||||
# and the project in codecov.io: https://app.codecov.io/gh/${{ github.repository }}
|
||||
go test -v -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
||||
chmod +x codecov
|
||||
./codecov --verbose upload-process --fail-on-error -t $CODECOV_TOKEN -n 'service'-$RUN_ID -F service -f coverage.txt
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
# Go workspaces.
|
||||
go.work
|
||||
go.work.sum
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
# Dependency directories after running `go mod vendor`
|
||||
vendor/
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.elf
|
||||
*.uf2
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
*.hex
|
||||
# `__debug_bin` Debug binary generated in VSCode when using the built-in debugger.
|
||||
*bin
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
|
||||
# For local development and testing create `local` directories.
|
||||
local
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
*.cov
|
||||
|
||||
# Log files and common data formats.
|
||||
*.log
|
||||
*.Log
|
||||
*.LOG
|
||||
*.csv
|
||||
*.tsv
|
||||
*.dat
|
||||
*.json
|
||||
*.xlsx
|
||||
*.xls
|
||||
*.zip
|
||||
*.gz
|
||||
*.tar
|
||||
|
||||
# If running a python script.
|
||||
*/__pycache__/*
|
||||
@@ -0,0 +1,28 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, Patricio Whittingslow
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,44 @@
|
||||
# go-module-template
|
||||
[](https://pkg.go.dev/github.com/soypat/go-module-template)
|
||||
[](https://goreportcard.com/report/github.com/soypat/go-module-template)
|
||||
[](https://codecov.io/gh/soypat/go-module-template)
|
||||
[](https://github.com/soypat/go-module-template/actions/workflows/go.yml)
|
||||
[](https://sourcegraph.com/github.com/soypat/go-module-template?badge)
|
||||
<!--
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
[](https://github.com/emersion/stability-badges#experimental)
|
||||
|
||||
See https://github.com/emersion/stability-badges#unstable for more stability badges.
|
||||
-->
|
||||
|
||||
Go module template with instructions on how to make your code importable and setting up codecov CI.
|
||||
|
||||
How to install package with newer versions of Go (+1.16):
|
||||
```sh
|
||||
go mod download github.com/soypat/go-module-template@latest
|
||||
```
|
||||
|
||||
|
||||
## First steps
|
||||
|
||||
0. Replace LICENSE with your desired license. BSD 3 clause is included by default.
|
||||
|
||||
1. Fix `go.mod` file by replacing `github.com/YOURUSER/YOURREPONAME` with your corresponding project repository link.
|
||||
|
||||
2. Replace `soypat/go-module-template` in the badge URLs. Make sure you've replaced all of them by performing text search in the readme for `soypat` and `template`.
|
||||
|
||||
3. Rename `module.go` and `module_test.go` to fit your own repository needs. Below are some exemplary modules that abide by what's generally considered "good practices":
|
||||
- [`mu8` minimal machine learning library](https://github.com/soypat/mu8). Note how most interfaces and interface algorithms are defined at the root package level and how the concrete implementations live in the subdirectories.
|
||||
- Similarily [`sdf`](https://github.com/soypat/sdf) also does the same with defining interfaces top level.
|
||||
|
||||
## Setting up codecov CI
|
||||
This instructive will allow for tests to run on pull requests and pushes to your repository.
|
||||
|
||||
1. Create an account on [codecov.io](https://app.codecov.io/)
|
||||
|
||||
2. Setup repository on codecov and obtain the CODECOV_TOKEN token, which is a string of base64 characters.
|
||||
|
||||
3. Open up the github repository for this project and go to `Settings -> Secrets and variables -> Actions`. Once there create a New Repository Secret. Name it `CODECOV_TOKEN` and copy paste the token obtained in the previous step in the `secret` input box. Click "Add secret".
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Stdout.WriteString("Hello world!\n")
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// package gomoduletemplate is a template repository
|
||||
// for creating new Go modules with basic CI instrumentation.
|
||||
package gomoduletemplate
|
||||
|
||||
// Fibonacci returns the nth number in the Fibonacci sequence.
|
||||
func Fibonacci(n int) int {
|
||||
a, b := 0, 1
|
||||
for i := 0; i < n; i++ {
|
||||
a, b = b, a+b
|
||||
}
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package gomoduletemplate_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
gomoduletemplate "github.com/YOURUSER/YOURREPONAME"
|
||||
)
|
||||
|
||||
func TestWorkingGoInstall(t *testing.T) {
|
||||
t.Log("Your go installation works!")
|
||||
}
|
||||
|
||||
func TestFibonacci(t *testing.T) {
|
||||
var sequence = []int{0, 1, 1, 2, 3, 5, 8, 13, 21, 34}
|
||||
for nth, expected := range sequence {
|
||||
got := gomoduletemplate.Fibonacci(nth)
|
||||
if got != expected {
|
||||
t.Errorf("Fibonacci(%d) = %d, expected %d", nth, got, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user