Skip to content

Commit

Permalink
Create go.yml
Browse files Browse the repository at this point in the history
This GitHub Actions workflow is designed to automate building and testing a Golang project. The main job is named "build," which performs the following steps:

Checks whether Protocol Buffers compiler (protoc) is already installed. If not, downloads and installs it from the official repository.
#    Sets up Go by using the actions/setup-go action, specifying version 1.21 as the required version.
#    Runs go mod tidy to ensure all necessary packages are included in the module's dependency graph.
#    Runs go mod vendor to create a copy of the current state of the module's dependencies in the vendor directory.
#    Executes go build -v ./..., which builds the entire package and its dependencies.
#    Finally, executes go test -v ./..., which runs tests for the entire package and its dependencies.

The workflow triggers on both pushes and pull requests to the main branch. Additionally, it specifies Ubuntu as the operating system for running the jobs.
  • Loading branch information
SohelAhmedJoni authored Oct 16, 2023
1 parent 34c0993 commit 9c09fd3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Install protoc
run: |
if ! command -v protoc &> /dev/null; then
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.0-rc1/protoc-25.0-rc-1-linux-x86_64.zip
unzip protoc-25.0-rc-1-linux-x86_64.zip
sudo mv bin/protoc /usr/local/bin
sudo mv include/google /usr/local/include
fi
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install dependencies
run: |
go mod tidy
go mod vendor
- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

0 comments on commit 9c09fd3

Please sign in to comment.