Added go lint check/fixed issues/updated gh workflow #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Unit Tests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23.4' | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Run tests with coverage | |
run: | | |
go mod tidy | |
go test -coverprofile=coverage.out ./... | |
- name: Show coverage | |
run: | | |
go tool cover -func=coverage.out | |
- name: Build Docker image | |
run: | | |
docker build -t go-scraper-api . | |
- name: Run golangci-lint | |
run: | | |
./golangci-lint run | |
- name: Report golangci-lint output | |
run: | | |
if [ $? -ne 0 ]; then | |
echo "golangci-lint found issues:" | |
./golangci-lint run | |
else | |
echo "golangci-lint found no issues. All good!" | |
fi |