Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate common workflows #97

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/go-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# http://www.apache.org/licenses/LICENSE-2.0

# Reusable workflow to run unit tests and gosec on Golang based projects
# Reusable workflow to run multiple workflow checks on Golang based projects
name: Common Workflows

on:
Expand Down Expand Up @@ -38,3 +38,13 @@ jobs:

- name: gosec
uses: dell/common-github-actions/gosec-runner@main

formatter_vetter:
name: Go Formatter and Vetter
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: gofmt and go vet
uses: dell/common-github-actions/go-code-formatter-vetter@main
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:

### go-common

This workflow runs unit tests, checks package coverage and runs gosec against repositories that utilize Golang as the primary development language.
This workflow runs multiple checks against repositories that utilize Golang as the primary development language. Currently, this workflow will run unit tests, check package coverage, gosec, and go formatter and vetter.

```
name: Common Workflows
Expand All @@ -136,9 +136,8 @@ on: # yamllint disable-line rule:truthy

jobs:

# unit tester and gosec runner
common:
name: Run gosec, unit tests, and check package coverage
name: Quality Checks
uses: dell/common-github-actions/.github/workflows/go-common.yml@main
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.23

LABEL "com.github.actions.name"="go-code-formatter-linter-vetter"
LABEL "com.github.actions.description"="Checks for formatting, linting, and vetting issues"
LABEL "com.github.actions.name"="go-code-formatter-vetter"
LABEL "com.github.actions.description"="Checks for formatting and vetting issues"
LABEL "com.github.actions.icon"="eye"
LABEL "com.github.actions.color"="gray-dark"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Formatter-Linter-Vetter GitHub Action
# Code Formatter-Vetter GitHub Action

This GitHub Action can be used to check sources files for formatting, linting, and vetting issues.
This GitHub Action can be used to check sources files for formatting and vetting issues.

To enable this Action, you can create a .yml file under your repo's .github/workflows directory.
Simple example:
Expand All @@ -17,13 +17,13 @@ on:
jobs:

code-check:
name: Check formatting, linting, vetting
name: Check formatting and vetting
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Run the formatter, linter, and vetter
uses: dell/common-github-actions/go-code-formatter-linter-vetter@main
- name: Run the formatter and vetter
uses: dell/common-github-actions/go-code-formatter-vetter@main
with:
directories: ./...
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
name: 'Check Formatting, Linting, Vetting'
description: 'Runs gofmt, golint, and go vet'
name: 'Check Formatting, Vetting'
description: 'Runs gofmt and go vet'

inputs:
directories:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,9 @@ if [ $VET_IN_DIR -eq 1 ]; then
cd - || exit 1
fi

echo === Linting...
(command -v golint >/dev/null 2>&1 \
|| go install golang.org/x/lint/golint@latest) \
&& golint --set_exit_status ${CHECK_DIRS}
LINT_RETURN_CODE=$?
echo === Finished

# Report output.
fail_checks=0
[ "${FMT_RETURN_CODE}" != "0" ] && echo "Formatting checks failed! => Run 'make format'." && fail_checks=1
[ "${VET_RETURN_CODE}" != "0" ] && echo "Vetting checks failed!" && fail_checks=1
[ "${LINT_RETURN_CODE}" != "0" ] && echo "Linting checks failed!" && fail_checks=1

exit ${fail_checks}