Skip to content

Commit

Permalink
chore: build github action
Browse files Browse the repository at this point in the history
  • Loading branch information
erayarslan committed Nov 21, 2024
1 parent bb33776 commit 2334b9d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, reopened, synchronize]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Prepare
run: |
make init
make lint
make proto
- name: Install dependencies and Build
run: go mod tidy && make build
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test

on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, reopened, synchronize]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Install Multipass
run: |
sudo sh -c "snap list multipass && sudo snap refresh multipass --channel latest/stable || sudo snap install multipass --channel latest/stable"
- name: Launch Multipass
run: |
sudo multipass launch --name foo
- uses: actions/checkout@v3
- name: Delete Multipass
if: always()
run: |
sudo multipass delete foo
sudo multipass purge
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,31 @@ PROTOBUF_INSTALL_CMD = brew install protobuf

ifeq ($(OS),Windows_NT)
PROTOBUF_INSTALL_CMD = choco install protoc
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PROTOBUF_INSTALL_CMD = sudo apt install -y protobuf-compiler
endif
endif

windows:
go mod tidy
go build -o main.exe cmd/main.go

init:
$(PROTOBUF_INSTALL_CMD)
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@v0.27.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.35.2
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1

proto:
protoc --go_out=. --go-grpc_out=. agent/agent.proto api/api.proto cluster/cluster.proto multipass/multipass.proto

lint:
golangci-lint run -c .golangci.yml --timeout=5m -v

linter:
pre-commit:
go mod tidy
fieldalignment -fix ./...
golangci-lint run -c .golangci.yml --timeout=5m -v --fix

proto:
protoc --go_out=. --go-grpc_out=. --experimental_allow_proto3_optional agent/agent.proto api/api.proto cluster/cluster.proto multipass/multipass.proto

build:
go build cmd/main.go

Expand Down

0 comments on commit 2334b9d

Please sign in to comment.