Skip to content

Commit

Permalink
Merge pull request #1 from okp4/feat/initial-implementation
Browse files Browse the repository at this point in the history
Implement Minimum Viable Blockchain
  • Loading branch information
ccamel authored Feb 8, 2022
2 parents ee02994 + 30468fe commit a61ea31
Show file tree
Hide file tree
Showing 29 changed files with 23,683 additions and 9 deletions.
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

0 comments on commit a61ea31

Please sign in to comment.