forked from phoedos/pmd
Add docker for testing
This commit is contained in:
.ci
@ -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 <https://github.com/actions/virtual-environments>).
|
||||
|
||||
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
|
||||
```
|
||||
|
37
.ci/docker_ubuntu18.04/Dockerfile
Normal file
37
.ci/docker_ubuntu18.04/Dockerfile
Normal file
@ -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
|
||||
#
|
10
.ci/docker_ubuntu18.04/create-gh-pull-request-event.sh
Executable file
10
.ci/docker_ubuntu18.04/create-gh-pull-request-event.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat > /workspaces/event.json <<EOF
|
||||
{
|
||||
"number": ${PMD_CI_PULL_REQUEST_NUMBER},
|
||||
"repository": {
|
||||
"clone_url": "https://github.com/pmd/pmd.git"
|
||||
}
|
||||
}
|
||||
EOF
|
8
.ci/docker_ubuntu18.04/install-ruby.sh
Executable file
8
.ci/docker_ubuntu18.04/install-ruby.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
||||
curl -sSL https://get.rvm.io | bash -s stable
|
||||
source ~/.rvm/scripts/rvm
|
||||
rvm install 2.7
|
||||
rvm use 2.7 --default
|
||||
ruby -v
|
Reference in New Issue
Block a user