Skip to content

Commit

Permalink
feat: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 committed Aug 14, 2024
1 parent 324c716 commit ca24321
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 144 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/lint-test-code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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: 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
26 changes: 25 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ 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

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
if [ -n "$(gofmt -d pkg/config-api-client)" ]; then
echo "Error: (gofmt) formatting required" >&2
exit 1
fi

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 ca24321

Please sign in to comment.