-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dweb Fan <[email protected]>
- Loading branch information
Showing
14 changed files
with
169 additions
and
13 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,33 @@ | ||
name: test-pr | ||
on: | ||
push: | ||
#pull_request: | ||
# types: | ||
# - opened | ||
# - synchronize | ||
# - reopened | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: lomorage/lomo-backup:1.0 | ||
env: | ||
PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin | ||
GOFLAGS: "-buildvcs=false" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: make lint | ||
|
||
install: | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: lomorage/lomo-backup:1.0 | ||
env: | ||
PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin | ||
GOBIN: /usr/local/bin | ||
GOFLAGS: "-buildvcs=false" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
- run: make install |
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 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
# default linter | ||
- govet | ||
#- errcheck | ||
- staticcheck | ||
- unused | ||
- gosimple | ||
- ineffassign | ||
# enabled linter | ||
- bodyclose # checks whether HTTP response body is closed successfully | ||
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. | ||
# rowserrcheck - checks whether Err of rows is checked successfully | ||
# stylecheck - Stylecheck is a replacement for golint | ||
# gosec - Inspects source code for security problems | ||
# interfacer - Linter that suggests narrower interface types | ||
- unconvert # Remove unnecessary type conversions | ||
# dupl - Tool for code clone detection | ||
# goconst - Finds repeated strings that could be replaced by a constant | ||
- gocyclo # Computes and checks the cyclomatic complexity of functions | ||
# gocognit - Computes and checks the cognitive complexity of functions | ||
# asciicheck - Simple linter to check that your code does not contain non-ASCII identifiers | ||
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification | ||
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports | ||
# maligned - Tool to detect Go structs that would take less memory if their fields were sorted | ||
# - depguard # Go linter that checks if package imports are in a list of acceptable packages | ||
- misspell # Finds commonly misspelled English words in comments | ||
#- lll # Reports long lines | ||
- unparam # Reports unused function parameters | ||
# dogsled - Checks assignments with too many blank identifiers (e.g. x, , , _, := f()) | ||
# - nakedret # Finds naked returns in functions greater than a specified function length | ||
- prealloc # Finds slice declarations that could potentially be preallocated | ||
# scopelint - Scopelint checks for unpinned variables in go programs | ||
# gocritic - The most opinionated Go source code linter | ||
# gochecknoinits - Checks that no init functions are present in Go code | ||
# gochecknoglobals - Checks that no globals are present in Go code | ||
# godox - Tool for detection of FIXME, TODO and other comment keywords | ||
# funlen - Tool for detection of long functions | ||
- whitespace # Tool for detection of leading and trailing whitespace | ||
# wsl - Whitespace Linter - Forces you to use empty lines! | ||
# goprintffuncname - Checks that printf-like functions are named with f at the end | ||
# gomnd - An analyzer to detect magic numbers. | ||
# goerr113 - Golang linter to check the errors handling expressions | ||
# gomodguard - Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. | ||
# godot # Check if comments end in a period | ||
# testpackage - linter that makes you use a separate _test package | ||
# nestif - Reports deeply nested if statements | ||
# exportloopref - An analyzer that finds exporting pointers for loop variables. | ||
# nolintlint - Reports ill-formed or insufficient nolint directives | ||
- typecheck | ||
linters-settings: | ||
revive: | ||
confidence: 0.7 | ||
issues: | ||
exclude-use-default: false | ||
run: | ||
deadline: 20m |
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,26 @@ | ||
.PHONY: vendor | ||
|
||
SHELL=/bin/bash # Use bash syntax | ||
GOPATH=/go | ||
|
||
vendor: | ||
go mod vendor | ||
|
||
lint: | ||
golangci-lint run --modules-download-mode vendor -v --max-same-issues 10 | ||
|
||
install: | ||
go install -v ./cmd/... | ||
|
||
dev-container: | ||
docker build --tag "lomorage/lomo-backup:1.0" -f dockerfiles/dev-image . | ||
|
||
dev: | ||
docker build --tag "lomorage/lomo-backup" -f dockerfiles/dev-run . | ||
docker rm -f lomo-backup | ||
docker run \ | ||
--name lomo-backup --hostname lomo-backup \ | ||
--privileged --cap-add=ALL -v /dev:/dev -v /lib/modules:/lib/modules \ | ||
-v "${PWD}:/go/src/github.com/lomorage/lomo-backup" \ | ||
--net host --dns-search local \ | ||
-it "lomorage/lomo-backup" -d bash |
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
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
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
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
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
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
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
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
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,19 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV GOPATH=/go | ||
|
||
RUN apt-get -yqq update && apt-get install -yq --no-install-recommends man-db vim build-essential \ | ||
sqlite3 curl apt-transport-https ca-certificates software-properties-common \ | ||
&& apt-get install -yq sqlite3 \ | ||
&& apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
# install docker | ||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
RUN apt-get -yqq update && apt-get install -yq docker-ce && apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
|
||
RUN curl -fsSL https://go.dev/dl/go1.21.0.linux-amd64.tar.gz | tar xz -C /usr/local | ||
|
||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.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,9 @@ | ||
FROM "lomorage/lomo-backup:1.0" | ||
ENV GOPATH=/go | ||
ENV GOROOT=/usr/local/go | ||
ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin | ||
WORKDIR /go/src/github.com/lomorage/lomo-backup | ||
|
||
COPY ./dockerfiles/entrypoint.sh /entrypoint.sh | ||
RUN chmod 755 /entrypoint.sh | ||
ENTRYPOINT /entrypoint.sh "$@" |
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,8 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
echo user: $USER | ||
echo uid: $UID | ||
|
||
$@ |