From 573d92082145da29019d6440bfafee77244f470d Mon Sep 17 00:00:00 2001 From: Stanislav Bogatyrev Date: Mon, 20 Mar 2023 18:22:36 +0300 Subject: [PATCH] [#149] Use custom image and kludges for node Until #139 is fixed, we can't use root inside Docker container running CI, but Woodpecker CI can't run non-root containers until they fix https://github.com/woodpecker-ci/woodpecker/issues/1077, hence we use temporary kludges with custom image and manual permissions in pipelines. Signed-off-by: Stanislav Bogatyrev --- .docker/Dockerfile.ci | 25 +++++++++++++++++++++++++ .woodpecker/full-pre-commit.yml | 11 +++++++++++ .woodpecker/pre-commit.yml | 17 +++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .docker/Dockerfile.ci create mode 100644 .woodpecker/full-pre-commit.yml create mode 100644 .woodpecker/pre-commit.yml diff --git a/.docker/Dockerfile.ci b/.docker/Dockerfile.ci new file mode 100644 index 000000000..010616a17 --- /dev/null +++ b/.docker/Dockerfile.ci @@ -0,0 +1,25 @@ +FROM golang:1.19 + +WORKDIR /tmp + +# Install apt packages +RUN apt-get update && apt-get install --no-install-recommends -y \ + pip \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ + && rm -rf /var/lib/apt/lists/* + +# Dash → Bash +RUN echo "dash dash/sh boolean false" | debconf-set-selections +RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash + +RUN useradd -u 1234 -d /home/ci -m ci +USER ci + +ENV PATH="$PATH:/home/ci/.local/bin" + +COPY .pre-commit-config.yaml . + +RUN pip install "pre-commit==3.1.1" \ + && git init . \ + && pre-commit install-hooks \ + && rm -rf /tmp/* diff --git a/.woodpecker/full-pre-commit.yml b/.woodpecker/full-pre-commit.yml new file mode 100644 index 000000000..4aa62c1c0 --- /dev/null +++ b/.woodpecker/full-pre-commit.yml @@ -0,0 +1,11 @@ +pipeline: + # Kludge for non-root containers under WoodPecker + fix-ownership: + image: alpine:latest + commands: chown -R 1234:1234 . + + full-pre-commit: + image: git.frostfs.info/truecloudlab/frostfs-ci:v0.36 + commands: + - export HOME="$(getent passwd $(id -u) | cut '-d:' -f6)" + - pre-commit run -a diff --git a/.woodpecker/pre-commit.yml b/.woodpecker/pre-commit.yml new file mode 100644 index 000000000..debe0cba9 --- /dev/null +++ b/.woodpecker/pre-commit.yml @@ -0,0 +1,17 @@ +pipeline: + # Kludge for non-root containers under WoodPecker + fix-ownership: + image: alpine:latest + commands: chown -R 1234:1234 . + + pre-commit: + image: git.frostfs.info/truecloudlab/frostfs-ci:v0.36 + commands: + - export HOME="$(getent passwd $(id -u) | cut '-d:' -f6)" + - pre-commit run + + unit: + image: git.frostfs.info/truecloudlab/frostfs-ci:v0.36 + commands: + - export HOME="$(getent passwd $(id -u) | cut '-d:' -f6)" + - make test