-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big refactoring #8
Open
DimNS
wants to merge
1
commit into
master
Choose a base branch
from
dimns-refactor-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.55.2 | ||
|
||
- 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Класть папки IDE в gitignore считается антипаттерном https://habr.com/ru/articles/202696/