Skip to content

Commit

Permalink
Merge pull request #2 from dewep-online/refactoring
Browse files Browse the repository at this point in the history
full refactoring
  • Loading branch information
markus621 committed Nov 4, 2021
2 parents 091dccc + 4b03a88 commit 713578f
Show file tree
Hide file tree
Showing 61 changed files with 1,147 additions and 443 deletions.
26 changes: 26 additions & 0 deletions .deb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package: uri-one
source: uri-one
version: 0.0.1
architecture:
- amd64
maintainer: DewepPro <support@dewep.pro>
homepage: https://www.dewep.pro/products/urione
description:
- Link shortening service
section: web
priority: optional
control:
depends:
- systemd
- ca-certificates
build: scripts/build.sh %s
conffiles:
- /etc/uri-one/config.yaml
preinst: scripts/preinst.sh
postinst: scripts/postinst.sh
prerm: scripts/prerm.sh
postrm: scripts/postrm.sh
data:
build/bin/uri-one_amd64: usr/bin/uri-one
configs/config.yaml: etc/uri-one/config.yaml
init/systemd/uri-one.service: etc/systemd/system/uri-one.service
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: CI
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: make ci
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '38 20 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# language: [ 'go', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
54 changes: 54 additions & 0 deletions .github/workflows/deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "DEB Build Ubuntu"

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: "Set up NodeJS"
uses: actions/setup-node@v2
with:
node-version: 14.15.4

- name: "Frontend build"
run: make build_font

- name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: "Go tools install"
run: |
go install github.com/deweppro/go-static/cmd/static@latest
go install github.com/mailru/easyjson/easyjson@latest
go install github.com/dewep-online/deb-builder/cmd/deb-builder@latest
- name: "Backend build"
run: make build_back

- name: "Deb build"
run: deb-builder build --base-dir=${{ github.workspace }}/deb --tmp-dir=/tmp/deb

- name: Upload deb files to a GitHub release
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/deb/f/fdns/*.deb
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Upload binary files to a GitHub release
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/build/bin/fdns_*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
*.lock
*.log

# Test binary, built with `go test -c`
.DS_Store
.glide
.idea
.vscode
.tools
vendorgo test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
Expand Down
51 changes: 51 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
run:
concurrency: 1
deadline: 2m
issues-exit-code: 1
tests: true
skip-files:
- easyjson

issues:
exclude-use-default: false

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0.8
gofmt:
simplify: true
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 30
misspell:
locale: US
gosimple:
go: "1.16"
checks: ["all"]
prealloc:
simple: true
range-loops: true
for-loops: false

linters:
disable-all: true
enable:
- govet
- gofmt
- errcheck
- misspell
- gocyclo
- ineffassign
- goimports
- gosimple
- prealloc
fast: false
37 changes: 35 additions & 2 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
build-alpine:
docker run --net="host" --rm -v $(PWD):/app -w /app markus621/golang:1.1.0 go build -v
SHELL=/bin/bash

.PHONY: run_back run_front
run_back:
go run -race cmd/uri-one/main.go run -config=./configs/config.dev.yaml
run_front:
cd web && npm ci --no-delete --cache=/tmp && npm run start

.PHONY: build_back build_font
build_back:
bash scripts/build.sh back
build_font:
bash scripts/build.sh front

.PHONY: linter
linter:
bash scripts/linter.sh

.PHONY: tests
tests:
bash scripts/tests.sh

.PHONY: develop_up develop_down
develop_up:
bash scripts/docker.sh docker_up
develop_down:
bash scripts/docker.sh docker_down

.PHONY: ci
ci:
bash scripts/ci.sh

.PHONY: ci
deb: build_font build_back
deb-builder build
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# uri-one

[![Coverage Status](https://coveralls.io/repos/github/dewep-online/uri-one/badge.svg?branch=master)](https://coveralls.io/github/dewep-online/uri-one?branch=master)
[![Release](https://img.shields.io/github/release/dewep-online/uri-one.svg?style=flat-square)](https://github.com/dewep-online/uri-one/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/dewep-online/uri-one)](https://goreportcard.com/report/github.com/dewep-online/uri-one)
[![CI](https://github.com/dewep-online/uri-one/actions/workflows/ci.yml/badge.svg)](https://github.com/dewep-online/uri-one/actions/workflows/ci.yml)
21 changes: 0 additions & 21 deletions app/config/config.go

This file was deleted.

Loading

0 comments on commit 713578f

Please sign in to comment.