Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Apr 29, 2024
0 parents commit f52c728
Show file tree
Hide file tree
Showing 36 changed files with 2,220 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
64 changes: 64 additions & 0 deletions .github/workflows/auto-check-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Initialise Repo
on:
create:
branches:
- main

permissions:
contents: write

jobs:
run-script:
name: run auto-check script

# We will only run this action when this repository isn't the
# template repository
#
if: >-
${{ !github.event.repository.is_template }}
runs-on: ubuntu-latest

steps:
- name: Configure Git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR_EMAIL}"
shell: bash

- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Run Auto Check script
run: |
. ./scripts/automate-checklist.sh
auto-check
shell: bash

- name: Go Format
run: |
go fmt ./...
shell: bash

- name: Clean up redundant scripts
run: |
rm -fv .github/workflows/auto-check-workflow.yml 2>/dev/null
rm -fv ./scripts/automate-checklist.sh 2>/dev/null
shell: bash

- name: Add files and commit changes
run: |
echo "* available branches:"
git branch | cat
echo "default branch: '${{ github.event.repository.default_branch }}'"
echo "========"
git fetch
git checkout main
git add .
git commit -m "chore(gh-actions): apply auto-check edits"
git push -u origin ${{ github.event.repository.default_branch }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Astrolib Continuous Integration
on:
push:

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.22
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.56.2
args: --verbose

test:
strategy:
matrix:
go-version: [1.22]
platform: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.platform }}

steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

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

- run: go test -v -coverprofile=coverage.out ./...

- uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github
35 changes: 35 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Astrolib Release

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Git Fetch
run: git fetch --force --tags
- name: Setup
uses: actions/setup-go@v3
with:
go-version: '>=1.22'
cache: true
- name: Generate Changelog Only
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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
*.env

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

coverage
coverage.out
ginkgo.report

.task/

i18n/out/en-US/active.en-GB.json

.DS_Store
thumbs.db
.tmp
66 changes: 66 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
linters-settings:
errcheck:
check-type-assertions: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
check-shadowing: true
disable:
- fieldalignment # too strict

nolintlint:
require-explanation: true
require-specific: true

linters:
disable-all: true
enable:
- bodyclose
# - deadcode
# depguard needs to be reviewed properly and then configured, before
# it can be re-enabled.
# https://github.com/OpenPeeDeeP/depguard#example-configs
# - depguard
- dogsled
# - dupl
- errcheck
- exportloopref
- exhaustive
- goconst
- gocritic
- gofmt
- goimports
- gomnd
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nolintlint
- nakedret
- prealloc
- predeclared
- revive
- staticcheck
# - structcheck
- stylecheck
- thelper
- tparallel
- unconvert
- unparam
# - varcheck
- whitespace
- wsl

run:
issues-exit-code: 1
timeout: "5m"
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
before:
hooks:
- go mod tidy
# ? do we need a - go mod generate
# - go mod generate

builds:
- id: "astrolib"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
no_main_check: true
skip: true

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .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
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: github
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
groups:
- title: "🚀 Features"
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: "🐛 Bug fixes"
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: "🥝 Others"
order: 999
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
hooks:
- id: golangci-lint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args: ["--branch", "master", "--branch", "main"]
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
Loading

0 comments on commit f52c728

Please sign in to comment.