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

Feat(update): Added Job summary for lint.yml workflow #2755

Closed
wants to merge 7 commits into from
Closed
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
80 changes: 62 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,97 @@
name: "Lint"

on:
workflow_call:

permissions:
contents: read
pull-requests: read

jobs:
ts-lint:
# TODO(JayF): Determine what nodejs versions we target, and setup matrix-based testing similar to what we do for go
name: Lint TypeScript
runs-on: ubuntu-22.04

steps:
- name: Checkout
- name: Adding markdown for Typescript
run: echo '### Lint TypeScript ✨' >> $GITHUB_STEP_SUMMARY
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Setup Node
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: yarn
cache-dependency-path: ./internal/lookout/ui/yarn.lock

- name: Check TypeScript formatting
- name: Check TypeScript formatting
id: ts-lint
run: |
yarn install --frozen-lockfile && yarn run fmt || exit 1
yarn install --frozen-lockfile && yarn run fmt > lint_results.txt || exit 0
echo "::set-output name=lint_results::$(cat lint_results.txt)"
exit $(git status -s -uno | wc -l)
working-directory: ./internal/lookout/ui

- name: Generate list using Markdown
id: ts-lint-summary
run: |
if [ ${{ steps.ts-lint.outcome }} == 'success' ]; then
echo "- ✔️ Checked out the repository" >> $GITHUB_STEP_SUMMARY
echo "- ✔️ Set up Node.js with version 16.14.2 and cached Yarn dependencies" >> $GITHUB_STEP_SUMMARY
echo "- ✔️ Checked TypeScript formatting" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ Checked out the repository" >> $GITHUB_STEP_SUMMARY
echo "- ❌ Set up Node.js with version 16.14.2 and cached Yarn dependencies" >> $GITHUB_STEP_SUMMARY
echo "- ❌ TypeScript formatting check failed" >> $GITHUB_STEP_SUMMARY
echo "::error::Linting issues found. Check the details below." >> $GITHUB_STEP_SUMMARY
cat lint_results.txt >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true
go-lint:
name: Lint Go
runs-on: ubuntu-22.04

steps:
- name: Checkout
- name: Adding markdown
run: echo '### Lint Go ✨' >> $GITHUB_STEP_SUMMARY
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Setup Golang with Cache
- name: Setup Golang with Cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "1.20"

- name: Lint using golangci-lint
- name: Lint using golangci-lint
id: go-lint
uses: golangci/golangci-lint-action@v3
with:
skip-pkg-cache: true
skip-build-cache: true
version: v1.52.2
only-new-issues: true
args: --timeout=10m --issues-exit-code=1 --sort-results ./...

- name: Save Go linting results
if: ${{ always() }}
run: |
echo "GolangCI-Lint Results:" > lint_results.txt
echo "\`\`\`" >> lint_results.txt
echo "${{ steps.go-lint.outputs.stdout }}" >> lint_results.txt
echo "\`\`\`" >> lint_results.txt
cat lint_results.txt
continue-on-error: true

- name: Generate list using Markdown
id: go-lint-summary
run: |
if [ ${{ steps.go-lint.outcome }} == 'success' ]; then
echo "- ✔️ Checked out the repository" >> $GITHUB_STEP_SUMMARY
echo "- ✔️ Set up Go with version 1.20 and cached dependencies" >> $GITHUB_STEP_SUMMARY
echo "- ✔️ Linted Go code using golangci-lint" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ Checked out the repository" >> $GITHUB_STEP_SUMMARY
echo "- ❌ Set up Go with version 1.20 and cached dependencies" >> $GITHUB_STEP_SUMMARY
echo "- ❌ Go lint check failed" >> $GITHUB_STEP_SUMMARY
echo "::error::Linting issues found. Check the details below." >> $GITHUB_STEP_SUMMARY
while read -r line; do
file=$(echo "$line" | cut -d':' -f1)
linenum=$(echo "$line" | cut -d':' -f2)
message=$(echo "$line" | cut -d':' -f4-)
echo "::error file=$file,line=$linenum::${message}" >> $GITHUB_STEP_SUMMARY
done < lint_results.txt
fi
continue-on-error: true
if: always()

4 changes: 4 additions & 0 deletions internal/lookout/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"github.com/armadaproject/armada/pkg/api/lookout"
)

func exampleFunction() {

Check failure on line 22 in internal/lookout/application.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

func `exampleFunction` is unused (unused)
// Lint issue: Empty block, this should have some code.

Check failure on line 23 in internal/lookout/application.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
}

type LogRusLogger struct{}

func (l LogRusLogger) Printf(format string, v ...interface{}) {
Expand Down
Loading