Skip to content
Snippets Groups Projects
Commit 1ab25616 authored by Teake Nutma's avatar Teake Nutma
Browse files

Add ci-tools docker image and fix linting job

parent 37f0638b
Branches
No related merge requests found
......@@ -8,16 +8,20 @@ workflow:
- if: $CI_COMMIT_REF_PROTECTED == 'true'
- if: $CI_MERGE_REQUEST_ID
# TODO: replace with https://docs.gitlab.com/ee/api/lint.html
#lint:
# stage: lint
# image: node:lts-alpine
# script:
# - npm install -g gitlab-ci-lint
# - find . \( -name '*.yaml' -o -name '*.yml' \) -print -exec gitlab-ci-lint --url https://gitlab.astro-wise.org "{}" \;
lint:
stage: lint
# Note: the ci-tools image has to be build and pushed manually once to bootstrap this job
# since this job comes before the build_containers job.
image: ${CI_REGISTRY_IMAGE}/ci-tools:master
script:
# Note: we cannot use the GitLab API https://docs.gitlab.com/ee/api/lint.html
# for this since that does not support local includes.
- shopt -s globstar dotglob
- check-jsonschema --builtin-schema vendor.gitlab-ci **/*.yml
build_containers:
stage: build
# Note: the docker-builder image has to be build and pushed manually once to bootstrap this job.
image: ${CI_REGISTRY_IMAGE}/docker-builder:master
script:
# Find the directories that contain a file named 'Dockerfile'
......
FROM python:3
LABEL description="Various tools that come in handy during (GitLab) CI"
# Install via apt
RUN apt-get update && apt-get -y install \
jq \
rsync \
s-nail \
gettext \
&& apt-get clean
# Install via pip
RUN pip install \
check-jsonschema \
black==22.3.0 \
autopep8 \
python-gitlab \
python-compare-ast \
coverage-fixpaths
# Install Gitlab release-cli
RUN curl --location --output /usr/local/bin/release-cli "https://gitlab.com/gitlab-org/release-cli/-/releases/permalink/latest/downloads/bin/release-cli-linux-amd64" \
&& chmod +x /usr/local/bin/release-cli
# Install git-scripts
RUN git clone https://gitlab.astro-wise.org/omegacen/git-scripts.git ~/git-scripts \
&& mv ~/git-scripts/bin/* /usr/local/bin/ \
&& rm -rf ~/git-scripts
# Install ssh-addkey
RUN mkdir -p ~/.ssh
RUN echo "Host *\n\tStrictHostKeyChecking no" > ~/.ssh/config
COPY ssh-addkey.sh /usr/local/bin/ssh-addkey
COPY python-gitlab-set-private-token.sh /usr/local/bin/python-gitlab-set-private-token
COPY entrypoint.sh /usr/local/bin/entrypoint
ENTRYPOINT [ "/bin/bash", "/usr/local/bin/entrypoint" ]
CMD [ "/bin/bash" ]
#!/bin/sh
# Propagate GitLab CI variables to Git.
if [ -n "${GITLAB_USER_EMAIL}" ]; then
git config --global user.email "${GITLAB_USER_EMAIL}"
fi
if [ -n "${GITLAB_USER_NAME}" ]; then
git config --global user.name "${GITLAB_USER_NAME}"
fi
# Set python-gitlab configuration.
if [ -n "${GITLAB_CI}" ]; then
cat << EOF > ~/.python-gitlab.cfg
[global]
default = current-ci-server
[current-ci-server]
url = ${CI_SERVER_URL}
job_token = ${CI_JOB_TOKEN}
api_version = 4
EOF
fi
# Run whatever the user wants to.
exec "$@"
\ No newline at end of file
#!/bin/bash
if [ -z "${GITLAB_CI}" ]; then
echo "Not running during GitLab CI, exiting."
exit 1
fi
cat << EOF > ~/.python-gitlab.cfg
[global]
default = current-ci-server
[current-ci-server]
url = ${CI_SERVER_URL}
private_token = $1
api_version = 4
EOF
\ No newline at end of file
#!/bin/bash
# Find a non-existing filename for the private key
fileprefix="${HOME}/.ssh/id_"
i=0
while [[ -e ${fileprefix}${i} ]] ; do
(( i++ ))
done
file="${fileprefix}${i}"
# Put the key in the file and make it read-only
echo "$1" > "${file}"
chmod 600 "${file}"
# Make SSH aware of the private key
echo -e "\tIdentityFile ${file}" >> ~/.ssh/config
\ No newline at end of file
FROM gcr.io/kaniko-project/executor:debug
LABEL description="Convenience wrapper around kaniko for building images in GitLab CI"
RUN mkdir -p /kaniko/.docker
COPY entrypoint.sh /usr/local/bin/entrypoint
COPY buildimage.sh /usr/local/bin/buildimage
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment