-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitrii Shcherbakov
committed
Feb 29, 2024
1 parent
b3aae69
commit d88393b
Showing
183 changed files
with
47,407 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
GEEKSONATOR_TELEGRAM_BOT_TOKEN=bot_token_here | ||
GEEKSONATOR_TELEGRAM_TIMEOUT_SECONDS=15 | ||
GEEKSONATOR_DEBUG_MODE=false | ||
GEEKSONATOR_DEBUG_TELEGRAM_BOT_TOKEN=debug_bot_token_here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: audit | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
audit: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: ["1.21"] | ||
|
||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/checkout@v4 | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.51 | ||
|
||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Display Go version | ||
run: go version | ||
|
||
- name: Install dependencies | ||
run: | | ||
go mod tidy | ||
go mod vendor | ||
go install github.com/vektra/mockery/[email protected] | ||
- name: Run golangci-lint | ||
run: golangci-lint run | ||
|
||
- name: Run test | ||
run: go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: deploy to ghcr.io | ||
|
||
on: | ||
push: | ||
# run only against tags | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/checkout@main | ||
|
||
- name: Fetch tags | ||
run: git fetch --force --tags | ||
|
||
- name: Display tag | ||
run: echo ${{github.ref_name}} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Build Image | ||
run: docker build . --tag ghcr.io/phpgeeks-club/geeksonator:${{github.ref_name}} | ||
|
||
- name: Push Image | ||
run: docker push ghcr.io/phpgeeks-club/geeksonator:${{github.ref_name}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
# run only against tags | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Fetch tags | ||
run: git fetch --force --tags | ||
|
||
- name: Display tag | ||
run: echo ${{github.ref_name}} | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
|
||
- name: Display Go version | ||
run: go version | ||
|
||
- name: Create release | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.vscode | ||
geeksonator | ||
.vscode/ | ||
bin/ | ||
dist/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
run: | ||
concurrency: 4 | ||
timeout: 5m | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
- contextcheck | ||
- cyclop | ||
- dogsled | ||
- dupl | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- gci | ||
- gocheckcompilerdirectives | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- godox | ||
- gofmt | ||
- goimports | ||
- gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- importas | ||
- ineffassign | ||
- maintidx | ||
- makezero | ||
- misspell | ||
- musttag | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- nosprintfhostport | ||
- paralleltest | ||
- prealloc | ||
- predeclared | ||
- reassign | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- tagliatelle | ||
- thelper | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- whitespace | ||
- wrapcheck | ||
|
||
linters-settings: | ||
errorlint: | ||
errorf: false | ||
gci: | ||
sections: | ||
- standard | ||
- default | ||
- prefix(geeksonator) | ||
gocognit: | ||
min-complexity: 10 | ||
gocyclo: | ||
min-complexity: 10 | ||
nestif: | ||
min-complexity: 4 | ||
unparam: | ||
check-exported: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
project_name: geeksonator | ||
builds: | ||
- id: geeksonator | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
main: ./cmd/geeksonator | ||
binary: ./bin/geeksonator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
quiet: true | ||
with-expecter: true | ||
disable-config-search: true | ||
dir: "{{.InterfaceDir}}/mocks" | ||
mockname: "{{.InterfaceName}}Mock" | ||
filename: "{{.InterfaceName | snakecase}}_mock.go" | ||
outpkg: "mocks" | ||
packages: | ||
geeksonator/internal/observer: | ||
geeksonator/internal/provider/telegram: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
golang 1.21.4 | ||
golangci-lint 1.55.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Run | ||
# docker build -f ./Dockerfile -t geeksonator:latest . | ||
# docker run -d --env-file=/path/to/.env --name geeksonator.app geeksonator:latest . | ||
|
||
################################## | ||
# STEP 1 build executable binary # | ||
################################## | ||
|
||
FROM golang:1.21.4-alpine as builder | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/phpgeeks-club/admin-bot" | ||
|
||
# Install git + SSL ca certificates. | ||
# Git is required for fetching the dependencies. | ||
# Ca-certificates is required to call HTTPS endpoints. | ||
RUN apk update && apk add --no-cache git ca-certificates tzdata make && update-ca-certificates | ||
|
||
# Create appuser. | ||
ENV USER=appuser | ||
ENV UID=10001 | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
# Build the binary. | ||
RUN make build | ||
|
||
############################## | ||
# STEP 2 build a small image # | ||
############################## | ||
|
||
FROM scratch | ||
|
||
# Import from builder. | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/group /etc/group | ||
|
||
# Copy our static executable. | ||
COPY --from=builder /app/bin/geeksonator /app/geeksonator | ||
|
||
# Use an unprivileged user. | ||
USER appuser:appuser | ||
|
||
# Run the binary. | ||
ENTRYPOINT ["/app/geeksonator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.EXPORT_ALL_VARIABLES: | ||
GOBIN = $(shell pwd)/bin | ||
|
||
.PHONY: deps | ||
deps: | ||
@go mod tidy | ||
@go mod vendor | ||
|
||
.PHONY: mocks | ||
mocks: tools | ||
@export PATH="$(shell pwd)/bin:$(PATH)"; mockery --config=.mockery.yaml | ||
|
||
.PHONY: lint | ||
lint: | ||
@golangci-lint run | ||
|
||
.PHONY: test | ||
test: | ||
@go test ./... | ||
|
||
.PHONY: build | ||
build: deps | ||
@GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o ./bin/geeksonator ./cmd/geeksonator | ||
|
||
.PHONY: tools | ||
tools: deps | ||
@go install github.com/vektra/mockery/[email protected] | ||
@go install github.com/goreleaser/[email protected] |
Oops, something went wrong.