-
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
Borja Aranda
committed
Jun 21, 2023
1 parent
fd086fa
commit 6aecbcc
Showing
43 changed files
with
6,974 additions
and
0 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,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gomod | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: github-actions | ||
directory: '/' | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 |
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,30 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
paths: | ||
- "cmd/**" | ||
- "pkg/**" | ||
- ".github/workflows/build.yml" | ||
|
||
jobs: | ||
build_bif: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 | ||
id: tool-versions | ||
|
||
- name: Setup go ${{ steps.tool-versions.outputs.golang_version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ steps.tool-versions.outputs.golang_version }} | ||
|
||
- name: Make build | ||
run: make build | ||
|
||
- name: Make clean | ||
run: make clean |
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,29 @@ | ||
name: Verify code | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.go" | ||
|
||
jobs: | ||
golang_lint: | ||
name: Golang Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 | ||
id: tool-versions | ||
|
||
- name: Setup go ${{ steps.tool-versions.outputs.golang_version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ steps.tool-versions.outputs.golang_version }} | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v${{ steps.tool-versions.outputs.golangci-lint_version }} | ||
args: -v --timeout=5m | ||
only-new-issues: 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,36 @@ | ||
name: Timelock Worker Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # Required to upload dist files | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 | ||
id: tool-versions | ||
|
||
- name: Setup go ${{ steps.tool-versions.outputs.golang_version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ steps.tool-versions.outputs.golang_version }} | ||
|
||
- name: Run goreleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: ./dist/* |
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,32 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
paths: | ||
- "cmd/**" | ||
- "pkg/**" | ||
- ".github/workflows/test.yml" | ||
|
||
jobs: | ||
test_bif: | ||
name: Unit test | ||
runs-on: ubuntu-latest | ||
env: | ||
TEST_NODE_URL: '${{ secrets.TEST_NODE_URL }}' | ||
TEST_TIMELOCK_ADDRESS: '${{ secrets.TEST_TIMELOCK_ADDRESS }}' | ||
TEST_PROXY_ADDRESS: '${{ secrets.TEST_PROXY_ADDRESS }}' | ||
TEST_PRIVATE_KEY: '${{ secrets.TEST_PRIVATE_KEY }}' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 | ||
id: tool-versions | ||
|
||
- name: Setup go ${{ steps.tool-versions.outputs.golang_version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ steps.tool-versions.outputs.golang_version }} | ||
|
||
- name: Test | ||
run: make 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,23 @@ | ||
.DS_Store | ||
bin/ | ||
.idea/ | ||
dist/ | ||
MacOSX* | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
!*.c | ||
report.html | ||
timelock-worker.log | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# env file | ||
.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,52 @@ | ||
run: | ||
timeout: 10m | ||
tests: false | ||
modules-download-mode: readonly | ||
output: | ||
format: github-actions | ||
linters: | ||
disable-all: true | ||
enable: | ||
- asasalint | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
- contextcheck | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- gochecknoinits | ||
- godot | ||
- gofmt | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nilerr | ||
- nilnil | ||
- noctx | ||
- nolintlint | ||
- predeclared | ||
- promlinter | ||
- staticcheck | ||
- tenv | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- whitespace | ||
issues: | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
severity: | ||
default-severity: error |
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 @@ | ||
project_name: timelock-worker | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- binary: timelock-worker | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
main: ./main.go | ||
flags: | ||
- -trimpath | ||
- -buildmode=pie | ||
ldflags: | ||
- -s -w | ||
- -X github.com/smartcontractkit/timelock-worker/cmd.Version={{ .Version }} | ||
- -X github.com/smartcontractkit/timelock-worker/cmd.Commit={{ .FullCommit }} | ||
archives: | ||
- id: timelock-worker | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- if eq .Os "darwin" }}macos | ||
{{- else }}{{ .Os }}{{ end }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
source: | ||
enabled: true | ||
checksum: | ||
name_template: "checksums.txt" | ||
snapshot: | ||
name_template: "{{ .Tag }}-dev" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^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,2 @@ | ||
golang 1.20 | ||
golangci-lint 1.52.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,44 @@ | ||
# environment variables | ||
BINARY := timelock-worker | ||
PACKAGE := github.com/smartcontractkit/timelock-worker | ||
VERSION := $(shell git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//') | ||
COMMIT_HASH := $(shell git rev-parse HEAD) | ||
LDFLAGS := "-X $(PACKAGE)/cmd.Version=$(VERSION) -X $(PACKAGE)/cmd.Commit=$(COMMIT_HASH) -w -s" | ||
|
||
# Folders | ||
BIN_FOLDER := bin | ||
SCRIPTS_F := scripts | ||
|
||
# assets | ||
C_GREEN=\033[0;32m | ||
C_RED=\033[0;31m | ||
C_BLUE=\033[0;34m | ||
C_END=\033[0m | ||
|
||
########## | ||
# builds # | ||
########## | ||
|
||
.PHONY: all | ||
all: clean test build | ||
|
||
.PHONY: clean | ||
clean: | ||
@echo "\n\t$(C_GREEN)# Cleaning environment$(C_END)" | ||
go clean -x | ||
rm -rf $(BIN_FOLDER) | ||
rm -f $(SCRIPTS_F)/report.html | ||
|
||
.PHONY: test | ||
test: | ||
@echo "\n\t$(C_GREEN)# Run test and generate new coverage.out$(C_END)" | ||
go test -short -coverprofile=coverage.out -covermode=atomic -race ./... | ||
|
||
.PHONY: build | ||
build: clean | ||
@echo "\n\t$(C_GREEN)# Build binary $(BINARY)$(C_END)" | ||
go build -trimpath -ldflags $(LDFLAGS) -o $(BIN_FOLDER)/$(BINARY) main.go | ||
|
||
.PHONY: lint | ||
lint: | ||
$(SCRIPTS_F)/golangci_html_report.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,18 @@ | ||
<div align="center"> | ||
<h1>Timelock Worker</h1> | ||
<a><img src="https://github.com/smartcontractkit/timelock-worker/actions/workflows/build.yml/badge.svg" /></a> | ||
<a><img src="https://github.com/smartcontractkit/timelock-worker/actions/workflows/test.yml/badge.svg" /></a> | ||
<a><img src="https://github.com/smartcontractkit/timelock-worker/actions/workflows/lint.yml/badge.svg" /></a> | ||
<br /> | ||
<br /> | ||
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/README.md">Documentation</a> | ||
<span> • </span> | ||
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/BUILD.md">Build</a> | ||
<span> • </span> | ||
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/CONFIG.md">Configuration</a> | ||
<span> • </span> | ||
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/USAGE.md">Usage</a> | ||
<span> • </span> | ||
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/DEVELOPMENT.md">Development</a> | ||
<br /> | ||
</div> |
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,24 @@ | ||
# Builder image | ||
FROM quay.io/centos/centos:stream8 as builder | ||
|
||
USER root | ||
|
||
# Dependencies | ||
RUN dnf install -y golang git | ||
RUN mkdir /build | ||
WORKDIR /build | ||
|
||
# Golang build | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -a -installsuffix cgo -ldflags '-w -s -extldflags "-static"' -o timelock-worker . | ||
|
||
# Final image | ||
FROM quay.io/centos/centos:stream8 | ||
COPY --from=builder /build/timelock-worker /app/ | ||
WORKDIR /app | ||
|
||
ENTRYPOINT ["./timelock-worker"] | ||
CMD ["start", "--log-level", "${LOGLEVEL:-debug}"] |
Oops, something went wrong.