Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
violog committed Jul 16, 2024
1 parent b2b836b commit ab7671e
Show file tree
Hide file tree
Showing 18 changed files with 3,522 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
workflow_dispatch:

env:
CI_JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
converge:
name: Converge
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/[email protected]

- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_SHA
- name: Run Build
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
22 changes: 22 additions & 0 deletions .github/workflows/code-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
pull_request:

permissions:
checks: write
contents: read
pull-requests: write

jobs:
lint:
name: code-review
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
reporter: github-pr-review
cache: false
38 changes: 38 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
workflow_dispatch:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'

env:
CI_JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
converge:
name: Converge
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/[email protected]

- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_REF_NAME
- name: Run Build
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode/
.idea/
config.*.yaml
docs/node_modules
docs/web_deploy
vendor/
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
linters:
enable:
- asciicheck
- bodyclose
- dogsled
- dupl
- errcheck
- exportloopref
- goconst
- gofmt
- goimports
- revive
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused

issues:
max-same-issues: 50

linters-settings:
dogsled:
max-blank-identifiers: 3
golint:
min-confidence: 0
maligned:
suggest-new: true
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.20-alpine as buildbase

RUN apk add git build-base

WORKDIR /go/src/github.com/rarimo/galxe-svc
COPY vendor .
COPY . .

RUN GOOS=linux go build -o /usr/local/bin/galxe-svc /go/src/github.com/rarimo/galxe-svc


FROM alpine:3.9

COPY --from=buildbase /usr/local/bin/galxe-svc /usr/local/bin/galxe-svc
RUN apk add --no-cache ca-certificates

ENTRYPOINT ["galxe-svc"]
6 changes: 6 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
log:
level: debug
disable_sentry: true

listener:
addr: :8000
66 changes: 66 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

GENERATOR_IMAGE=registry.gitlab.com/tokend/openapi-go-generator:c59241b52b0e37bbbeb02a214ab5bfd07627aabc

[[ ! -x "$(command -v go 2>/dev/null)" ]] && echo "go is not installed" && exit 1

GENERATED="$PWD/resources"
OPENAPI_DIR="$PWD/docs/web_deploy"
PACKAGE_NAME=resources

function printHelp {
echo "usage: ./generate.sh [<flags>]
script to generate resources for api
Flags:
--package PACKAGE package name of generated stuff (first line of file, by default is 'resources')
--image IMAGE name of generator docker image (by default is openapi-generator)
-h, --help show this help
-p, --path-to-generate PATH path to put generated things (by default is resources)
-i, --input OPENAPI_DIR path to dir where openapi.yaml is stored (by default docs/web_deploy)"
}

function parseArgs {
while [[ -n "$1" ]]
do
case "$1" in
-h | --help)
printHelp && exit 0
;;
-p | --path-to-generate) shift
[[ ! -d $1 ]] && echo "path $1 does not exist or not a dir" && exit 1
GENERATED=$1
;;
--package) shift
[[ -z "$1" ]] && echo "package name not specified" && exit 1
PACKAGE_NAME=$1
;;
-i | --input) shift
[[ ! -f "$1/openapi.yaml" ]] && echo "file openapi.yaml does not exist in $1 or not a file" && exit 1
OPENAPI_DIR=$1
;;
--image) shift
[[ "$(docker images -q $1)" == "" ]] && echo "image $1 does not exist locally" && exit 1
GENERATOR_IMAGE=$1
;;
esac
shift
done
}

function generate {
(cd docs && npm run build)
if [[ ! -d "${GENERATED}" ]]; then
mkdir -p "${GENERATED}"
else
rm -rf "${GENERATED}"/*
fi
docker run --rm -v "${OPENAPI_DIR}":/openapi -v "${GENERATED}":/generated "${GENERATOR_IMAGE}" \
generate -pkg "${PACKAGE_NAME}" --raw-formats-as-types --meta-for-lists
goimports -w ${GENERATED}
}

parseArgs "$@"
#echo ${OPENAPI_DIR} ${GENERATED} ${GENERATOR_IMAGE} ${PACKAGE_NAME}
generate
59 changes: 59 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module github.com/rarimo/galxe-svc

go 1.22.2

require (
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/go-chi/chi v4.1.2+incompatible
gitlab.com/distributed_lab/ape v1.7.1
gitlab.com/distributed_lab/kit v1.11.3
gitlab.com/distributed_lab/logan v3.8.1+incompatible
)

require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/go-ethereum v1.10.25 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/raven-go v0.2.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.2.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/google/jsonapi v0.0.0-20200226002910-c8283f632fb7 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
gitlab.com/distributed_lab/figure/v3 v3.1.4 // indirect
gitlab.com/distributed_lab/lorem v0.2.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit ab7671e

Please sign in to comment.