Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalcaliskan committed Jan 7, 2024
1 parent e96ae7c commit 4493b18
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 141 deletions.
64 changes: 29 additions & 35 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
run: make -s clean

test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -66,38 +63,35 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

# sonarcloud:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version-file: "go.mod"
# cache: true
# - name: Test
# run: make -s test
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# with:
# args: >
# -Dproject.settings=build/ci/sonar-project.properties
# - name: SonarQube Quality Gate check
# uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Test
run: make -s test
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dproject.settings=build/ci/sonar-project.properties
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -106,5 +100,5 @@ jobs:
with:
go-version-file: "go.mod"
cache: true
- name: Test
- name: Build
run: make -s build
75 changes: 30 additions & 45 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ jobs:
run: make -s clean

test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -63,38 +60,35 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

# sonarcloud:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version-file: "go.mod"
# cache: true
# - name: Test
# run: make -s test
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# with:
# args: >
# -Dproject.settings=build/ci/sonar-project.properties
# - name: SonarQube Quality Gate check
# uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Test
run: make -s test
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dproject.settings=build/ci/sonar-project.properties
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -103,7 +97,7 @@ jobs:
with:
go-version-file: "go.mod"
cache: true
- name: Test
- name: Build
run: make -s build

tag:
Expand All @@ -113,7 +107,7 @@ jobs:
- test
- codeql
- staticcheck
# - sonarcloud
- sonarcloud
- build
steps:
- name: Checkout
Expand Down Expand Up @@ -142,14 +136,6 @@ jobs:
echo "::set-output name=latest_tag::$(git describe --tags $(git rev-list --tags --max-count=1))"
echo "::set-output name=build_time::$(date -u +'%m-%d-%YT%H:%M:%SZ')"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Docker Login
# uses: docker/login-action@v2
# with:
# registry: docker.io
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install Go
uses: actions/setup-go@v5
with:
Expand All @@ -162,4 +148,3 @@ jobs:
args: release --clean --config build/package/.goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
12 changes: 4 additions & 8 deletions build/ci/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
sonar.projectKey=bilalcaliskan_golang-cli-template
sonar.projectKey=bilalcaliskan_split-the-tunnel
sonar.organization=bilalcaliskan-github

# This is the name and version displayed in the SonarCloud UI.
# sonar.projectName=golang-cli-template
# sonar.projectVersion=1.0

sonar.sources=.
sonar.exclusions=**/*_test.go,**/vendor/**,**/testdata/*,build/package/Dockerfile
sonar.exclusions=**/*_test.go,**/vendor/**,**/testdata/*
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.test.exclusions=**/vendor/**
sonar.test.exclusions=**/vendor/**,**/mock*
sonar.go.coverage.reportPaths=/github/workspace/coverage.txt
sonar.coverage.exclusions=main.go
sonar.coverage.exclusions=main.go,**/mock*
38 changes: 3 additions & 35 deletions build/package/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
project_name: golang-cli-template
project_name: split-the-tunnel

env:
- CGO_ENABLED=0
Expand All @@ -19,7 +19,7 @@ builds:
- amd64
binary: golang-cli-template
ldflags:
- -s -w -X github.com/bilalcaliskan/golang-cli-template/internal/version.gitVersion={{ .Version }} -X github.com/bilalcaliskan/golang-cli-template/internal/version.gitCommit={{ .ShortCommit }} -X github.com/bilalcaliskan/golang-cli-template/internal/version.buildDate={{ .CommitDate }}
- -s -w -X github.com/bilalcaliskan/split-the-tunnel/internal/version.gitVersion={{ .Version }} -X github.com/bilalcaliskan/split-the-tunnel/internal/version.gitCommit={{ .ShortCommit }} -X github.com/bilalcaliskan/split-the-tunnel/internal/version.buildDate={{ .CommitDate }}
main: ./main.go

archives:
Expand All @@ -29,30 +29,10 @@ archives:
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
#dockers:
# - image_templates:
# - "docker.io/bilalcaliskan/{{ .ProjectName }}:{{ .Version }}"
# - "docker.io/bilalcaliskan/{{ .ProjectName }}:latest"
# dockerfile: build/package/Dockerfile.goreleaser
# goos: linux
# goarch: amd64
# use: docker
# build_flag_templates:
# - --pull
# - --platform=linux/amd64
# - --label=org.opencontainers.image.title={{ .ProjectName }}
# - --label=org.opencontainers.image.description={{ .ProjectName }}
# - --label=org.opencontainers.image.url=https://github.com/bilalcaliskan/golang-cli-template
# - --label=org.opencontainers.image.source=https://github.com/bilalcaliskan/golang-cli-template
# - --label=org.opencontainers.image.version={{ .Version }}
# - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
# - --label=org.opencontainers.image.revision={{ .FullCommit }}
# - --label=org.opencontainers.image.licenses=Apache

release:
github:
owner: bilalcaliskan
name: golang-cli-template
name: split-the-tunnel

changelog:
sort: asc
Expand All @@ -66,15 +46,3 @@ changelog:
- 'README'
- '^Merge branch'
- '^Merge pull request'

#brews:
# - name: golang-cli-template
# tap:
# owner: bilalcaliskan
# name: homebrew-tap
# token: "{{ .Env.TAP_GITHUB_TOKEN }}"
# folder: Formula
# goarm: 6
# homepage: https://github.com/bilalcaliskan/golang-cli-template
# license: apache-2.0
# description: golang-cli-template does something
6 changes: 0 additions & 6 deletions build/package/Dockerfile.goreleaser

This file was deleted.

7 changes: 3 additions & 4 deletions cmd/foo/foo.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package foo

import (
"github.com/bilalcaliskan/golang-cli-template/cmd/foo/options"
"github.com/bilalcaliskan/split-the-tunnel/cmd/foo/options"

rootopts "github.com/bilalcaliskan/golang-cli-template/cmd/root/options"
rootopts "github.com/bilalcaliskan/split-the-tunnel/cmd/root/options"

"github.com/bilalcaliskan/golang-cli-template/internal/logging"
"github.com/bilalcaliskan/split-the-tunnel/internal/logging"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -33,7 +33,6 @@ var (
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
logger.Info().Str("rootOptsKey", fooOpts.RootOptions.Key).Msg("hello guys")

return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/foo/options/options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package options

import (
"github.com/bilalcaliskan/golang-cli-template/cmd/root/options"
"github.com/bilalcaliskan/split-the-tunnel/cmd/root/options"
"github.com/spf13/cobra"
)

Expand Down
10 changes: 5 additions & 5 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"os"

"github.com/bilalcaliskan/golang-cli-template/cmd/foo"
"github.com/bilalcaliskan/golang-cli-template/cmd/root/options"
"github.com/bilalcaliskan/split-the-tunnel/cmd/foo"
"github.com/bilalcaliskan/split-the-tunnel/cmd/root/options"

"github.com/bilalcaliskan/golang-cli-template/internal/logging"
"github.com/bilalcaliskan/golang-cli-template/internal/version"
"github.com/bilalcaliskan/split-the-tunnel/internal/logging"
"github.com/bilalcaliskan/split-the-tunnel/internal/version"
"github.com/spf13/cobra"
)

Expand All @@ -27,7 +27,7 @@ func init() {

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "golang-cli-template",
Use: "split-the-tunnel",
Short: "",
Long: ``,
Version: ver.GitVersion,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/bilalcaliskan/golang-cli-template
module github.com/bilalcaliskan/split-the-tunnel

go 1.21

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright © 2022 bilalcaliskan [email protected]
package main

import (
"github.com/bilalcaliskan/golang-cli-template/cmd/root"
"github.com/bilalcaliskan/split-the-tunnel/cmd/root"
)

func main() {
Expand Down

0 comments on commit 4493b18

Please sign in to comment.