Improve and extend CI pipelines #96

Merged
lucas merged 3 commits from feat/ci into master 2023-04-05 16:27:53 +02:00
10 changed files with 170 additions and 40 deletions
Showing only changes of commit feff4b83be - Show all commits

View file

@ -4,6 +4,9 @@ RUN set -eux; \
apt-get update; \ apt-get update; \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
build-essential \ build-essential \
curl \
gpg \
jq \
libatk1.0-dev \ libatk1.0-dev \
libclang-13-dev \ libclang-13-dev \
libglib2.0-dev \ libglib2.0-dev \
@ -18,5 +21,4 @@ RUN set -eux; \
WORKDIR /src/dtmt WORKDIR /src/dtmt
COPY *.so /src COPY liboo2corelinux64.so /src

View file

@ -1,5 +1,5 @@
# https://jake-shadle.github.io/xwin/ # https://jake-shadle.github.io/xwin/
FROM rust:slim-bullseye FROM dtmt-ci-base-linux
ENV KEYRINGS /usr/local/share/keyrings ENV KEYRINGS /usr/local/share/keyrings
ARG XWIN_VERSION=0.2.11 ARG XWIN_VERSION=0.2.11
@ -11,10 +11,6 @@ ADD https://github.com/Jake-Shadle/xwin/releases/download/$XWIN_VERSION/$XWIN_PR
RUN set -eux; \ RUN set -eux; \
mkdir -p $KEYRINGS; \ mkdir -p $KEYRINGS; \
apt-get update; \
apt-get install -y --no-install-recommends \
gpg \
curl; \
# clang/lld/llvm # clang/lld/llvm
gpg --dearmor > $KEYRINGS/llvm.gpg < /root/llvm-snapshot.gpg.key; \ gpg --dearmor > $KEYRINGS/llvm.gpg < /root/llvm-snapshot.gpg.key; \
# wine # wine
@ -24,17 +20,8 @@ RUN set -eux; \
dpkg --add-architecture i386; \ dpkg --add-architecture i386; \
apt-get update; \ apt-get update; \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
build-essential \
libatk1.0-dev \
libclang-13-dev \ libclang-13-dev \
libglib2.0-dev \
libgtk-3-dev \
libpango1.0-dev \
libssl-dev \
libzstd-dev \
pkg-config \
gcc-mingw-w64-x86-64 \ gcc-mingw-w64-x86-64 \
# g++-mingw-w64-x86-64 \
clang-13 \ clang-13 \
llvm-13 \ llvm-13 \
lld-13 \ lld-13 \
@ -55,7 +42,6 @@ RUN set -eux; \
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100; \ update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100; \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100; \ update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100; \
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld 100; \ update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld 100; \
rustup default nightly; \
rustup target add x86_64-pc-windows-msvc; \ rustup target add x86_64-pc-windows-msvc; \
rustup component add rust-src; \ rustup component add rust-src; \
# Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`. # Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`.
@ -100,4 +86,4 @@ RUN wine wineboot --init
WORKDIR /src/dtmt WORKDIR /src/dtmt
COPY *.lib /src COPY oo2core_win32.lib oo2core_win64.lib /src

View file

@ -4,34 +4,45 @@
# creates a new pipeline instance for each of them. # creates a new pipeline instance for each of them.
resource_types: resource_types:
- name: git-branches - name: gitea-pr
type: registry-image type: registry-image
source: source:
repository: aoldershaw/git-branches-resource repository: registry.local:5000/gitea-pr
resources: resources:
- name: repo-branches - name: repo-pr
type: git-branches type: gitea-pr
source: source:
uri: https://git.sclu1034.dev/bitsquid_dt/dtmt access_token: ((gitea_api_key))
owner: ((owner))
repo: ((repo))
url: https://git.sclu1034.dev
- name: repo - name: repo
type: git type: git
source: source:
uri: https://git.sclu1034.dev/bitsquid_dt/dtmt uri: https://git.sclu1034.dev/bitsquid_dt/dtmt
# DEBUG:
branch: feat/ci
jobs: jobs:
- name: set-pipelines - name: set-pipelines
plan: plan:
- in_parallel: - in_parallel:
- get: repo-branches - get: repo-pr
trigger: true trigger: true
- get: repo - get: repo
- load_var: branches - load_var: prs
file: repo-branches/branches.json file: repo-pr/prs.json
- across: - across:
- var: branch - var: pr
values: ((.:branches)) values: ((.:prs))
set_pipeline: dtmt-check set_pipeline: dtmt-pr
file: repo/.ci/pipelines/check.yml file: repo/.ci/pipelines/pr.yml
vars:
pr: ((.:pr))
gitea_api_key: ((gitea_api_key))
instance_vars: instance_vars:
branch: ((.:branch.name)) pr: ((.:pr.number))

49
.ci/pipelines/pr.yml Normal file
View file

@ -0,0 +1,49 @@
---
# The actual CI pipeline that is run per branch
resources:
- name: repo
type: git
source:
uri: https://git.sclu1034.dev/bitsquid_dt/dtmt
branch: ((pr.head.ref))
jobs:
- name: clippy
plan:
- get: repo
trigger: true
- load_var: ref
file: repo/.git/ref
- task: check
file: repo/.ci/tasks/clippy.yml
vars:
ref: ((.:ref))
gitea_api_key: ((gitea_api_key))
- name: build-msvc
plan:
- get: repo
trigger: true
- load_var: ref
file: repo/.git/ref
- task: build
file: repo/.ci/tasks/build.yml
vars:
target: msvc
ref: ((.:ref))
gitea_api_key: ((gitea_api_key))
- name: build-linux
plan:
- get: repo
trigger: true
- load_var: ref
file: repo/.git/ref
- task: build
file: repo/.ci/tasks/build.yml
vars:
target: linux
ref: ((.:ref))
gitea_api_key: ((gitea_api_key))

View file

@ -2,8 +2,6 @@
set -eux set -eux
OUTPUT="$1"
case "$TARGET" in case "$TARGET" in
msvc) msvc)
cp /src/*.lib ./lib/oodle/ cp /src/*.lib ./lib/oodle/
@ -13,7 +11,6 @@ case "$TARGET" in
install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmt.exe install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmt.exe
install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmm.exe install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmm.exe
fi fi
;; ;;
linux) linux)
cp /src/*.so ./lib/oodle/ cp /src/*.so ./lib/oodle/
@ -23,10 +20,8 @@ case "$TARGET" in
install -t "$OUTPUT/" target/release/dtmt install -t "$OUTPUT/" target/release/dtmt
install -t "$OUTPUT/" target/release/dtmm install -t "$OUTPUT/" target/release/dtmm
fi fi
;; ;;
*) *)
set +x
echo "Env var 'TARGET' must either be 'msvc' or 'linux'. Got '$TARGET'." >&2 echo "Env var 'TARGET' must either be 'msvc' or 'linux'. Got '$TARGET'." >&2
exit 1 exit 1
esac esac

View file

@ -16,9 +16,14 @@ outputs:
params: params:
CI: true CI: true
TARGET: ((target)) TARGET: ((target))
GITEA_API_KEY: ((gitea_api_key))
REF: ((ref))
OUTPUT: artifact
run: run:
path: .ci/tasks/build.sh path: .ci/util/run.sh
dir: repo dir: repo
args: args:
- /artifact - .ci/tasks/build.sh
- build/((target))
- "Build for the target platform: ((target))"

7
.ci/tasks/clippy.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
set -eux
rustup component add clippy
cargo clippy --color always --no-deps

25
.ci/tasks/clippy.yml Normal file
View file

@ -0,0 +1,25 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: registry.local:5000/dtmt-ci-base-linux
tag: latest
inputs:
- name: repo
params:
CI: true
GITEA_API_KEY: ((gitea_api_key))
REF: ((ref))
run:
path: .ci/util/run.sh
dir: repo
args:
- .ci/tasks/clippy.sh
- lint/clippy
- "Checking for common mistakes and opportunities for code improvement"

50
.ci/util/run.sh Executable file
View file

@ -0,0 +1,50 @@
#!/bin/sh
set -ux
script="$1"
context="$2"
desc="$3"
if [ -z "$script" ]; then
echo "No script to run" >&2
exit 1
fi
if [ -z "$context" ]; then
echo "Missing 'context' for CI status report" >&2
exit 1
fi
if [ -z "$REF" ]; then
echo "Environment variable 'REF' must be set to a valid Git ref." >&2
exit 1
fi
if [ -z "$GITEA_API_KEY" ]; then
echo "Environment variable 'GITEA_API_KEY' must be set." >&2
exit 1
fi
notify() {
curl -X 'POST' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Authorization: token $GITEA_API_KEY" \
"https://git.sclu1034.dev/api/v1/repos/bitsquid_dt/dtmt/statuses/$REF" \
--data @- <<EOF
{
"context": "$2",
"description": "$3",
"state": "$1"
}
EOF
}
notify 'pending' "$context" "$desc"
if sh "$script"; then
notify 'success' "$context" "$desc"
else
notify 'failure' "$context" "$desc"
fi

View file

@ -1,6 +1,6 @@
ci-image: ci-image-msvc ci-image-linux ci-image: ci-image-linux ci-image-msvc
ci-image-msvc: ci-image-msvc: ci-image-linux
docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image
docker tag dtmt-ci-base-msvc registry.sclu1034.dev/dtmt-ci-base-msvc docker tag dtmt-ci-base-msvc registry.sclu1034.dev/dtmt-ci-base-msvc
docker push registry.sclu1034.dev/dtmt-ci-base-msvc docker push registry.sclu1034.dev/dtmt-ci-base-msvc