OSnap icon indicating copy to clipboard operation
OSnap copied to clipboard

Container image fails when home dir changed, e.g. github actions

Open andrewbelcher opened this issue 6 months ago • 2 comments

Running osnap in github actions fails, it gets stuck attempting to download chrome.

The reason it can't find it is because chrome is in /root/..., but is then accessed via ~/... or $HOME/.... GitHub Actions overrides the home dir to /github/home, and so it fail to find the already installed chrome.

Adding the following step to the job makes everything work perfectly:

      - name: Copy osnap chromium into home
        run: mv /root/osnap* ~/

A couple potential ideas to mitigate this:

  • Use a full absolute path to the chrome install, i.e. /root/...
  • Perhaps having an actual run in the project actions - currently it just does osnap --help=plain which checks it's installed, but doesn't trigger a dependency check, e.g. chrome

andrewbelcher avatar May 28 '25 20:05 andrewbelcher

Hi 🙂

I am not quite sure I understand.

You are not running OSnap inside a docker container in Github Actions, right? Or is GitHub somehow changing the home path inside of the docker image?

Running real tests in the build pipeline is something on my todo list. Would be happy to accept contributions here 🙂

eWert-Online avatar May 29 '25 07:05 eWert-Online

So this is an example workflow:

name: osnap 

jobs:
  osnap:
    runs-on: ubuntu-latest
    name: Run OSnap tests
    container: osnap/debian:latest
    steps:
      # Various steps to get the app running locally...       
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      # Necessary step to get working in GitHub actions which modified the home directory.
      - name: Copy osnap chromium into home
        run: mv /root/osnap* ~/

      - name: Run the tests
        run: osnap

When you use a container for the test run itself, GitHub does a bunch of other things as well, such as mounting code etc. That includes modifying the home directory for root.

I'm sure it'd be possible to not use a container, and instead run docker run ... on the host itself, I expect that would not exhibit the same behaviour.

andrewbelcher avatar May 29 '25 08:05 andrewbelcher