Skip to content
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
23 changes: 3 additions & 20 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- name: lint system workflows with workflowcheck
run: make workflowcheck

fmt-imports:
fmt:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v6
Expand All @@ -101,7 +101,7 @@ jobs:

- name: format golang import statements
run: |
make fmt-imports
make fmt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes make fmt-gofix and make fmt-yaml, too, now.


- name: check-is-dirty
run: |
Expand All @@ -112,22 +112,6 @@ jobs:
exit 1
fi

lint-yaml:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make fmt already invokes make fmt-yaml

runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
check-latest: true
cache: true

- name: check yaml formatting
run: make lint-yaml

parallelize-tests:
runs-on: ubuntu-24.04-arm
steps:
Expand Down Expand Up @@ -183,11 +167,10 @@ jobs:
linters-succeed:
name: All Linters Succeed
needs:
- fmt
- lint-api
- lint-protos
- lint-actions
- fmt-imports
- lint-yaml
- golangci
- parallelize-tests
runs-on: ubuntu-24.04-arm
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,22 @@ fmt: fmt-gofix fmt-imports fmt-yaml

# Some fixes enable others (e.g. rangeint may expose minmax opportunities),
# so - as recommended by the Go team - we run go fix in a loop until it reaches
# a fixed point (exit code 0)
# a fixed point. We check for "files updated" in the output rather than relying
# on the exit code alone, since go fix can exit non-zero without actually
# modifying any files (see https://github.com/golang/go/issues/77482).
# Note: go fix automatically skips generated files.
GOFIX_FLAGS ?= -any -rangeint
GOFIX_MAX_ITERATIONS ?= 5
fmt-gofix:
@printf $(COLOR) "Run go fix..."
@while ! go fix -any -rangeint ./...; do \
@n=0; while [ $$n -lt $(GOFIX_MAX_ITERATIONS) ]; do \
output=$$(go fix $(GOFIX_FLAGS) ./... 2>&1); \
echo "$$output"; \
if ! echo "$$output" | grep -q "files updated"; then break; fi; \
n=$$((n + 1)); \
printf $(COLOR) "Re-running go fix..."; \
done
done; \
if [ $$n -ge $(GOFIX_MAX_ITERATIONS) ]; then echo "ERROR: go fix did not converge after $(GOFIX_MAX_ITERATIONS) iterations"; exit 1; fi

fmt-imports: $(GCI) # Don't get confused, there is a single linter called gci, which is a part of the mega linter we use is called golangci-lint.
@printf $(COLOR) "Formatting imports..."
Expand Down
26 changes: 13 additions & 13 deletions common/tasks/execution_queue_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *executionQueueSchedulerSuite) TestSequentialExecution_SameWorkflow() {
testWG := sync.WaitGroup{}
testWG.Add(numTasks)

for i := 0; i < numTasks; i++ {
for i := range numTasks {
taskIndex := i
mockTask := NewMockTask(s.controller)
mockTask.EXPECT().RetryPolicy().Return(s.retryPolicy).AnyTimes()
Expand All @@ -144,7 +144,7 @@ func (s *executionQueueSchedulerSuite) TestSequentialExecution_SameWorkflow() {

// Verify tasks executed in order
s.Len(executionOrder, numTasks)
for i := 0; i < numTasks; i++ {
for i := range numTasks {
s.Equal(i, executionOrder[i], "Tasks should execute in submission order")
}
}
Expand All @@ -163,15 +163,15 @@ func (s *executionQueueSchedulerSuite) TestSequentialExecution_DifferentWorkflow
orders []int
}
executionOrders := make([]*workflowOrders, numWorkflows)
for i := 0; i < numWorkflows; i++ {
for i := range numWorkflows {
executionOrders[i] = &workflowOrders{orders: make([]int, 0, tasksPerWorkflow)}
}

testWG := sync.WaitGroup{}
testWG.Add(numWorkflows * tasksPerWorkflow)

for wf := 0; wf < numWorkflows; wf++ {
for t := 0; t < tasksPerWorkflow; t++ {
for wf := range numWorkflows {
for t := range tasksPerWorkflow {
workflowID := wf
taskIndex := t
mockTask := NewMockTask(s.controller)
Expand All @@ -191,9 +191,9 @@ func (s *executionQueueSchedulerSuite) TestSequentialExecution_DifferentWorkflow
testWG.Wait()

// Verify each workflow's tasks executed in order
for wf := 0; wf < numWorkflows; wf++ {
for wf := range numWorkflows {
s.Len(executionOrders[wf].orders, tasksPerWorkflow)
for i := 0; i < tasksPerWorkflow; i++ {
for i := range tasksPerWorkflow {
s.Equal(i, executionOrders[wf].orders[i], "Workflow %d tasks should execute in order", wf)
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func (s *executionQueueSchedulerSuite) TestTTLExpiryRace_NoTaskOrphaning() {
var processedCount int32
testWG := sync.WaitGroup{}

for i := 0; i < iterations; i++ {
for range iterations {
testWG.Add(1)

mockTask := NewMockTask(s.controller)
Expand Down Expand Up @@ -445,7 +445,7 @@ func (s *executionQueueSchedulerSuite) TestMaxQueues_RejectsNewQueues() {
blockCh := make(chan struct{})
defer close(blockCh)

for i := 0; i < 2; i++ {
for i := range 2 {
mockTask := NewMockTask(s.controller)
mockTask.EXPECT().RetryPolicy().Return(s.retryPolicy).AnyTimes()
mockTask.EXPECT().Execute().DoAndReturn(func() error {
Expand Down Expand Up @@ -483,13 +483,13 @@ func (s *executionQueueSchedulerSuite) TestParallelTrySubmit_DifferentWorkflows(
startWG := sync.WaitGroup{}
startWG.Add(numSubmitters)

for i := 0; i < numSubmitters; i++ {
for i := range numSubmitters {
submitterID := i
go func() {
startWG.Done()
startWG.Wait() // Sync all submitters to start at once

for j := 0; j < tasksPerSubmitter; j++ {
for range tasksPerSubmitter {
mockTask := NewMockTask(s.controller)
mockTask.EXPECT().RetryPolicy().Return(s.retryPolicy).AnyTimes()
mockTask.EXPECT().Execute().Return(nil).Times(1)
Expand Down Expand Up @@ -530,12 +530,12 @@ func (s *executionQueueSchedulerSuite) TestParallelTrySubmit_SameWorkflow() {
startWG := sync.WaitGroup{}
startWG.Add(numSubmitters)

for i := 0; i < numSubmitters; i++ {
for range numSubmitters {
go func() {
startWG.Done()
startWG.Wait()

for j := 0; j < tasksPerSubmitter; j++ {
for range tasksPerSubmitter {
mockTask := NewMockTask(s.controller)
mockTask.EXPECT().RetryPolicy().Return(s.retryPolicy).AnyTimes()
mockTask.EXPECT().Execute().DoAndReturn(func() error {
Expand Down
2 changes: 1 addition & 1 deletion tools/flakereport/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func processArtifactsParallel(ctx context.Context, jobs []ArtifactJob, concurren

// Start worker pool
var wg sync.WaitGroup
for i := 0; i < concurrency; i++ {
for range concurrency {
wg.Add(1)
go worker(ctx, jobChan, resultChan, totalArtifacts, &wg)
}
Expand Down
Loading