diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f24c70f..cbe47fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,8 +40,6 @@ jobs: echo "VERSION -> $GITVERSION_SEMVER" test: runs-on: ubuntu-latest - container: - image: golang:1.24-bookworm needs: set-version env: SEMVER: ${{ needs.set-version.outputs.semVer }} @@ -51,25 +49,18 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - name: Install Task - uses: arduino/setup-task@v2 - with: - version: 3.x - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: install deps - run: | - apt update && apt install -y jq git unzip - git config --global --add safe.directory "$GITHUB_WORKSPACE" - git config user.email ${{ github.actor }}-ci@gha.org - git config user.name ${{ github.actor }} + - name: Install Eirctl + uses: ensono/actions/eirctl-setup@v0.3.1 + with: + version: 0.6.5 + isPrerelease: false - name: Run Lint run: | - task lint + eirctl run pipeline lint - name: Run Tests run: | - task coverage + eirctl run pipeline test ls -alt .coverage/out ls -lat .coverage/report-junit.xml - name: Publish Junit style Test Report diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29c1d15..040ca81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,10 +40,6 @@ jobs: release: runs-on: ubuntu-latest - container: - image: golang:1.24-bookworm - env: - FOO: Bar needs: set-version env: SEMVER: ${{ needs.set-version.outputs.semVer }} @@ -52,24 +48,23 @@ jobs: with: fetch-depth: 1 - - name: Install Task - uses: arduino/setup-task@v2 - with: - version: 3.x - repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install Eirctl + uses: ensono/actions/eirctl-setup@v0.3.1 + with: + version: 0.6.5 + isPrerelease: false - - name: install deps + - name: release library run: | - apt-get update && apt-get install jq git -y git config --global --add safe.directory "$GITHUB_WORKSPACE" git config user.email ${{ github.actor }}-ci@gha.org git config user.name ${{ github.actor }} - - name: release library - run: | - task tag GIT_TAG=${SEMVER} REVISION=$GITHUB_SHA + GIT_TAG=${SEMVER} REVISION=$GITHUB_SHA eirctl run tag + - name: build binary run: | - task bin REVISION=$GITHUB_SHA GIT_TAG=${SEMVER} + eirctl run pipeline build:bin --set VERSION=${SEMVER} --set REVISION=$GITHUB_SHA + - name: Release binary uses: softprops/action-gh-release@v2 with: diff --git a/eirctl.yaml b/eirctl.yaml new file mode 100644 index 0000000..667116d --- /dev/null +++ b/eirctl.yaml @@ -0,0 +1,174 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Ensono/eirctl/refs/heads/main/schemas/schema_v1.json + +output: prefixed +debug: false + +contexts: + go1x: + container: + name: golang:1.24.4-bookworm + enable_dind: true + enable_mount: true + envfile: + exclude: + - GO + - CXX + - CGO + + golint: + container: + name: golangci/golangci-lint:v2.1.5-alpine + enable_dind: true + enable_mount: true + envfile: + exclude: + - GO + - CXX + - CGO + - PATH + - HOME + +tasks: + clean: + context: go1x + command: + - rm -rf dist/* + - rm -rf .coverage + - mkdir -p dist .coverage + + run:test: + description: Runs the tests + context: go1x + command: + - | + go test ./... -v -buildvcs=false -mod=readonly -race -coverpkg=./... -coverprofile=.coverage/out | tee .coverage/unit + + install: + description: Install dependencies + command: | + go mod tidy + + lint:vet: + description: Runs lint and vet + context: go1x + command: | + go vet + + golint: + # in CI it is run + context: golint + description: Runs the linter and go vet and other default static checks + allow_failure: false + command: + # echo "lint ran with exit code: $?" + # pwd && ls -lat + - | + golangci-lint run + + vuln:check: + context: go1x + description: | + Runs a vulnerability scan against the code base + command: + - | + go install golang.org/x/vuln/cmd/govulncheck@latest + govulncheck ./... + + coverage: + description: generate coverage + context: go1x + command: + - | + go install github.com/jstemmer/go-junit-report/v2@latest + go install github.com/axw/gocov/gocov@latest + go install github.com/AlekSi/gocov-xml@latest + go-junit-report -in .coverage/unit > .coverage/report-junit.xml + gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml + + show:coverage: + description: Opens the current coverage viewer for the the configmanager utility. + command: go tool cover -html=.coverage/out + + show_docs: + description: | + Opens a webview with godoc running + Already filters the packages to this one and enables + internal/private package documentation +# go install golang.org/x/tools/cmd/godoc@latest + command: | + open http://localhost:6060/pkg/github.com/DevLabFoundry/configmanager/v2/?m=all + godoc -notes "BUG|TODO" -play -http=:6060 + + build:binary: + context: go1x + description: | + Generates binaries in a dist folder + + Generates all the binaries for the configmanager utility. + command: + - | + ldflags="-s -w -X \"github.com/DevLabFoundry/configmanager/v2/cmd/configmanager.Version={{.VERSION}}\" -X \"github.com/DevLabFoundry/configmanager/v2/cmd/configmanager.Revision={{.REVISION}}\" -extldflags -static" + GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} CGO_ENABLED=0 go build -mod=readonly -buildvcs=false -ldflags="$ldflags" \ + -o ./dist/configmanager-${GOOS}-${GOARCH}${BUILD_SUFFIX} ./cmd + reset_context: true + variations: + - BUILD_GOOS: darwin + BUILD_GOARCH: amd64 + BUILD_SUFFIX: "" + - BUILD_GOOS: darwin + BUILD_GOARCH: arm64 + BUILD_SUFFIX: "" + - BUILD_GOOS: linux + BUILD_GOARCH: amd64 + BUILD_SUFFIX: "" + - BUILD_GOOS: linux + BUILD_GOARCH: arm64 + BUILD_SUFFIX: "" + - BUILD_GOOS: windows + BUILD_GOARCH: amd64 + BUILD_SUFFIX: ".exe" + - BUILD_GOOS: windows + BUILD_GOARCH: arm64 + BUILD_SUFFIX: ".exe" + - BUILD_GOOS: windows + BUILD_GOARCH: "386" + BUILD_SUFFIX: ".exe" + required: + args: + - VERSION + - REVISION + + tag: + description: | + Usage `eirctl tag GIT_TAG=2111dsfsdfa REVISION=as2342432` + + command: | + git tag -a ${VERSION} -m "ci tag release" ${REVISION} + git push origin ${VERSION} + required: + env: + - VERSION + - REVISION + +pipelines: + test: + - task: clean + - task: run:test + depends_on: clean + - task: coverage + depends_on: run:test + + lint: + - task: lint:vet + - task: vuln:check + + show_coverage: + - pipeline: test + - task: show:coverage + depends_on: test + + build:bin: + - task: clean + - task: build:binary + depends_on: clean + diff --git a/go.mod b/go.mod index 92a5b0f..04f1901 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/DevLabFoundry/configmanager/v2 -go 1.24.3 +go 1.24.4 require ( cloud.google.com/go/secretmanager v1.14.7 diff --git a/sonar-project.properties b/sonar-project.properties index 1536a52..4869d51 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,4 +12,5 @@ sonar.tests=. sonar.test.inclusions=**/*_test.go sonar.test.exclusions=**/*_generated*.go,**/*_generated/**,**/vendor/** -sonar.sourceEncoding=UTF-8 \ No newline at end of file +sonar.sourceEncoding=UTF-8 +sonar.qualitygate.wait=true diff --git a/taskfile.yml b/taskfile.yml deleted file mode 100644 index 6a2c9e1..0000000 --- a/taskfile.yml +++ /dev/null @@ -1,105 +0,0 @@ -# yaml-language-server: $schema=https://taskfile.dev/schema.json -version: '3' - -env: - OWNER: DevLabFoundry - NAME: configmanager - GO_TARGET_ARCH: "darwin" - GIT_TAG: "0.0.0" - VERSION: "v{{.GIT_TAG}}" - REVISION: '{{.REVISION | default "aaaa1234" }}' - -tasks: - test_prereq: - internal: true - preconditions: - - go version - cmd: | - mkdir -p .coverage - go install github.com/jstemmer/go-junit-report/v2@latest - go install github.com/axw/gocov/gocov@latest - go install github.com/AlekSi/gocov-xml@latest - - clean_go: - internal: true - cmds: - - rm -rf dist/* - - rm -rf .coverage - - mkdir -p dist - - test: - desc: Install dependencies - internal: false - deps: - - test_prereq - cmds: - - | - set -exo pipefail - go test ./... -v -buildvcs=false -mod=readonly -race -coverpkg=./... -coverprofile=.coverage/out | tee .coverage/unit - - install: - desc: Install dependencies - internal: true - cmd: | - go mod tidy - - lint: - desc: Runs lint and vet - cmd: | - go vet - - coverage: - desc: generate coverage - deps: - - test - cmds: - - go-junit-report -in .coverage/unit > .coverage/report-junit.xml - - gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml - - show_coverage: - desc: Opens the current coverage viewer for the the configmanager utility. - deps: - - coverage - cmd: go tool cover -html=.coverage/out - - show_docs: - desc: Opens a webview with godoc running - summary: | - Already filters the packages to this one and enables - internal/private package documentation -# go install golang.org/x/tools/cmd/godoc@latest - cmd: | - open http://localhost:6060/pkg/github.com/DevLabFoundry/configmanager/v2/?m=all - godoc -notes "BUG|TODO" -play -http=:6060 - - bin: - desc: Generates binaries in a dist folder - summary: | - Generates all the binaries for the configmanager utility. - - can be called from inside CI like this: - - `task bin GIT_TAG=0.1.2 REVISION=$commit_sha` - deps: - - clean_go - cmds: - - cmd: mkdir -p ./dist - - for: { var: GO_ARCHS, as: GO_TARGET_ARCH } - cmd: | - GOOS={{.GO_TARGET_ARCH}} CGO_ENABLED=0 go build -mod=readonly -buildvcs=false {{.LDFLAGS}} -o ./dist/configmanager-{{.GO_TARGET_ARCH}} ./cmd - - for: { var: GO_ARCHS, as: GO_TARGET_ARCH } - cmd: | - GOOS={{.GO_TARGET_ARCH}} GOARCH=arm64 CGO_ENABLED=0 go build -mod=readonly -buildvcs=false {{.LDFLAGS}} -o ./dist/configmanager-{{.GO_TARGET_ARCH}}-arm64 ./cmd - - for: { var: GO_ARCHS, as: GO_TARGET_ARCH } - cmd: | - GOOS={{.GO_TARGET_ARCH}} GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -buildvcs=false {{.LDFLAGS}} -o ./dist/configmanager-{{.GO_TARGET_ARCH}}-amd64 ./cmd - vars: - LDFLAGS: -ldflags="-s -w -X \"github.com/DevLabFoundry/configmanager/v2/cmd/configmanager.Version=${VERSION}\" -X \"github.com/DevLabFoundry/configmanager/v2/cmd/configmanager.Revision={{.REVISION}}\" -extldflags -static" - GO_ARCHS: darwin windows linux - - tag: - desc: | - Usage `task tag GIT_TAG=2111dsfsdfa REVISION=as2342432` - cmd: | - git tag -a ${VERSION} -m "ci tag release" ${REVISION} - git push origin ${VERSION}