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

feat: ci/cd setup #2

Merged
merged 5 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 26 additions & 19 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,28 @@ jobs:
with:
version: "2022.1.3"

codeql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# codeql:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# language: [ 'go' ]
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version-file: "go.mod"
# cache: true
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v3
# with:
# languages: ${{ matrix.language }}
# - name: Autobuild
# uses: github/codeql-action/autobuild@v3
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v3

sonarcloud:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -100,5 +105,7 @@ jobs:
with:
go-version-file: "go.mod"
cache: true
- name: Build
run: make -s build
- name: Build daemon
run: make -s build-daemon
- name: Build CLI
run: make -s build-cli
42 changes: 22 additions & 20 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ jobs:
with:
version: "2022.1.3"

codeql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# codeql:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# language: [ 'go' ]
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v3
# with:
# languages: ${{ matrix.language }}
# - name: Autobuild
# uses: github/codeql-action/autobuild@v3
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v3

sonarcloud:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -97,15 +97,17 @@ jobs:
with:
go-version-file: "go.mod"
cache: true
- name: Build
run: make -s build
- name: Build daemon
run: make -s build-daemon
- name: Build CLi
run: make -s build-cli

tag:
runs-on: ubuntu-latest
needs:
- lint
- test
- codeql
# - codeql
- staticcheck
- sonarcloud
- build
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ test-coverage: test
go tool cover -html=coverage.txt -o cover.html
open cover.html

.PHONY: build
.PHONY: build-daemon
build: vendor
$(info building binary...)
go build -o bin/main main.go || (echo an error while building binary, exiting!; sh -c 'exit 1';)
$(info building daemon binary...)
go build -o bin/split-the-tunnel cmd/daemon/daemon.go || (echo an error while building daemon binary, exiting!; sh -c 'exit 1';)

.PHONY: build-cli
build: vendor
$(info building cli binary...)
go build -o bin/stt-cli cmd/cli/cli.go || (echo an error while building cli binary, exiting!; sh -c 'exit 1';)

.PHONY: run
run: vendor
Expand Down
14 changes: 12 additions & 2 deletions build/package/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ before:
- go mod download

builds:
- id: binary
- id: daemon
goos:
- linux
- darwin
goarch:
- amd64
binary: "{{ .ProjectName }}"
Expand All @@ -26,6 +25,17 @@ builds:
- -s -w -X {{ .Env.MODULE }}/{{ .Env.VERSION_DIR }}.gitCommit={{ .ShortCommit }}
- -s -w -X {{ .Env.MODULE }}/{{ .Env.VERSION_DIR }}.buildDate={{ .CommitDate }}
main: ./main.go
- id: cli
goos:
- linux
goarch:
- amd64
binary: stt-cli
ldflags:
- -s -w -X {{ .Env.MODULE }}/{{ .Env.VERSION_DIR }}.gitVersion={{ .Version }}
- -s -w -X {{ .Env.MODULE }}/{{ .Env.VERSION_DIR }}.gitCommit={{ .ShortCommit }}
- -s -w -X {{ .Env.MODULE }}/{{ .Env.VERSION_DIR }}.buildDate={{ .CommitDate }}
main: ./main.go

archives:
- files:
Expand Down
5 changes: 1 addition & 4 deletions internal/ipc/ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ func handleListCommand(conn net.Conn) error {

func Cleanup(path string) error {
// Perform any cleanup and shutdown tasks here
if err := os.Remove(path); err != nil {
return err
}

return nil
return os.Remove(path)
}