Skip to content

Commit

Permalink
feat: linting (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 authored Aug 14, 2024
1 parent 324c716 commit 7533e1c
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 144 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Description

Any further details ...

## Related Issue(s)

- <https://jira.arubanetworks.com/browse/UXI-XXX>
48 changes: 48 additions & 0 deletions .github/workflows/lint-test-code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint & Test Code

on:
push:
branches:
- "**"
- "!main"
- "!master"

env:
go_version: 1.22

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "${{ env.go_version }}"

- name: Setup Just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: just setup-dev

- name: Run Code Linting Test
run: just lint >> "$GITHUB_STEP_SUMMARY"

- name: Run Tests
run: |
just test
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions pkg/config-api-client/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

.coverage
33 changes: 32 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@ generate-config-api-client: retrieve-config-api-openapi-spec
--git-user-id aruba-uxi \
--git-repo-id configuration-api-terraform-provider/{{ CONFIG_API_DIR }} \
cd {{ CONFIG_API_DIR }} && go mod tidy
just fmt-client

setup-dev:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1

test-client:
cd {{ CONFIG_API_DIR }} && go test -v ./...
cd {{ CONFIG_API_DIR }} && go test -v ./... -race -covermode=atomic -coverprofile=.coverage

fmt-client:
gofmt -w pkg/config-api-client

lint-client:
#!/usr/bin/env bash
cd pkg/config-api-client

if [ -n "$(gofmt -d .)" ]; then
echo "Error: (gofmt) formatting required" >&2
exit 1
fi

golangci-lint run

test:
just test-client

lint:
just lint-client

fmt:
just fmt-client

clean:
find . -name ".coverage" -type f -delete
3 changes: 2 additions & 1 deletion pkg/config-api-client/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

git_push.sh
.gitignore
.travis.yml
git_push.sh
62 changes: 32 additions & 30 deletions pkg/config-api-client/api_health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7533e1c

Please sign in to comment.