From 6b2b33bdece6ad2a863bafd3941836b25584f5c0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 12 Nov 2020 16:13:02 +0100 Subject: [PATCH] Add docker for testing --- .ci/README.md | 22 +++++++++-- .ci/docker_ubuntu18.04/Dockerfile | 37 +++++++++++++++++++ .../create-gh-pull-request-event.sh | 10 +++++ .ci/docker_ubuntu18.04/install-ruby.sh | 8 ++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 .ci/docker_ubuntu18.04/Dockerfile create mode 100755 .ci/docker_ubuntu18.04/create-gh-pull-request-event.sh create mode 100755 .ci/docker_ubuntu18.04/install-ruby.sh diff --git a/.ci/README.md b/.ci/README.md index 96d6091bd4..13ec72eba0 100644 --- a/.ci/README.md +++ b/.ci/README.md @@ -55,11 +55,25 @@ is not protected. ### Local tests -You can run a local instance with docker: +Create a local docker container: ``` -docker run -it --mount type=bind,source=path/to/pmd,target=/workspaces/pmd/pmd ubuntu:latest +cd .ci/docker_ubuntu18.04 +docker build -t pmd-ci . ``` -You'll need to install a few packages before you can start... You can verify with `check-environment.sh` -if everything is prepared. +This container is based on Ubuntu 18.04, which is used for `ubuntu-latest` github actions runner +(see ). + +You can run a local instance with docker and mount your local pmd checkout into the container: + +``` +docker run -it --mount type=bind,source=path/to/pmd,target=/workspaces/pmd/pmd pmd-ci +``` + +You'll be dropped into a bash. Start e.g. with + +``` +cd workspaces/pmd/pmd +.ci/check-environment.sh +``` diff --git a/.ci/docker_ubuntu18.04/Dockerfile b/.ci/docker_ubuntu18.04/Dockerfile new file mode 100644 index 0000000000..ae761efa59 --- /dev/null +++ b/.ci/docker_ubuntu18.04/Dockerfile @@ -0,0 +1,37 @@ +# https://hub.docker.com/_/ubuntu/ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get upgrade --yes && \ + apt-get install --yes curl jq gpg rsync ssh git p7zip-full openjdk-8-jdk \ + libgdbm-dev libncurses5-dev automake libtool bison libffi-dev \ + sudo nano bash && \ + apt-get clean +RUN cd opt && \ + curl https://mirror.checkdomain.de/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xz && \ + ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/local/bin/mvn && \ + cd .. +RUN groupadd --gid 1000 pmd-ci && useradd --gid 1000 --uid 1000 --groups sudo \ + --shell /bin/bash --create-home --password "" \ + pmd-ci + +RUN mkdir /workspaces && chown pmd-ci:pmd-ci /workspaces && ln -sf /workspaces /home/pmd-ci/workspaces + +USER pmd-ci:pmd-ci +WORKDIR /home/pmd-ci +ENV GITHUB_EVENT_PATH=/workspaces/event.json +ENV GITHUB_REPOSITORY=pmd/pmd +ENV GITHUB_ACTION=run1 +ENV GITHUB_EVENT_NAME=pull_request +ENV PMD_CI_BRANCH=refs/heads/master +ENV PMD_CI_PULL_REQUEST_NUMBER=2913 +COPY create-gh-pull-request-event.sh . +COPY install-ruby.sh . +RUN ./install-ruby.sh +RUN ./create-gh-pull-request-event.sh + +CMD ["/bin/bash", "--login"] + +# +# build with: docker build -t pmd-ci . +# run with: docker run -it pmd-ci +# \ No newline at end of file diff --git a/.ci/docker_ubuntu18.04/create-gh-pull-request-event.sh b/.ci/docker_ubuntu18.04/create-gh-pull-request-event.sh new file mode 100755 index 0000000000..7f3576196e --- /dev/null +++ b/.ci/docker_ubuntu18.04/create-gh-pull-request-event.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cat > /workspaces/event.json <