Skip to content

Commit

Permalink
Get list of affected files
Browse files Browse the repository at this point in the history
  • Loading branch information
chudilka1 committed Dec 9, 2024
1 parent e94f624 commit 58194e2
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 21 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
permissions:
pull-requests: read
outputs:
affected-packages: ${{ steps.affected-modules.outputs.changes }}
affected-packages: ${{ steps.match-every.outputs.non-ignored_files }}
deployment-changes: ${{ steps.match-some.outputs.deployment == 'true' }}
should-run-ci-core: ${{ steps.match-some.outputs.core-ci == 'true' || steps.match-every.outputs.non-ignored == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
should-run-golangci: ${{ steps.match-some.outputs.golang-ci == 'true' || steps.match-every.outputs.non-ignored == 'true' || github.event_name == 'workflow_dispatch' }}
Expand Down Expand Up @@ -69,6 +69,10 @@ jobs:
# non-integration-tests - only changes made outside of the `integration-tests` directory
# non-ignored - only changes except for the negated ones
# - This is opt-in on purpose. To be safe, new files are assumed to have an affect on CI Core unless listed here specifically.
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
# Paths will be formatted as JSON array
list-files: json
filters: |
non-integration-tests:
- '**'
Expand All @@ -77,7 +81,6 @@ jobs:
- '**'
- '!docs/**'
- '!fuzz/**'
- '!integration-tests/**'
- '!tools/secrets/**'
- '!tools/goreleaser-config/**'
- '!tools/docker/**'
Expand All @@ -93,24 +96,13 @@ jobs:
- '!nix-darwin-shell-hook.sh'
- '!LICENSE'
- '!.github/**'
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: affected-modules
with:
# This filter returns a list of affected packages names (not simply `true` or `false`)
# Use the following syntax `package_name: 'path/to/package/**'`
filters: |
ccip: 'ccip/**'
common: 'common/**'
core: 'core/**'
dashboard-lib: 'dashboard-lib/**'
deployment: 'deployment/**'
plugins: 'plugins/**'
tools: 'tools/**'
- name: TEST
run: echo "${{ steps.match-every.outputs.non-ignored_files }}"

golangci:
name: lint
# We don't directly merge dependabot PRs, so let's 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' && (toJson(fromJson(needs.filter.outputs.affected-packages)) != '[]' && needs.filter.outputs.affected-packages != '')}}
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' && needs.filter.outputs.should-run-golangci == 'true' }}
needs: [filter, run-frequency]
permissions:
# To annotate code in the PR.
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ cl_backup_*.tar.gz

# Test artifacts
core/cmd/TestClient_ImportExportP2PKeyBundle_test_key.json
output.txt
race.*
golangci-lint-output.txt
*output.txt
/golangci-lint/
.covdata
core/services/job/testdata/wasm/testmodule.wasm
Expand Down
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ nodejs 20.13.1
pnpm 9.4.0
postgres 15.1
helm 3.10.3
golangci-lint 1.61.0
golangci-lint 1.62.2
protoc 25.1
python 3.10.5
act 0.2.30
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ config-docs: ## Generate core node configuration documentation
.PHONY: golangci-lint
golangci-lint: ## Run golangci-lint for all issues.
[ -d "./golangci-lint" ] || mkdir ./golangci-lint && \
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 | tee ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.62.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 | tee ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt

.PHONY: modgraph
modgraph:
Expand Down
49 changes: 49 additions & 0 deletions deployment/fail_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package deployment

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)
}
}
49 changes: 49 additions & 0 deletions integration-tests/fail_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

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

Check failure on line 38 in integration-tests/fail_test.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

constant-logical-expr: left and right hand-side sub-expressions are the same (revive)
a := 1
if !(a == 2) { // SQ boolean check should not be inverted

Check failure on line 40 in integration-tests/fail_test.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

empty-block: this block is empty, you can remove it (revive)
}
const UnusedVar = 1 // lint should complain for unused variable

Check failure on line 42 in integration-tests/fail_test.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

const `UnusedVar` is unused (unused)
const ALL_CAPS = 10 // should be AllCaps

Check failure on line 43 in integration-tests/fail_test.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

const `ALL_CAPS` is unused (unused)
err := os.ErrNotExist
if err == os.ErrNotExist { // should use errors.Is

Check failure on line 45 in integration-tests/fail_test.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
err := errors.New("fake error") // shadowed variable
t.Log(err)
}
}

0 comments on commit 58194e2

Please sign in to comment.