Skip to content

feat: Fix critical bugs and improve copybara-action flexibility#139

Open
fireboy1919 wants to merge 1 commit into
Olivr:mainfrom
fireboy1919:copybara-improvements
Open

feat: Fix critical bugs and improve copybara-action flexibility#139
fireboy1919 wants to merge 1 commit into
Olivr:mainfrom
fireboy1919:copybara-improvements

Conversation

@fireboy1919

Copy link
Copy Markdown

This commit consolidates bug fixes and enhancements to make the copybara-action more flexible and resolve reported issues.

Bug Fixes

1. Fixed Copybara Options Passing (fixes #136) Issue: Options passed via copybara_options weren't reaching the copybara command Root Cause: COPYBARA_OPTIONS was set as environment variable but never used Fix: Pass options directly as command line arguments to docker/copybara Impact: All copybara CLI options now work correctly

2. Fixed Custom Config File Support (fixes #130) Issue: Custom copybara config files caused TypeError crashes Root Cause: Action always set COPYBARA_CONFIG env var, conflicting with user configs Fix: Detect when user provides config file in options and skip setting env var Impact: Users can now successfully use custom .bara.sky files

Enhancements

3. Made SSH Key Optional

Enhancement: SSH key is no longer required for workflows using HTTPS authentication Implementation: Conditionally mount SSH key volume only if key file exists Benefit: Enables HTTPS-only workflows without dummy SSH key files

4. Support Custom Workflow Names in Options

Enhancement: Users can specify workflow names directly in copybara_options Implementation: Detect 'migrate' or config file in options and skip COPYBARA_WORKFLOW env var Benefit: More flexibility for advanced copybara configurations

5. Improved Environment Variable Handling

Enhancement: Cleaner separation between action defaults and user overrides Implementation:

  • COPYBARA_WORKFLOW only set when not provided by user
  • COPYBARA_CONFIG only set when user hasn't provided custom config Benefit: Reduces env var conflicts and improves predictability

Technical Changes

src/copybara.ts:

  • Added detection for workflow names in copybara_options (lines 17, 34-36)
  • Added detection for config files in copybara_options (lines 72, 86-88)
  • Changed from -e COPYBARA_OPTIONS to direct argument passing (lines 90-95)
  • Made SSH key volume mount conditional (lines 67-69)

src/copybaraAction.ts:

  • Made SSH key saving conditional at line 142

dist/index.js:

  • Rebuilt distribution with all changes

Use Cases Enabled

  1. HTTPS-only workflows: No SSH key required
  2. Custom configs: Users can provide their own .bara.sky files (Custom Copybara file support might be broken? #130)
  3. Custom workflows: Users can specify workflow names in options
  4. Complex option passing: All copybara CLI options work correctly (Simple Copybara job fails #136)

Backward Compatibility

All changes are backward compatible. Existing workflows continue to work as before. The improvements only enhance functionality for users who want to:

  • Skip SSH authentication
  • Provide custom copybara configs
  • Use advanced copybara CLI options

Testing

Tested with airbnb/viaduct demo app publishing workflow, which successfully publishes to three external repositories using custom config and options.

Fixes #130
Fixes #136

Pull request

Related issue

Motivation and context

Solution

How has this been tested

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This commit consolidates bug fixes and enhancements to make the copybara-action
more flexible and resolve reported issues.

## Bug Fixes

### 1. Fixed Copybara Options Passing (fixes Olivr#136)
**Issue:** Options passed via copybara_options weren't reaching the copybara command
**Root Cause:** COPYBARA_OPTIONS was set as environment variable but never used
**Fix:** Pass options directly as command line arguments to docker/copybara
**Impact:** All copybara CLI options now work correctly

### 2. Fixed Custom Config File Support (fixes Olivr#130)
**Issue:** Custom copybara config files caused TypeError crashes
**Root Cause:** Action always set COPYBARA_CONFIG env var, conflicting with user configs
**Fix:** Detect when user provides config file in options and skip setting env var
**Impact:** Users can now successfully use custom .bara.sky files

## Enhancements

### 3. Made SSH Key Optional
**Enhancement:** SSH key is no longer required for workflows using HTTPS authentication
**Implementation:** Conditionally mount SSH key volume only if key file exists
**Benefit:** Enables HTTPS-only workflows without dummy SSH key files

### 4. Support Custom Workflow Names in Options
**Enhancement:** Users can specify workflow names directly in copybara_options
**Implementation:** Detect 'migrate' or config file in options and skip COPYBARA_WORKFLOW env var
**Benefit:** More flexibility for advanced copybara configurations

### 5. Improved Environment Variable Handling
**Enhancement:** Cleaner separation between action defaults and user overrides
**Implementation:**
  - COPYBARA_WORKFLOW only set when not provided by user
  - COPYBARA_CONFIG only set when user hasn't provided custom config
**Benefit:** Reduces env var conflicts and improves predictability

## Technical Changes

**src/copybara.ts:**
- Added detection for workflow names in copybara_options (lines 17, 34-36)
- Added detection for config files in copybara_options (lines 72, 86-88)
- Changed from -e COPYBARA_OPTIONS to direct argument passing (lines 90-95)
- Made SSH key volume mount conditional (lines 67-69)

**src/copybaraAction.ts:**
- Made SSH key saving conditional at line 142

**dist/index.js:**
- Rebuilt distribution with all changes

## Use Cases Enabled

1. **HTTPS-only workflows:** No SSH key required
2. **Custom configs:** Users can provide their own .bara.sky files (Olivr#130)
3. **Custom workflows:** Users can specify workflow names in options
4. **Complex option passing:** All copybara CLI options work correctly (Olivr#136)

## Backward Compatibility

All changes are backward compatible. Existing workflows continue to work as before.
The improvements only enhance functionality for users who want to:
- Skip SSH authentication
- Provide custom copybara configs
- Use advanced copybara CLI options

## Testing

Tested with airbnb/viaduct demo app publishing workflow, which successfully
publishes to three external repositories using custom config and options.

Fixes Olivr#130
Fixes Olivr#136
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.

Simple Copybara job fails Custom Copybara file support might be broken?

1 participant