gazebo-tooling / release-tools

8 stars 9 forks source link

Reproduce the Jenkins CI linux build locally #923

Open j-rivero opened 1 year ago

j-rivero commented 1 year ago

It should be possible trying to reproduce a Linux build on Jenkins in a local system in a non very difficult way. They mainly consist in a Docker enviroment + build.sh script and a custom way of running them in using docker run parameters.

Roadmap:

Known problems:

j-rivero commented 1 year ago

Use an easy way for running docker build + docker run with all the arguments setup correctly.

docker build uses $USER/$GUI/$UID variables from active session. Can not find a way of using devcontainer.json file to include them.

Using docker compose it is also not fully clean since UID/GUI seems not easy to deal with:

services:
  jenkins-build:
    image: buildoo/jenkinsbuild
    build:
      context: .
      dockerfile: Dockerfile
      args:
        GID: ${GID}
        USERID: ${USERID}
        USER: ${USER}

Via:

USERID=$(id -u) GID=$(id -g) docker compose build
USERID=$(id -u) GID=$(id -g) docker compose run --rm -e DISPLAY=unix${DISPLAY} -v /sys:/sys:ro -v /tmp/.X11-unix:/tmp/.X11-unix:rw -e TERM=xterm-256color -v /dev/log:/dev/log:ro -v /run/log:/run/log:ro jenkins-build
j-rivero commented 4 months ago

While debugging an -install- type of job, I've been developing the compose configuration to something that is usable to reproduce the build locally for an X kind of job:

services:
  jenkins-build:
    image: buildoo/jenkinsbuild
    build:
      context: .
      dockerfile: Dockerfile
      args:
        GID: ${GID}
        USERID: ${USERID}
        USER: ${USER}
  run-jenkins-build:
    image: buildoo/jenkinsbuild
    stdin_open: true 
    tty: true
    environment:
        - DISPLAY=unix${DISPLAY}
        - TERM=xterm-256color
        - GID=${GID}
        - USERID=${USERID}
        - USER=${USER}
    volumes:
        - /sys:/sys:ro
        - /tmp/.X11-unix:/tmp/.X11-unix:rw
        - /dev/log:/dev/log:ro
        - /run/log:/run/log:ro
    entrypoint: ['./build.sh']

Via:

USERID=$(id -u) GID=$(id -g) docker compose build
USERID=$(id -u) GID=$(id -g) docker compose run --rm run-jenkins-build

That will reproduce the build of for example https://build.osrfoundation.org/job/ros_gzharmonic_bridge-install-pkg_iron-ci-jammy-amd64 . To obtain a debugging shell in the fail of the build.sh command, we will need to add to that script the bash trap:

trap "/bin/bash" 0 INT QUIT ABRT PIPE TERM
j-rivero commented 2 months ago

The noble images could be currently broken since they have a default ubuntu user with UID 1000. This could match the local user UID hence broken.