ros-tooling / action-ros-ci

Github Action to build and test ROS 2 packages using colcon
Apache License 2.0
144 stars 53 forks source link

GitHub Enterprise private repository action fails #923

Open seantfish opened 1 week ago

seantfish commented 1 week ago

Description

I am using a mirrored action-ros-ci repository to use on an Enterprise server. The action fails due to an issue seemingly related with Git and the way credentials are handled.

Expected Behavior

What I would expect is that this error would not happen and it would continue on into the build process.

Actual BehaviorWhen attempting to run the following:

name: Humble Source Build
on:
  workflow_dispatch:

jobs:
  humble_source:
    runs-on: ubuntu-latest
    container:
      image: osrf/ros:humble-desktop
      env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: <ENTERPRISE_MIRROR>/action-ros-ci@v0.3
        with:
          ref: humble
          target-ros2-distro: humble
          skip-tests: true
          import-token: ${{ secrets.GITHUB_TOKEN }}
          skip-rosdep-install: true
          rosdep-check: true

The action fails at:

Invoking: bash -c,vcs import --force --recursive src/ < package.repo
  /usr/bin/bash -c vcs import --force --recursive src/ < package.repo
  === src/yg5xuzuncnh/greenhorn (git) ===
Could not determine ref type of version: fatal: could not read Username for 'https://<ENTERPRISE_URL>/': No such device or address

To Reproduce

  1. Have the Git repository on an Enterprise server and run the above GitHub action.

  2. Navigate to details of failed action

  3. Look under Invoking: bash -c,vcs import --force --recursive src/ < package.repo

System (please complete the following information)

Additional context

There are no .repos dependencies specified for this repository.

This seems to possibly be an intersection of #533, #691, and #835.

I know this is hard to reproduce and I am happy to help. I am not very experienced with TypeScript however.

christophebedard commented 4 days ago

Could not determine ref type of version: fatal: could not read Username for 'https://<ENTERPRISE_URL>/': No such device or address

is the address valid? It uses the GitHub server URL from the GITHUB_SERVER_URL (see the default environment variables here) here: https://github.com/ros-tooling/action-ros-ci/blob/8bcafc257f491574fe99ddcfaf9e9a02757ca694/src/action-ros-ci.ts#L631

Now that I'm looking at the code, though, it's probably because the code that sets up authentication using the provided token uses github.com:

  1. In the setup: https://github.com/ros-tooling/action-ros-ci/blob/8bcafc257f491574fe99ddcfaf9e9a02757ca694/src/action-ros-ci.ts#L523-L572
  2. In the cleanup: https://github.com/ros-tooling/action-ros-ci/blob/8bcafc257f491574fe99ddcfaf9e9a02757ca694/src/action-ros-ci.ts#L786-L792

It should use the URL from the GITHUB_SERVER_URL environment variable, which would need to be stripped of https:// in some cases. I've quickly implemented it, see #926. Please give it a try using action-ros-ci@christophebedard/token-auth-use-github-server-url-env-var. I assume you can easily mirror the branch into your enterprise server.

This does mean you couldn't access private repos on github.com from an enterprise server using a token from github.com saved in the enterprise server, but I don't know if that's a common use-case.

seantfish commented 3 days ago

Thank you @christophebedard! The branch solved the issue. I agree that private repos from github.com while on GitHub Enterprise seems unlikely, though perhaps one day someone will make an issue for this. I imagine this would require a fair amount of restructuring to work.