Skip to content

Commit

Permalink
refactor: Improve project workflows and implement linting, testing, a…
Browse files Browse the repository at this point in the history
…nd building actions via GitHub Actions.

- Add Github Actions for linting, testing, and building
- Upgrade Go version from 1.20 to 1.22
- Improve error handling and logging in various providers
- Whitelist relevant files in .gitignore
- Delete unnecessary ci.yml file
  • Loading branch information
moonD4rk committed Feb 29, 2024
1 parent 6918d1b commit ff2b375
Show file tree
Hide file tree
Showing 13 changed files with 556 additions and 53 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: ["1.22.x"]

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false
id: go

- name: cache go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Format Check
if: matrix.os != 'windows-latest'
run: |
diff -u <(echo -n) <(gofmt -d .)
- name: Get dependencies
run: go mod download

- name: Build
run: go build -v ./...
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set Golang
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache: false

- name: Check spelling with custom config file
uses: crate-ci/typos@master
with:
config: ./.typos.toml

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Tests
on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
test:
strategy:
matrix:
go-version: ["1.22.x"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
if: success()
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Run tests
run: go test -v ./... -covermode=count

coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Checkout code
uses: actions/checkout@v4
- name: Calc coverage
run: |
go test -v ./... -covermode=count -coverprofile=coverage.out
- name: Convert coverage.out to coverage.lcov
uses: jandelgado/gcov2lcov-action@v1

- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/
!.github/workflows/*.yml
!.typos.toml
!.golangci.yml
Loading

0 comments on commit ff2b375

Please sign in to comment.