Skip to content

Commit

Permalink
Basic windows support (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer authored Aug 27, 2024
1 parent 8e0c4a6 commit 76df3df
Show file tree
Hide file tree
Showing 174 changed files with 4,717 additions and 1,183 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{go,go.tmpl}]
indent_style = tab
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.go text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
*.json text eol=lf
*.sh text eol=lf
*.md text eol=lf

61 changes: 49 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Continuous Integration

on:
push:

Expand All @@ -13,7 +12,7 @@ jobs:
name: Tests
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand All @@ -22,6 +21,7 @@ jobs:
go-version: stable

- name: Install Ubuntu dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install libpam0g-dev

- name: Checkout code
Expand All @@ -40,26 +40,63 @@ jobs:
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

- name: Install Syft
uses: anchore/sbom-action/[email protected]

- name: Test
run: |
mkdir -p var
go test -v -covermode atomic "-coverprofile=var/profile.cov" ./...
- name: Send coverage
if: false
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
goveralls "-coverprofile=profile.cov" "-service=github" "-parallel" "-flagname=go-${{ matrix.os }}"
package:
name: Package
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Install Ubuntu dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install libpam0g-dev

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Syft
uses: anchore/sbom-action/[email protected]

- name: GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: build --snapshot --clean
args: release --snapshot --clean
env:
BIFROEST_VENDOR: engity

- name: Send coverage
if: false
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
goveralls "-coverprofile=profile.cov" "-service=github" "-parallel" "-flagname=go-${{ matrix.os }}"
- name: Archive package results
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: dist
path: |
var/dist/*.tgz*
var/dist/*.zip*
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint
on:
push:

pull_request:
types:
- opened
- reopened

permissions:
contents: read

jobs:
golangci:
name: "golangci-lint"
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: stable

- name: Install Ubuntu dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install libpam0g-dev

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: 20m

linters:
enable:
- asasalint
- asciicheck
- bidichk
- misspell
disable:
- ineffassign

linters-settings:
misspell:
locale: US
ignore-words:
- engity
- bifröst
- bifroest

issues:
exclude-dirs:
- internal/fmtsort
- internal/text
exclude:
- S1002
- S1016
- SA1012
- S1031
- SA1019
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ builds:
binary: bifroest
goos:
- linux
- windows
env:
- CGO_ENABLED=0
goarch:
Expand Down
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions cmd/bifroest/dummy-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package main
import (
"context"
"fmt"
"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"
"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/errors"
"net"
"net/http"
"os"
"os/signal"
"strings"
"syscall"

"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/errors"
)

var (
Expand Down Expand Up @@ -83,7 +85,7 @@ func dummyServerHandleIndex(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodHead {
return
}
_, err = fmt.Fprintf(w, `Hello from a dummy-server!
_, _ = fmt.Fprintf(w, `Hello from a dummy-server!
Called URI: %v
Method: %v
Expand Down
4 changes: 0 additions & 4 deletions cmd/bifroest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
"github.com/echocat/slf4g/native/facade/value"
)

const (
defaultConfigurationRef = "/etc/engity/bifroest/configuration.yaml"
)

var (
configurationRef configuration.ConfigurationRef
registerCommands []func(*kingpin.Application)
Expand Down
7 changes: 7 additions & 0 deletions cmd/bifroest/main_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build unix

package main

const (
defaultConfigurationRef = "/etc/engity/bifroest/configuration.yaml"
)
7 changes: 7 additions & 0 deletions cmd/bifroest/main_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build windows

package main

const (
defaultConfigurationRef = `C:\ProgramData\Engity\Bifroest\configuration.yaml`
)
9 changes: 6 additions & 3 deletions cmd/bifroest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package main

import (
"context"
"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"
"github.com/engity-com/bifroest/pkg/service"
"os"
"os/signal"
"syscall"

"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"

"github.com/engity-com/bifroest/pkg/service"
)

var _ = registerCommand(func(app *kingpin.Application) {
Expand All @@ -25,6 +27,7 @@ var _ = registerCommand(func(app *kingpin.Application) {
func doRun() error {
svc := service.Service{
Configuration: *configurationRef.Get(),
Version: versionV,
}

fail := func(err error) error {
Expand Down
Loading

0 comments on commit 76df3df

Please sign in to comment.