Skip to content

feat: introduce -fail-fast flag for src batch #1154

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

Merged
merged 8 commits into from
Mar 20, 2025
Merged

Conversation

bahrmichael
Copy link
Contributor

@bahrmichael bahrmichael commented Mar 19, 2025

Closes SRCH-1778

Customers want to iterate faster with batch changes, and they need the src cli to fail faster when something goes wrong.

This PR introduces a -fail-fast flag and migrates the concurrency in executor.go from github.com/neelance/parallel to github.com/sourcegraph/conc.

Test plan

New unit tests

Manual test:

We may be lucky that gitpod from the spec is the first task being processed. If the task you're failing on comes last, there may be no speed gain.

Spec
version: 2
name: t4
description: Add Hello World to READMEs

# Find the first 100 search results for README files.
# This could yield less than 100 repos/workspaces if some repos contain multiple READMEs.
on:
  - repositoriesMatchingQuery: repo:github.com/sourcegraph-testing/gi*

# In each repository, run this command. Each repository's resulting diff is captured.
steps:
  - if: ${{ eq repository.name "github.com/sourcegraph-testing/gitpod" }}
    run: exit 123
    container: ubuntu:18.04
  - run: IFS=$'\n'; echo Hello World | tee -a $(find -name README.md)
    container: ubuntu:18.04

# Describe the changeset (e.g., GitHub pull request) you want for each repository.
changesetTemplate:
  title: Hello World
  body: My first batch change!
  commit:
    message: Append Hello World to all README.md files
  # Optional: Push the commit to a branch named after this batch change by default.
  branch: ${{ batch_change.name }}
go run ./cmd/src batch preview -j 1 spec.yaml
go run ./cmd/src batch preview -j 1 spec.yaml
✅ Parsing batch spec
✅ Resolving namespace
✅ Preparing container images  ███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  100%
✅ Set workspace type
✅ Resolved 8 workspaces from 8 repositories
✅ Found 0 cached changeset specs; 8 tasks need to be executed
✅ Executing... (8/8, 1 errored)  ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  100%
│                                                                                                                                                                                                           
└── github.com/sourcegraph-testing/grpc-gateway  Done!                                                                                                                                                    3s

❌ Error:
   execution in github.com/sourcegraph-testing/gitpod failed: run: exit 123
   container: ubuntu:18.04
   
   Command failed with exit code 123. (see /tmp/changeset-github.com-sourcegraph-testing-gitpod-461d5b8262b63f53aed396b64ce382d6b64b5b17.1600092820.log for details)
   

💡 The troubleshooting documentation can help to narrow down the cause of the errors:
   https://docs.sourcegraph.com/batch_changes/references/troubleshooting
   
exit status 1

Cleared the cache with rm -R /Users/michael/Library/Caches/sourcegraph/batch/*

go run ./cmd/src batch preview -fail-fast -j 1 spec.yaml
go run ./cmd/src batch preview -fail-fast -j 1 spec.yaml
✅ Parsing batch spec
✅ Resolving namespace
✅ Preparing container images  ███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  100%
✅ Set workspace type
✅ Resolved 8 workspaces from 8 repositories
✅ Found 0 cached changeset specs; 8 tasks need to be executed
✅ Executing... (8/8, 8 errored)  ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  100%
│                                                                                                                                                                                                           
└── github.com/sourcegraph-testing/grpc-gateway  fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/grpc-gateway@e8ea5bde418a534334e8a34db7...  0s

❌ Error:
   execution in github.com/sourcegraph-testing/gitpod failed: run: exit 123
   container: ubuntu:18.04
   
   Command failed with exit code 123. (see /tmp/changeset-github.com-sourcegraph-testing-gitpod-461d5b8262b63f53aed396b64ce382d6b64b5b17.448801336.log for details)
   execution in github.com/sourcegraph-testing/go-repo-a failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/go-repo-a@b12a6b731d7d130281488ed43b25fd7a299cca15/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-go-repo-a-b12a6b731d7d130281488ed43b25fd7a299cca15.607195497.log for details)
   execution in github.com/sourcegraph-testing/go-repo-b failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/go-repo-b@5bd0d30b22a21c62589edddd3459a561ad457576/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-go-repo-b-5bd0d30b22a21c62589edddd3459a561ad457576.713813129.log for details)
   execution in github.com/sourcegraph-testing/go-repo-c failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/go-repo-c@be237e109171b586240a404a656dbbb01cafb424/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-go-repo-c-be237e109171b586240a404a656dbbb01cafb424.3132940962.log for details)
   execution in github.com/sourcegraph-testing/go-repo-d failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/go-repo-d@5ae7ccac1cee71d0b18b22de044061b67c8f8edb/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-go-repo-d-5ae7ccac1cee71d0b18b22de044061b67c8f8edb.3029611995.log for details)
   execution in github.com/sourcegraph-testing/gods failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/gods@dbdbadc158ae6b453820b3cfb8c6cb48be4d7ddf/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-gods-dbdbadc158ae6b453820b3cfb8c6cb48be4d7ddf.3512329585.log for details)
   execution in github.com/sourcegraph-testing/gophish failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/gophish@3863ad31b9e39025b10ce5ba0461d3f8e9d98f45/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-gophish-3863ad31b9e39025b10ce5ba0461d3f8e9d98f45.2318174745.log for details)
   execution in github.com/sourcegraph-testing/grpc-gateway failed: fetching repo: fetching ZIP archive: Get "https://sourcegraph.sourcegraph.com/github.com/sourcegraph-testing/grpc-gateway@e8ea5bde418a534334e8a34db7103b2db72be672/-/raw": context canceled (see /tmp/changeset-github.com-sourcegraph-testing-grpc-gateway-e8ea5bde418a534334e8a34db7103b2db72be672.2806333135.log for details)
   

💡 The troubleshooting documentation can help to narrow down the cause of the errors:
   https://docs.sourcegraph.com/batch_changes/references/troubleshooting
   
exit status 1

Cleared the cache with rm -R /Users/michael/Library/Caches/sourcegraph/batch/*

history -D
 1097  0:01  rm -R /Users/michael/Library/Caches/sourcegraph/batch/*
 1098  0:52  go run ./cmd/src batch preview -j 1 spec.yaml
 1099  0:01  rm -R /Users/michael/Library/Caches/sourcegraph/batch/*
 1100  0:19  go run ./cmd/src batch preview -fail-fast -j 1 spec.yaml

@bahrmichael bahrmichael requested a review from camdencheek March 20, 2025 09:52
@bahrmichael bahrmichael changed the title bahrmichael/fail-fast feat: introduce -fail-fast flag for src batch Mar 20, 2025
@bahrmichael bahrmichael marked this pull request as ready for review March 20, 2025 09:52
Copy link
Member

@camdencheek camdencheek left a comment

Choose a reason for hiding this comment

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

Couple small comments, but all the concurrency stuff looks great to me!

@bahrmichael bahrmichael merged commit 8d95a13 into main Mar 20, 2025
8 checks passed
@bahrmichael bahrmichael deleted the bahrmichael/fail-fast branch March 20, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants