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
7 changes: 3 additions & 4 deletions .github/workflows/build-ruby-from-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ jobs:
R2_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
R2_SECRET_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
run: |
ARGS=""
R2_ARGS="--r2-endpoint=$R2_ENDPOINT --r2-bucket=$R2_BUCKET --r2-access-key=$R2_ACCESS_KEY --r2-secret-key=$R2_SECRET_KEY"
ARGS="$R2_ARGS"
if [ -n "${{ inputs.version }}" ]; then
ARGS="--version=${{ inputs.version }}"
else
ARGS="--r2-endpoint=$R2_ENDPOINT --r2-bucket=$R2_BUCKET --r2-access-key=$R2_ACCESS_KEY --r2-secret-key=$R2_SECRET_KEY"
ARGS="--version=${{ inputs.version }} $R2_ARGS"
fi

MATRIX=$(./scripts/detect-ruby-gaps/detect-ruby-gaps $ARGS)
Expand Down
28 changes: 21 additions & 7 deletions scripts/detect-ruby-gaps/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var allPlatforms = []Platform{
}

var (
versionFlag = flag.String("version", "", "Force all 6 platforms for this version (no R2 check)")
versionFlag = flag.String("version", "", "Build missing platforms for this version (checks R2 if credentials provided, otherwise all platforms)")
r2Endpoint = flag.String("r2-endpoint", "", "R2 endpoint URL")
r2Bucket = flag.String("r2-bucket", "", "R2 bucket name")
r2AccessKey = flag.String("r2-access-key", "", "R2 access key ID")
Expand All @@ -77,17 +77,31 @@ var httpClient = &http.Client{
func main() {
flag.Parse()

// If --version is provided, output all 6 platforms without R2 check
hasR2Creds := *r2Endpoint != "" && *r2Bucket != "" && *r2AccessKey != "" && *r2SecretKey != ""

if *versionFlag != "" {
matrix := buildMatrixForVersion(*versionFlag)
outputMatrix(matrix)
// --version provided: check R2 if credentials available, otherwise output all platforms
if hasR2Creds {
fmt.Fprintf(os.Stderr, "Checking R2 for existing builds of Ruby %s...\n", *versionFlag)
existingMeta, err := fetchExistingMeta()
if err != nil {
fmt.Fprintf(os.Stderr, "Error fetching R2 metadata: %v\n", err)
os.Exit(1)
}
matrix := computeGaps([]string{*versionFlag}, existingMeta)
fmt.Fprintf(os.Stderr, "Detected %d missing platforms for %s\n", len(matrix.Include), *versionFlag)
outputMatrix(matrix)
} else {
fmt.Fprintln(os.Stderr, "No R2 credentials provided, outputting all platforms")
matrix := buildMatrixForVersion(*versionFlag)
outputMatrix(matrix)
}
return
}

// Otherwise, detect gaps by comparing upstream vs R2
if *r2Endpoint == "" || *r2Bucket == "" || *r2AccessKey == "" || *r2SecretKey == "" {
// No --version: full auto-detect requires R2 credentials
if !hasR2Creds {
fmt.Fprintln(os.Stderr, "Error: R2 credentials required (--r2-endpoint, --r2-bucket, --r2-access-key, --r2-secret-key)")
fmt.Fprintln(os.Stderr, " Or use --version=X to force all platforms for a specific version")
os.Exit(1)
}

Expand Down