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

Support multiple branches being checked out through config #214

Closed
bnb opened this issue Apr 9, 2020 · 4 comments · Fixed by #258
Closed

Support multiple branches being checked out through config #214

bnb opened this issue Apr 9, 2020 · 4 comments · Fixed by #258

Comments

@bnb
Copy link

bnb commented Apr 9, 2020

I've been working on Actions CI that leverages both actions/checkout and Jest for tests.

I am specifically using Jest's changedSince flag, which compares the current branch with the passed branch and limits the tests it is running to only those that are associated with the files changed. This is particularly useful for only running the relevant tests when compared against master in a PR.

It would significantly reduce the necessary work for users if there was a way to include multiple branches in the run through a simple YAML property. At present, I need to do this:

    steps:
    - uses: actions/checkout@v2
    - run: |
        git fetch --no-tags --depth=1 origin master
        git checkout -b master
        git checkout ${{ github.event.pull_request.head.sha }}

something like the following would be amazingly useful, where checkout is an array of branches to checkout on every run while still keeping the PR's branch as the currently checked out branch:

    steps:
    - uses: actions/checkout@v2
       checkout: ['master']

checkout may not be the most appropriate name, but the idea is more of what I'm going for here ❤️

@jarshwah
Copy link

Thanks for the tip on checking out multiple refs, that's going to help me out!

My use case is similar - running linting tools only on the files that have changed using pre-commit. To do this, I use the following command:

pre-commit run --show-diff-on-failure --source origin/master --origin HEAD

But this isn't possible without specific run commands as @bnb has shown above.

@ericsciple
Copy link
Contributor

i think this proposal would fix: #155

@pelotom
Copy link

pelotom commented Jul 13, 2020

Is there any way around this issue in checkout@v2? With checkout@v1 we were able to make use of the origin/master ref, but mysteriously it is no longer available in v2. I need v2 due to this, but also need access origin/master for use with Jest's --changedSince. Has anyone found a workaround?

@DiFuks
Copy link

DiFuks commented May 7, 2024

@bnb Thank you for your hint! Actually, your example is not quite correct. When switching to master, you create a new branch from the current one, rather than switching to origin/master. It should be like this:

steps:
    - uses: actions/checkout@v2
    - run: |
        git fetch --no-tags --depth=1 origin master
        git checkout master
        git checkout ${{ github.event.pull_request.head.sha }}

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 a pull request may close this issue.

6 participants
@pelotom @bnb @jarshwah @ericsciple @DiFuks and others