Skip to content
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

Implement Minimum Viable Blockchain #1

Merged
merged 41 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
232da23
feat: add scaffolded code
ccamel Jan 31, 2022
641f0f9
refactor: move okp4 content to project root
ccamel Jan 31, 2022
d69e305
refactor: remove unused vuejs app
ccamel Feb 1, 2022
aef474d
chore: exclude some unwanted files from git
ccamel Feb 1, 2022
e8540c6
chore: set some initial configuration values
ccamel Feb 1, 2022
b543b1d
ci(workflow): add lint-go job
ccamel Feb 2, 2022
af2a91b
chore: add golangci (standard) configuration
ccamel Feb 2, 2022
ef02b1a
style: make go linter happy again
ccamel Feb 2, 2022
0550908
chore: make yaml linter happy again
ccamel Feb 2, 2022
f4b413f
docs: initialize read-me content
ccamel Feb 2, 2022
c45f031
ci(workflow): set name for workflow
ccamel Feb 2, 2022
f89b956
chore(project): add makefile for linting code source
ccamel Feb 2, 2022
e22be6a
chore(project): add missing yaml file extension
ccamel Feb 2, 2022
78ca536
chore(project): add version
ccamel Feb 2, 2022
0cd6972
chore(project): exclude 'target' folder from git tracking
ccamel Feb 2, 2022
ddcc4e9
chore(project): add goals 'install', 'build' and 'start'
ccamel Feb 2, 2022
aab8519
chore(project): fix documentation
ccamel Feb 3, 2022
2c8ad28
chore(project): dockerize project
ccamel Feb 3, 2022
c7dca61
chore: fix typos and improve doc a bit
ccamel Feb 3, 2022
69bdbd3
ci(workflow): add dockerfile linting
ccamel Feb 3, 2022
2be93a8
ci(workflow): add build workflow (go, docker)
ccamel Feb 3, 2022
27ed968
ci(bot): add gomod package ecosystem
ccamel Feb 3, 2022
6962fce
ci(bot): add docker package ecosystem
ccamel Feb 3, 2022
6ee87f8
ci(bot): limit open pull requests to 2 for github actions
ccamel Feb 3, 2022
fee7a06
chore(project): add goal 'test'
ccamel Feb 3, 2022
8873b06
ci(workflow): add workflow 'test'
ccamel Feb 3, 2022
76c379e
chore: improve cosmetic
ccamel Feb 3, 2022
f3a3995
docs: update subtitle
ccamel Feb 3, 2022
d884efa
ci(workflow): remove unused workflow
ccamel Feb 3, 2022
a637f9f
ci(worflow): add 'publish' workflow
ccamel Feb 3, 2022
a277ac6
chore: remove useless directives
ccamel Feb 4, 2022
04f0a19
chore(project): fix incorrectly implemented goal install
ccamel Feb 4, 2022
5bae339
chore: adopt alpine docker image
ccamel Feb 4, 2022
1d47265
ci(workflow): fix context setup
ccamel Feb 4, 2022
62eabaa
chore: improve initial configuration for devnet
ccamel Feb 4, 2022
26ba51c
ci(workflow): fix workflow name
ccamel Feb 5, 2022
82f472f
docs: add status badge for build
ccamel Feb 5, 2022
7ee7d0a
docs: add status badge for test
ccamel Feb 5, 2022
48e6d04
chore(project): add semantic release configuration
ccamel Feb 7, 2022
97e66e6
ci(workflow): add release workflow
ccamel Feb 7, 2022
30468fe
fix: Add make init and fix start
ad2ien Feb 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
target/
.github/
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ charset = utf-8
trim_trailing_whitespace = false
indent_size = 2

[*.yml]
[*.{yml,yaml}]
trim_trailing_whitespace = false
indent_size = 2
indent_size = 2
19 changes: 14 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "daily"
reviewers:
- "maintainers"
interval: daily
open-pull-requests-limit: 2
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
open-pull-requests-limit: 5
- package-ecosystem: docker
directory: /
schedule:
interval: daily
open-pull-requests-limit: 2
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build

on:
workflow_call:

push:
branches: [ main ]

pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
build-go:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.17.6"

- name: Build go project
run: |
make build

build-docker:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Build docker image
run: |
docker build .
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Lint

on:
workflow_call:

push:
branches: [ main ]

Expand Down Expand Up @@ -40,3 +42,30 @@ jobs:

- name: Lint yaml files
uses: ibiqlik/[email protected]

lint-go:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Lint go code (golangci-lint)
uses: golangci/golangci-lint-action@v2
with:
version: v1.44

lint-dockerfile:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Lint dockerfile (hadolint)
uses: hadolint/[email protected]

- name: Lint dockerfile (docker-lint)
uses: luke142367/[email protected]
with:
target: Dockerfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish

on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
publish-docker-images:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Login to Docker registry
run: |
echo ${{ secrets.DOCKER_REGISTRY_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_REGISTRY_ID }} --password-stdin

- name: Set up context
id: project_context
uses: FranzDiebold/[email protected]

- name: Set up versions
id: project_version
run: |
version=`head -n 1 version`
echo "::set-output name=version::$version"
echo "::set-output name=major::$(echo $version | cut -d. -f1)"
echo "::set-output name=minor::$(echo $version | cut -d. -f2)"
echo "::set-output name=revision::$(echo $version | cut -d. -f3)"
echo "::set-output name=image::$GITHUB_REPOSITORY"

- name: Build and publish image(s)
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "Publish docker image for branch"
docker build \
-t ghcr.io/${{ steps.project_version.outputs.image }}:${{ steps.project_version.outputs.major }} \
-t ghcr.io/${{ steps.project_version.outputs.image }}:${{ steps.project_version.outputs.major }}.${{ steps.project_version.outputs.minor }} \
-t ghcr.io/${{ steps.project_version.outputs.image }}:${{ steps.project_version.outputs.version }} \
-t ghcr.io/${{ steps.project_version.outputs.image }}:latest \
.
elif [[ $GITHUB_EVENT_NAME == pull_request ]]; then
echo "Publish docker image for branch"
docker build \
-t ghcr.io/${{ steps.project_version.outputs.image }}:$CI_ACTION_REF_NAME_SLUG \
.
else
echo "Publish docker image for nightly"
docker build \
-t ghcr.io/${{ steps.project_version.outputs.image }}:nightly \
.
fi
docker push ghcr.io/${{ steps.project_version.outputs.image }} --all-tags
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
workflow_dispatch:

jobs:
lint:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/lint.yaml

build:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/build.yaml

test:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/test.yaml

perfom-release:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
needs:
- lint
- build
- test
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
token: ${{ secrets.OKP4_TOKEN }}

- name: Release project
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 19.0.2
branch: main
extra_plugins: |
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
@google/semantic-release-replace-plugin
env:
GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on:
workflow_call:

push:
branches: [ main ]

pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
test-go:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.17.6"

- name: Test go project
run: |
make test-go
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
vue/
release/
target/
okp4d
.idea/
.vscode/
.DS_Store
102 changes: 102 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
run:
timeout: 5m
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- dupl
- durationcheck
- errname
- errorlint
- exhaustive
- exportloopref
- funlen
- forbidigo
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- goimports
- gomodguard
- goprintffuncname
- gosec
- lll
- makezero
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- tenv
- testpackage
- tparallel
- unconvert
- unparam
- wastedassign
- whitespace

linters-settings:
cyclop:
max-complexity: 20
skip-tests: true
funlen:
statements: 65
godot:
scope: declarations # comments to be checked: `declarations` (default), `toplevel`, or `all`
exclude:
- "this line is used by starport scaffolding .*"
lll:
line-length: 135
output:
uniq-by-line: false

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- source: "^//\\s*go:generate\\s"
linters:
- lll
- source: "(noinspection|TODO)"
linters:
- godot
- source: "//noinspection"
linters:
- gocritic
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
linters:
- errorlint
- path: "_test\\.go"
linters:
- bodyclose
- deadcode
- dupl
- funlen
- goconst
- noctx
- unused
- varcheck
- wrapcheck
27 changes: 27 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
branches:
- main

plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- - "@semantic-release/changelog"
- changelogFile: CHANGELOG.md
changelogTitle: "# ØKP4 protocol changelog"
- - "@google/semantic-release-replace-plugin"
- replacements:
- files: [version]
from: ^.+$
to: ${nextRelease.version}
countMatches: true
results:
- file: version
hasChanged: true
numMatches: 1
numReplacements: 1

- "@semantic-release/github"
- - "@semantic-release/git"
- assets:
- CHANGELOG.md
- version
message: "chore(release): perform release ${nextRelease.version}"
2 changes: 2 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
extends: default
ignore: |
openapi.yml
rules:
document-start: disable
line-length:
Expand Down
Loading