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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
153 changes: 103 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: set up go 1.22
uses: actions/setup-go@v5
- name: checkout
uses: actions/checkout@v6

- name: set up go 1.26
uses: actions/setup-go@v6
with:
go-version: "1.22"
go-version: "1.26"
id: go

- name: checkout
uses: actions/checkout@v4

- name: build and test
run: |
go test -race -timeout=60s -v -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp ./...
Expand All @@ -28,12 +28,11 @@ jobs:
working-directory: app
env:
TZ: "America/Chicago"
MONGO_TEST: mongodb://127.0.0.1:27017

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.58
version: v2.9.0
env:
TZ: "America/Chicago"

Expand All @@ -44,49 +43,103 @@ jobs:
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: set up QEMU
uses: docker/setup-qemu-action@v3
docker:
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
artifact: linux-amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
artifact: linux-arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6

- name: set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3

- name: available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PKG_TOKEN }}

- name: build and deploy master image to ghcr.io and dockerhub
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
- uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
CI=github
GITHUB_SHA=${{ github.sha }}
GIT_BRANCH=${{ github.ref_name }}
outputs: type=image,"name=ghcr.io/${{ github.actor }}/docker-logger,${{ github.actor }}/docker-logger",push-by-digest=true,name-canonical=true,push=true

- name: export digest
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/${USERNAME}/docker-logger:${ref} -t ${USERNAME}/docker-logger:${ref} .

- name: deploy tagged (latest) to ghcr.io and dockerhub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- uses: actions/upload-artifact@v6
with:
name: digests-${{ matrix.artifact }}
path: /tmp/digests/*
retention-days: 1

docker-merge:
needs: docker
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v7
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PKG_TOKEN }}

- uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: determine tags
id: tags
run: |
ref="${GITHUB_REF#refs/*/}"
ref="${ref//\//_}"
echo "ref=${ref}" >> $GITHUB_OUTPUT
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
echo "is_tag=true" >> $GITHUB_OUTPUT
else
echo "is_tag=false" >> $GITHUB_OUTPUT
fi

- name: create manifest and push
working-directory: /tmp/digests
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/${USERNAME}/docker-logger:${ref} -t ghcr.io/${USERNAME}/docker-logger:latest \
-t ${USERNAME}/docker-logger:${ref} -t ${USERNAME}/docker-logger:latest .
ref="${{ steps.tags.outputs.ref }}"
is_tag="${{ steps.tags.outputs.is_tag }}"
tags="-t ghcr.io/${{ github.actor }}/docker-logger:${ref} -t ${{ github.actor }}/docker-logger:${ref}"
if [[ "$is_tag" == "true" ]]; then
tags="${tags} -t ghcr.io/${{ github.actor }}/docker-logger:latest -t ${{ github.actor }}/docker-logger:latest"
fi
docker buildx imagetools create ${tags} \
$(printf 'ghcr.io/${{ github.actor }}/docker-logger@sha256:%s ' *)
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/logs/
.DS_Store
.vscode
.idea
.idea
.ralphex
182 changes: 95 additions & 87 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,105 @@
linters-settings:
govet:
enable:
- shadow
gocyclo:
min-complexity: 15
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: US
lll:
line-length: 140
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport
- ifElseChain
- octalLiteral
- whyNoLint
- rangeValCopy
- hugeParam

version: "2"
run:
concurrency: 4
linters:
disable-all: true
default: none
enable:
- staticcheck
- revive
- govet
- unconvert
- gosec
- misspell
- unparam
- typecheck
- ineffassign
- unused
- stylecheck
- exportloopref
- gocritic
- nakedret
- gosimple
- prealloc
- bodyclose
- goimports
- gofmt
- gochecknoinits
- errcheck
- goprintffuncname
- lll
- dogsled
- whitespace
- gochecknoglobals
- copyloopvar
- dupl
- durationcheck
- errcheck
- errname
- exhaustive
- funlen
- gochecknoinits
- goconst
- gocritic
- gosec
- govet
- ineffassign
- misspell
- modernize
- nakedret
- nestif
- nilerr
- tenv
- prealloc
- revive
- staticcheck
- testifylint
- unconvert
- unparam
- unused
- usestdlibvars
fast: false


run:
concurrency: 8

issues:
exclude-dirs:
- vendor
exclude-rules:
- text: "should have a package comment"
linters:
- golint
- text: "package-comments: should have a package comment"
linters:
- revive
- text: "exitAfterDefer:"
linters:
- gocritic
- text: "whyNoLint: include an explanation for nolint directive"
linters:
- gocritic
- text: "weak cryptographic primitive"
linters:
- gosec
- text: "at least one file in a package should have a package comment"
linters:
- stylecheck
exclude-use-default: false
- whitespace
settings:
exhaustive:
default-signifies-exhaustive: true
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
gocritic:
disabled-checks:
- dupImport
- ifElseChain
- hugeParam
- rangeValCopy
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
enable:
- shadow
misspell:
locale: US
exclusions:
generated: lax
rules:
- linters:
- revive
text: "package-comments: should have a package comment"
- linters:
- staticcheck
text: at least one file in a package should have a package comment
- linters:
- gocritic
text: "exitAfterDefer:"
- linters:
- gocritic
text: "whyNoLint: include an explanation for nolint directive"
- linters:
- gosec
text: "weak cryptographic primitive"
- linters:
- dupl
- goconst
- usestdlibvars
path: _test\.go$
- linters:
- revive
- unparam
- unused
path: _test\.go$
text: unused-parameter
- linters:
- errcheck
text: "Error return value of .*.Close.*is not checked"
- linters:
- revive
path: app/syslog/
text: "var-naming: avoid package names that conflict"
paths:
- vendor
- third_party$
- builtin$
formatters:
exclusions:
generated: lax
paths:
- vendor
- third_party$
- builtin$
Loading