Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move validation of golangci results to a non-matrix job
Browse files Browse the repository at this point in the history
chudilka1 committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0bcc610 commit ad3f64c
Showing 2 changed files with 66 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ jobs:
bash ./.github/scripts/map-affected-files-to-modules.sh '${{ steps.match-every.outputs.non-ignored_files }}'
golangci:
name: lint
name: GolangCI Lint
needs: [filter, run-frequency]
# We don't directly merge dependabot PRs to not waste the resources.
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' && needs.filter.outputs.should-run-golangci == 'true' }}
@@ -135,6 +135,22 @@ jobs:
with:
channel-id: "#team-core"
slack-message: "golangci-lint failed: \n${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}"

# Fails if any golangci-lint matrix jobs fails and silently succeeds otherwise
# Consolidates golangci-lint matrix job results under one required `lint` check
# Inclusive check: all (new) modules are analyzed, but no need to enable "required" checks for each one
golangci-matrix-results-validation:
name: lint
needs: [golangci]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check Golangci-lint Matrix Results
if: ${{ needs.golangci.result != 'success' }}
shell: bash
run: |
echo "At least one 'GolangCI Lint' matrix job failed. Check the failed lint jobs."
exit 1
core:
env:
49 changes: 49 additions & 0 deletions dashboard-lib/fail_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dashboard_lib

import (
"context"
"errors"
"os"
"sync"
"testing"
)

type MyStruct struct {
Ctx context.Context // triggers context rules
}

func TestFail(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Fatal("fake failure")
}

func TestRace(t *testing.T) {
var v int
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
defer wg.Done()
v++
v--
}()
}
wg.Wait()
t.Log(v)
}

func TestLint(t *testing.T) {
const v1 = (true && false) && (true && false) // SQ Identical expressions should not be used on both sides of a binary operator
a := 1
if !(a == 2) { // SQ boolean check should not be inverted
}
const UnusedVar = 1 // lint should complain for unused variable
const ALL_CAPS = 10 // should be AllCaps
err := os.ErrNotExist
if err == os.ErrNotExist { // should use errors.Is
err := errors.New("fake error") // shadowed variable
t.Log(err)
}
}

0 comments on commit ad3f64c

Please sign in to comment.