Skip to content

Commit ac3b094

Browse files
authored
chore: various CI and test fixes
Also includes releasing things now!
1 parent 3af6f6c commit ac3b094

30 files changed

+797
-143
lines changed

.github/workflows/release.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
concurrency:
2+
group: ${{ github.workflow }}-${{ github.ref }}
3+
cancel-in-progress: true
4+
5+
on:
6+
push:
7+
tags:
8+
- 'v*'
9+
10+
# Declare default permissions as read only.
11+
permissions: read-all
12+
13+
name: Release
14+
jobs:
15+
release:
16+
permissions:
17+
contents: write
18+
packages: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
22+
with:
23+
# Disabling shallow clone is recommended for improving relevancy of reporting
24+
fetch-depth: 0
25+
- name: 'Login to GitHub Container Registry'
26+
uses: docker/login-action@v1
27+
with:
28+
registry: ghcr.io
29+
username: ${{github.actor}}
30+
password: ${{secrets.GITHUB_TOKEN}}
31+
- name: Get syft
32+
uses: anchore/sbom-action/[email protected]
33+
- name: Set up Go
34+
uses: actions/setup-go@v5
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v5
37+
with:
38+
args: release --clean
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/update-cache.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Prime cache, as per https://medium.com/@everton.spader/how-to-cache-package-dependencies-between-branches-with-github-actions-e6a19f33783a
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
11+
# Declare default permissions as read only.
12+
permissions: read-all
13+
14+
name: update-cache
15+
jobs:
16+
build-cache:
17+
name: Build Cache
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
23+
24+
- name: cache mise
25+
- uses: jdx/mise-action@0c39a522dfbced3ed83924152c45804a71ce216f # v2.0.4
26+
with:
27+
experimental: true
28+
cache: true

.gitignore

+51-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
/build/
2-
/dist/
1+
build/
2+
dist/
3+
.DS_Store
4+
**/.DS_Store
5+
6+
### GOLANG SPECIFIC ###
7+
#
8+
# Binaries for programs and plugins
9+
*.exe
10+
*.exe~
11+
*.dll
12+
*.so
13+
*.dylib
14+
15+
# Test binary, built with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
320

21+
# Dependency directories (remove the comment below to include it)
22+
# vendor/
423

5-
# PyCharm
6-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
7-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
8-
# and can be added to the global gitignore or merged into this file. For a more nuclear
9-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
10-
#.idea/
24+
# Go workspace file
25+
go.work
26+
go.work.sum
27+
28+
### END GOLANG SPECIFIC ###
29+
30+
### JETBRAINS SPECIFIC ###
31+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
32+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1133

1234
# User-specific stuff
1335
.idea/**/workspace.xml
@@ -31,6 +53,26 @@
3153
.idea/**/uiDesigner.xml
3254
.idea/**/dbnavigator.xml
3355

56+
# Gradle
57+
.idea/**/gradle.xml
58+
.idea/**/libraries
59+
60+
# Gradle and Maven with auto-import
61+
# When using Gradle or Maven with auto-import, you should exclude module files,
62+
# since they will be recreated, and may cause churn. Uncomment if using
63+
# auto-import.
64+
# .idea/artifacts
65+
# .idea/compiler.xml
66+
# .idea/jarRepositories.xml
67+
# .idea/modules.xml
68+
# .idea/*.iml
69+
# .idea/modules
70+
# *.iml
71+
# *.ipr
72+
73+
# CMake
74+
cmake-build-*/
75+
3476
# Mongo Explorer plugin
3577
.idea/**/mongoSettings.xml
3678

@@ -67,4 +109,4 @@ fabric.properties
67109
# Cody code completion
68110
.idea/cody_history.xml
69111

70-
.DS_Store
112+
### END JETBRAINS SPECIFIC ###

.goreleaser.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 1
10+
11+
before:
12+
hooks:
13+
# You may remove this if you don't use go modules.
14+
- go mod tidy
15+
16+
report_sizes: true
17+
18+
sboms:
19+
- artifacts: archive
20+
21+
# Enable verifiable builds
22+
gomod:
23+
proxy: true
24+
25+
builds:
26+
- main: ./cmd/sophrosyne
27+
env:
28+
- CGO_ENABLED=0
29+
goos:
30+
- linux
31+
goarch:
32+
- amd64
33+
- arm64
34+
binary: sophrosyne
35+
36+
archives:
37+
- format: tar.gz
38+
# this name template makes the OS and Arch compatible with the results of `uname`.
39+
name_template: >-
40+
{{ .ProjectName }}_
41+
{{- title .Os }}_
42+
{{- if eq .Arch "amd64" }}x86_64
43+
{{- else }}{{ .Arch }}{{ end }}
44+
{{- if .Arm }}v{{ .Arm }}{{ end }}
45+
46+
dockers:
47+
- id: sophrosyne_arm64
48+
use: buildx
49+
goos: linux
50+
goarch: arm64
51+
image_templates:
52+
- "ghcr.io/madsrc/sophrosyne:{{ .Version }}-arm64"
53+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}-arm64"
54+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}.{{ .Minor }}-arm64"
55+
dockerfile: Dockerfile
56+
build_flag_templates:
57+
- "--platform=linux/arm64"
58+
- id: sophrosyne_amd64
59+
use: buildx
60+
goos: linux
61+
goarch: amd64
62+
image_templates:
63+
- "ghcr.io/madsrc/sophrosyne:{{ .Version }}-amd64"
64+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}-amd64"
65+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}.{{ .Minor }}-amd64"
66+
dockerfile: Dockerfile
67+
build_flag_templates:
68+
- "--platform=linux/amd64"
69+
70+
docker_manifests:
71+
- name_template: "ghcr.io/madsrc/sophrosyne:{{ .Version }}"
72+
image_templates:
73+
- "ghcr.io/madsrc/sophrosyne:{{ .Version }}-amd64"
74+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}-amd64"
75+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}.{{ .Minor }}-amd64"
76+
- "ghcr.io/madsrc/sophrosyne:{{ .Version }}-arm64"
77+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}-arm64"
78+
- "ghcr.io/madsrc/sophrosyne:{{ .Major }}.{{ .Minor }}-arm64"
79+
80+
release:
81+
prerelease: auto
82+
83+
changelog:
84+
sort: asc
85+
filters:
86+
exclude:
87+
- "^docs:"
88+
- "^test:"

.idea/copyright/Sophrosyne.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.mise.toml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ protoc = "latest"
99
mockery = "latest"
1010
protoc-gen-go = "latest"
1111
protoc-gen-go-grpc = "latest"
12+
node = "latest"
13+
"go:github.com/goreleaser/goreleaser" = "latest"
1214

1315
[settings]
1416
experimental = true

.mise/tasks/build/dist

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
#!/bin/sh
2+
#
3+
# Sophrosyne
4+
# Copyright (C) 2024 Mads R. Havmand
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
20+
set -e
21+
# mise description="Builds distributables of Sophrosyne"
222
# mise sources=["go.mod", "go.sum", "internal/**/*", "cmd/**/*", "*.go"]
3-
# mise outputs=["dist/sophrosyne", "dist/sophrosyne_linux_amd64", "dist/sophrosyne_linux_arm64"]
4-
5-
goos=""
6-
goarch=""
7-
debug=1
8-
ldflags=""
923

1024
handle_argument() {
1125
echo "Argument '$1' not supported" >&2; exit 1
1226
}
1327

28+
snapshot=""
29+
1430
while test "$#" -gt 0; do
1531
case "$1" in
16-
-o) goos="$2"; shift 2;;
17-
-a) goarch="$2"; shift 2;;
18-
19-
--goos=*) goos="${1#*=}"; shift 1;;
20-
--goarch=*) goarch="${1#*=}"; shift 1;;
21-
--goos|--goarch) echo "$1 requires an argument" >&2; exit 1;;
22-
23-
--debug) debug=0; shift 1;;
32+
--snapshot) snapshot="--snapshot"; shift 1;;
2433

2534
-*) echo "unknown option: $1" >&2; exit 1;;
2635
*) handle_argument "$1"; shift 1;;
2736
esac
2837
done
2938

30-
if test "$debug" = 1; then
31-
ldflags="-s -w"
32-
fi
33-
34-
if test "$goarch" = ""; then
35-
GOOS="linux" GOARCH="amd64" go build -ldflags="$ldflags" -o dist/sophrosyne_linux_amd64 cmd/sophrosyne/main.go
36-
GOOS="linux" GOARCH="arm64" go build -ldflags="$ldflags" -o dist/sophrosyne_linux_arm64 cmd/sophrosyne/main.go
37-
else
38-
GOOS="$goos" GOARCH="$goarch" go build -ldflags="$ldflags" -o dist/sophrosyne cmd/sophrosyne/main.go
39-
fi
39+
goreleaser build $snapshot --clean

.mise/tasks/build/docker

-25
This file was deleted.

.mise/tasks/clean

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
#!/bin/sh
2+
#
3+
# Sophrosyne
4+
# Copyright (C) 2024 Mads R. Havmand
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
20+
set -e
21+
# mise description="Clean up local build artifacts"
222

323
rm -rf build
424
rm -rf dist

0 commit comments

Comments
 (0)