Skip to content
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

[steps] Resolve absolute working_directory paths from repository root #484

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sjchmiela
Copy link
Contributor

@sjchmiela sjchmiela commented Jan 9, 2025

Why

With Workflows I expect more and more users will want to execute scripts related less to mobile app, in directories other than that of the mobile app.

Currently, working_directory works like this:

  • relative paths get resolved from the base directory (mobile app directory) — working_directory: scripts if base directory is apps/mobile ends up being /home/expo/build/apps/mobile/scripts
  • absolute paths get resolved from VM root — working_directory: /usr/local/bin ends up being /usr/local/bin.

This makes it cumbersome to execute scripts in directories other than that of mobile app. Say, a user wants to execute scripts in /apps/web. If base directory is apps/mobile, they'd need to use ../web. This makes working_directory coupled to base directory set in GitHub repository settings.

How

Here I'm special-casing absolute working_directory paths. I expect very few people to need to execute scripts in FS-absolute paths (/usr/local/bin). So now it is going to work like this:

  • (unchanged) relative paths get resolved from the base directory (mobile app directory) — working_directory: scripts if base directory is apps/mobile ends up being /home/expo/build/apps/mobile/scripts
  • absolute paths get resolved from repository root — working_directory: /usr/local/bin ends up being /home/expo/build/usr/local/bin.

Test Plan

Adjusted tests.

Also tested manually. A workflow like

jobs:
  test:
    steps:
      - run: pwd
      - run: pwd
        working_directory: /
      - run: pwd
        working_directory: ./
      - uses: eas/checkout
      - run: pwd
        working_directory: scripts
      - run: pwd
        working_directory: /apps/web

produces output like this
Zrzut ekranu 2025-01-9 o 14 12 39

@sjchmiela sjchmiela marked this pull request as ready for review January 9, 2025 13:13
@sjchmiela sjchmiela requested a review from szdziedzic as a code owner January 9, 2025 13:13
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.

1 participant