1

I want to run the Unit Tests of my Bitbucket CI Pipeline using a local runner on an Arduino Due. I already managed to set up the Bitbucket Pipeline that runs the unit tests on a local runner. I use my own Dockerfile:

# Dockerfile

FROM infinitecoding/platformio-for-ci:latest

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install the PlatformIO Atmel SAM platform as well as other dependencies
RUN curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | tee /lib/udev/rules.d/99-platformio-udev.rules \
    && cd /app \
    && pio pkg install \
    && pio pkg install -g --tool "platformio/tool-bossac@~1.10700.0" \
    && pio pkg install -g --tool "platformio/tool-scons@~4.40400.0"

# Start the application
CMD ["bash"]

I build this with docker build -t platformio-atmelsam-due . and then upload it to docker hub. Then, I use this in bitbucket-pipelines.yml

# bitbucket-pipelines.yml

image: <my-namespace>/platformio-atmelsam-due

pipelines:
  default:
    - parallel:
      - step:
          name: 'Build and Test'
          runs-on:
            - self.hosted
            - linux
          script:
            - chmod a+x ./scripts/build.sh
            - ./scripts/build.sh
      - step:
...

where <my-namespace> is of course replaced by my docker hub account name. In the ./scripts/build.sh file, I run the tests on the native environment, so on the local runner. This all works perfectly fine. Now I want to change it to run on the due environment, so the Arduino Due that is connected over USB to the local runner.

When I manually run my docker image on the local machine with docker run -it --device=/dev/ttyACM3 platformio-atmelsam-due, then running the unit tests on the Arduino works. However, it needs the --device option, which I can't pass in the Bitbucket pipeline.

I have tried it by adding another step to the pipeline where I build the docker image like this:

image: <my-namespace>/platformio-atmelsam-due

pipelines:
  default:
    - step:
          name: 'Build Docker'
          runs-on:
            - self.hosted
            - linux
          script:
            - export DOCKER_BUILDKIT=0
            - docker run -t --device=/dev/ttyACM3 platformio-atmelsam-due
          services:
            - docker
    - parallel:
      - step:
          name: 'Build and Test'
          runs-on:
            - self.hosted
            - linux
          script:
            - chmod a+x ./scripts/build.sh
            - ./scripts/build.sh
      - step: ...

However, this doesn't work (it fails with docker: Error response from daemon: authorization denied by plugin pipelines: --devices is not allowed.). But even if it worked, this step would take a long time and slow down my CI process a lot.

So my question is, is there a better way than building the docker image in the CI pipeline? Can I somehow "bake" the tty access rights into the docker image?

ilja
  • 109
  • 7

0 Answers0