Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ RUN apt-get install -y ca-certificates openssl wget git git-lfs tar gnupg2 gcc
RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz

ENV PATH /usr/local/go/bin:$PATH
ENV PATH=/usr/local/go/bin:$PATH

ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH"
WORKDIR $GOPATH
RUN go install -v golang.org/x/tools/gopls@latest \
&& go install github.com/go-delve/delve/cmd/dlv@latest \
&& go install honnef.co/go/tools/cmd/staticcheck@latest \
&& go install golang.org/x/vuln/cmd/govulncheck@latest \
&& go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest \
&& go install gotest.tools/gotestsum@latest
&& go install gotest.tools/gotestsum@latest \
&& go install github.com/segmentio/golines@latest

FROM base AS dev

RUN go install github.com/pact-foundation/pact-go/v2@v2.0.2 \
&& go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest \
&& go install github.com/google/go-licenses@latest \
&& go install golang.org/x/vuln/cmd/govulncheck@latest
&& go install github.com/google/go-licenses@latest
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "CANOPENREST",
"image": "devcontainer-go-dev:latest",
"image": "ghcr.io/jaster-prj/devcontainer-go-base:latest",
"runArgs": [
"--name=CANOPENREST_Devcontainer"
"--name",
"CANOPENREST_Devcontainer"
],
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["golang.Go"],
"extensions": [
"golang.Go",
"stkb.rewrap"
],
"settings": {
"extensions.verifySignature": false
}
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: go - ci/cd release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+'

env:
SERVICE: canopenrest

jobs:
release-binaries:
name: release
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64, arm]
exclude:
- goos: darwin
goarch: arm
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v6

- uses: wangyoucao577/go-release-action@v1.49
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.26
binary_name: canopenrest
compress_assets: false
ldflags: -X "main.version=${{ github.ref_name }}"
env:
CGO_ENABLED: 0
15 changes: 15 additions & 0 deletions .github/workflows/ci-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: go - ci/cd stable

on:
push:
branches: [ "main" ]
workflow_dispatch:

env:
SERVICE: canopenrest


jobs:

ci:
uses: ./.github/workflows/ci.yml
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: go ci

env:
SERVICE: canopenrest

on:
pull_request:
branches: [ "main" ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Setup gotestsum
run: |
go install gotest.tools/gotestsum@latest

- name: Get dependencies
run: |
go get -v -t -d

- name: Test
run: |
gotestsum --format testname --junitfile report.xml ./...

- name: Publish test results
uses: actions/upload-artifact@v7
with:
name: test-results
path: report.xml

- name: Build
run: |
go build -trimpath -ldflags="-s -w" -o bin/${{ env.SERVICE }} ./cmd

- name: Upload service for job sharing
uses: actions/upload-artifact@v3
with:
name: ${{ env.SERVICE }}
path: bin/${{ env.SERVICE }}
retention-days: 5

name: Test Report
uses: dorny/test-reporter@v3
with:
name: go tests
path: report.xml
reporter: java-junit

check:
runs-on: ubuntu-latest
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Static-Check
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...

- name: Dependency-Update-Check
if: github.ref != 'refs/heads/main'
run: |
go get -u ./...
go mod tidy
if git diff --quiet -- go.mod go.sum
then
echo Project dependencies are up to date.
else
echo Project dependencies are outdatet.
echo Run \'go get -u ./... && go mod tidy\' to update project dependecies.
exit 1
fi

- name: Misspell-Check
run: |
go install github.com/client9/misspell/cmd/misspell@latest
find . -type f -name '*.go' | xargs misspell -error

- name: Vulnerability-Check
if: github.ref != 'refs/heads/main'
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

- name: Install go-licenses
run: go install github.com/google/go-licenses@latest

- name: Check Licenses
run: |
go-licenses check ./cmd/... --skip_headers --allowed_licenses="$(paste -sd, license_whitelist)"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 C3Re

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 0 additions & 22 deletions common/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import (
"reflect"
)

func POINTER[T any](val T) *T {
return &val
}

func NEWSTRINGPOINTER[T *string](val T) T {
if val == nil {
return nil
}
tmp := *val
return &tmp
}

func MATCHSLICES[T any](slice1 []T, slice2 []T) []T {
return_slice := []T{}
for _, value1 := range slice1 {
Expand All @@ -27,13 +15,3 @@ func MATCHSLICES[T any](slice1 []T, slice2 []T) []T {
}
return return_slice
}

// CONTAINS checks if list contains e
func CONTAINS[C comparable](list []C, e C) bool {
for _, element := range list {
if element == e {
return true
}
}
return false
}
Loading