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

run specified steps outside of container before the container is launched #812

Closed
igagis opened this issue Nov 18, 2020 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@igagis
Copy link

igagis commented Nov 18, 2020

Let's consider the following workflow:

name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    container: debian:buster
    steps:
      - name: git clone
        uses: actions/checkout@main
      - name: build
        run: make

for job linux it will first launch the container, then checkout the source code (inside of the already running container?), then run the build step inside of the container.

What I want to be able to do is to add some pre-steps which would be run outside of the container and before the container is launched. In particular, I need this to install qemu and binfmt packages.
So, the workflow would look something like this:

name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    container: igagis/my_image:arm
    pre-steps:
      - name: install qemu and binfmt
        run: apt update && apt install --yes binfmt-support qemu-user-static
    steps:
      - name: git clone
        uses: actions/checkout@main
      - name: build
        run: make

Note, that I changed the container image to my custom built image for ARM architecture, i.e. all binaries inside of the image are ARM binaries.
After installing qemu and binfmt it is possible to run ARM binaries on x86_64 architecture, using emulation. This approach works for me on Travis-CI, but there I start the docker manually and, thus, I have full control over what I run in host environment and what inside of the container. Now I'm trying to move to github actions and have this problem that it is only possible to either run everything inside of the container or everything in host ubuntu virtual machine.

@igagis igagis added the enhancement New feature or request label Nov 18, 2020
@umarcor
Copy link

umarcor commented Nov 20, 2020

@igagis, the following alternatives might work for you. You can optionally setup QEMU for a target architecture only (see dbhi/qus).

name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main

      - uses: dbhi/qus/action@master

      - name: build
        uses: docker://debian:buster
        with:
          args: make
name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main

      - name: Setup QEMU
        run: docker run --rm --privileged aptman/qus -s -- -p

      - name: build
        uses: docker://debian:buster
        with:
          args: make
name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main

      - name: Setup QEMU
        run: apt update && apt install --yes binfmt-support qemu-user-static

      - name: build
        uses: docker://debian:buster
        with:
          args: make

@igagis
Copy link
Author

igagis commented Nov 20, 2020

Thanks!
I have also submitted actions/runner-images#2095

I understand that these pre-steps do not look like beautiful solution.

@mirabilos
Copy link

This is more difficult than it seems: GitHub fucks up argument quoting and passing, so the step.with.args cannot realistically be more than a simple shell script invocation, definitely not an inline command :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants