From 4a3ad750e07d47785177783535ebd261418b6752 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 5 Jul 2023 14:43:25 +0200 Subject: [PATCH] ci: Introduce a CI pipeline for GitLab. --- .gitlab-ci.yml | 7 +++++++ gitlab/build-linux | 19 +++++++++++++++++++ gitlab/build.yml | 29 +++++++++++++++++++++++++++++ gitlab/image.docker | 40 ++++++++++++++++++++++++++++++++++++++++ gitlab/image.yml | 20 ++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100755 gitlab/build-linux create mode 100644 gitlab/build.yml create mode 100644 gitlab/image.docker create mode 100644 gitlab/image.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..8cc59d76 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,7 @@ +stages: + - image + - build + +include: + - local: "/gitlab/image.yml" + - local: "/gitlab/build.yml" diff --git a/gitlab/build-linux b/gitlab/build-linux new file mode 100755 index 00000000..1b7a7a5b --- /dev/null +++ b/gitlab/build-linux @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "Building $(git log -1)" +echo "---" + +COMMIT=$(git rev-parse --short HEAD) + +set -Eeuxo pipefail + +./autogen.sh +rm -fr build +mkdir build +cd build +../configure --enable-demos && make -j$(nproc) && make -j$(nproc) crosstest || touch ../pipeline_failed + +mkdir -p ../artifacts/$COMMIT +rsync -Rr doc/* tests/*.exe ../artifacts/$COMMIT + +git reset --hard diff --git a/gitlab/build.yml b/gitlab/build.yml new file mode 100644 index 00000000..49e69d57 --- /dev/null +++ b/gitlab/build.yml @@ -0,0 +1,29 @@ +.build: + stage: build + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + image: $CI_REGISTRY/wine/vkd3d:debian-bookworm + interruptible: true + needs: + - job: build-image + optional: true + dependencies: [] + script: + - git config --global --add safe.directory $CI_PROJECT_DIR + - git clean -fdx + - git reset --hard + - rm -fr .git/rebase-merge + - mkdir artifacts + - cat /proc/cpuinfo > artifacts/cpuinfo.txt + - cat /proc/meminfo > artifacts/meminfo.txt + - vulkaninfo > artifacts/vulkaninfo.txt + - git rebase $CI_MERGE_REQUEST_DIFF_BASE_SHA --exec ./gitlab/build-linux + - if [ -f pipeline_failed ] ; then exit 1 ; fi + artifacts: + when: always + expire_in: 1 day + paths: + - artifacts + +build: + extends: .build diff --git a/gitlab/image.docker b/gitlab/image.docker new file mode 100644 index 00000000..afc0dd1b --- /dev/null +++ b/gitlab/image.docker @@ -0,0 +1,40 @@ +# FROM line will be added dynamically + +WORKDIR /tmp + +RUN export DEBIAN_FRONTEND=noninteractive; \ + echo 'path-exclude=/usr/share/doc/*' > /etc/dpkg/dpkg.cfg.d/99-exclude-cruft && \ + echo 'path-exclude=/usr/share/locale/*' >> /etc/dpkg/dpkg.cfg.d/99-exclude-cruft && \ + echo 'path-exclude=/usr/share/man/*' >> /etc/dpkg/dpkg.cfg.d/99-exclude-cruft && \ + echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf && \ + echo '#!/bin/sh' > /usr/sbin/policy-rc.d && \ + echo 'exit 101' >> /usr/sbin/policy-rc.d && \ + chmod +x /usr/sbin/policy-rc.d && \ + dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get dist-upgrade -y && \ + apt-get install -y build-essential pkg-config gcc-multilib gcc-mingw-w64 \ + autoconf automake libtool flex bison \ + git ca-certificates rsync \ + doxygen doxygen-latex graphviz \ + mesa-vulkan-drivers mesa-vulkan-drivers:i386 \ + vulkan-tools spirv-headers \ + libvulkan-dev libvulkan-dev:i386 \ + libncurses-dev libncurses-dev:i386 \ + libxcb1-dev libxcb1-dev:i386 \ + libxcb-util-dev libxcb-util-dev:i386 \ + libxcb-icccm4-dev libxcb-icccm4-dev:i386 \ + libxcb-keysyms1-dev libxcb-keysyms1-dev:i386 && \ + git clone --depth 1 --branch wine-3.21 https://gitlab.winehq.org/wine/wine.git && \ + cd wine && \ + mkdir build && \ + cd build && \ + ../configure --without-x --without-freetype && \ + make tools/widl/widl && \ + cp tools/widl/widl /usr/local/bin && \ + cd ../.. && \ + rm -rf wine && \ + apt-get clean && \ + useradd -m gitlab + +USER gitlab diff --git a/gitlab/image.yml b/gitlab/image.yml new file mode 100644 index 00000000..45a87770 --- /dev/null +++ b/gitlab/image.yml @@ -0,0 +1,20 @@ +build-image: + stage: image + rules: + - if: $CI_PIPELINE_SOURCE == 'push' && $CI_PROJECT_PATH == "wine/vkd3d" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + changes: + - .gitlab-ci.yml + - gitlab/image.yml + - gitlab/image.docker + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + variables: + IMAGE_SOURCE: "$CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX/debian:bookworm" + IMAGE_LOCAL: "$CI_REGISTRY_IMAGE:debian-bookworm" + DOCKER_FILE: "$CI_PROJECT_DIR/gitlab/image.docker" + script: + - mkdir -p /kaniko/.docker + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(printf "%s:%s" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" "$CI_DEPENDENCY_PROXY_USER" "$CI_DEPENDENCY_PROXY_PASSWORD" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json + - sed -i "1iFROM $IMAGE_SOURCE" "$DOCKER_FILE" + - /kaniko/executor --context "$CI_PROJECT_DIR" --dockerfile "$DOCKER_FILE" --destination "$IMAGE_LOCAL"