feat(ci): Implement pipeline for PRs
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux
This includes using Gitea's Commit Status API to add checks to the PR UI.
This commit is contained in:
parent
5302eb6200
commit
feff4b83be
10 changed files with 170 additions and 40 deletions
|
@ -4,6 +4,9 @@ RUN set -eux; \
|
|||
apt-get update; \
|
||||
apt-get install --no-install-recommends -y \
|
||||
build-essential \
|
||||
curl \
|
||||
gpg \
|
||||
jq \
|
||||
libatk1.0-dev \
|
||||
libclang-13-dev \
|
||||
libglib2.0-dev \
|
||||
|
@ -18,5 +21,4 @@ RUN set -eux; \
|
|||
|
||||
WORKDIR /src/dtmt
|
||||
|
||||
COPY *.so /src
|
||||
|
||||
COPY liboo2corelinux64.so /src
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# https://jake-shadle.github.io/xwin/
|
||||
FROM rust:slim-bullseye
|
||||
FROM dtmt-ci-base-linux
|
||||
|
||||
ENV KEYRINGS /usr/local/share/keyrings
|
||||
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; \
|
||||
mkdir -p $KEYRINGS; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gpg \
|
||||
curl; \
|
||||
# clang/lld/llvm
|
||||
gpg --dearmor > $KEYRINGS/llvm.gpg < /root/llvm-snapshot.gpg.key; \
|
||||
# wine
|
||||
|
@ -24,17 +20,8 @@ RUN set -eux; \
|
|||
dpkg --add-architecture i386; \
|
||||
apt-get update; \
|
||||
apt-get install --no-install-recommends -y \
|
||||
build-essential \
|
||||
libatk1.0-dev \
|
||||
libclang-13-dev \
|
||||
libglib2.0-dev \
|
||||
libgtk-3-dev \
|
||||
libpango1.0-dev \
|
||||
libssl-dev \
|
||||
libzstd-dev \
|
||||
pkg-config \
|
||||
gcc-mingw-w64-x86-64 \
|
||||
# g++-mingw-w64-x86-64 \
|
||||
clang-13 \
|
||||
llvm-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/c++ c++ /usr/bin/clang++ 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 component add rust-src; \
|
||||
# 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
|
||||
|
||||
COPY *.lib /src
|
||||
COPY oo2core_win32.lib oo2core_win64.lib /src
|
||||
|
|
|
@ -4,34 +4,45 @@
|
|||
# creates a new pipeline instance for each of them.
|
||||
|
||||
resource_types:
|
||||
- name: git-branches
|
||||
- name: gitea-pr
|
||||
type: registry-image
|
||||
source:
|
||||
repository: aoldershaw/git-branches-resource
|
||||
repository: registry.local:5000/gitea-pr
|
||||
|
||||
resources:
|
||||
- name: repo-branches
|
||||
type: git-branches
|
||||
- name: repo-pr
|
||||
type: gitea-pr
|
||||
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
|
||||
type: git
|
||||
source:
|
||||
uri: https://git.sclu1034.dev/bitsquid_dt/dtmt
|
||||
# DEBUG:
|
||||
branch: feat/ci
|
||||
|
||||
|
||||
jobs:
|
||||
- name: set-pipelines
|
||||
plan:
|
||||
- in_parallel:
|
||||
- get: repo-branches
|
||||
- get: repo-pr
|
||||
trigger: true
|
||||
- get: repo
|
||||
- load_var: branches
|
||||
file: repo-branches/branches.json
|
||||
- load_var: prs
|
||||
file: repo-pr/prs.json
|
||||
- across:
|
||||
- var: branch
|
||||
values: ((.:branches))
|
||||
set_pipeline: dtmt-check
|
||||
file: repo/.ci/pipelines/check.yml
|
||||
- var: pr
|
||||
values: ((.:prs))
|
||||
set_pipeline: dtmt-pr
|
||||
file: repo/.ci/pipelines/pr.yml
|
||||
vars:
|
||||
pr: ((.:pr))
|
||||
gitea_api_key: ((gitea_api_key))
|
||||
instance_vars:
|
||||
branch: ((.:branch.name))
|
||||
pr: ((.:pr.number))
|
||||
|
||||
|
||||
|
|
49
.ci/pipelines/pr.yml
Normal file
49
.ci/pipelines/pr.yml
Normal 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))
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
set -eux
|
||||
|
||||
OUTPUT="$1"
|
||||
|
||||
case "$TARGET" in
|
||||
msvc)
|
||||
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/dtmm.exe
|
||||
fi
|
||||
|
||||
;;
|
||||
linux)
|
||||
cp /src/*.so ./lib/oodle/
|
||||
|
@ -23,10 +20,8 @@ case "$TARGET" in
|
|||
install -t "$OUTPUT/" target/release/dtmt
|
||||
install -t "$OUTPUT/" target/release/dtmm
|
||||
fi
|
||||
|
||||
;;
|
||||
*)
|
||||
set +x
|
||||
echo "Env var 'TARGET' must either be 'msvc' or 'linux'. Got '$TARGET'." >&2
|
||||
exit 1
|
||||
esac
|
||||
|
|
|
@ -16,9 +16,14 @@ outputs:
|
|||
params:
|
||||
CI: true
|
||||
TARGET: ((target))
|
||||
GITEA_API_KEY: ((gitea_api_key))
|
||||
REF: ((ref))
|
||||
OUTPUT: artifact
|
||||
|
||||
run:
|
||||
path: .ci/tasks/build.sh
|
||||
path: .ci/util/run.sh
|
||||
dir: repo
|
||||
args:
|
||||
- /artifact
|
||||
- .ci/tasks/build.sh
|
||||
- build/((target))
|
||||
- "Build for the target platform: ((target))"
|
||||
|
|
7
.ci/tasks/clippy.sh
Executable file
7
.ci/tasks/clippy.sh
Executable 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
25
.ci/tasks/clippy.yml
Normal 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
50
.ci/util/run.sh
Executable 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
|
4
Justfile
4
Justfile
|
@ -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 tag dtmt-ci-base-msvc registry.sclu1034.dev/dtmt-ci-base-msvc
|
||||
docker push registry.sclu1034.dev/dtmt-ci-base-msvc
|
||||
|
|
Loading…
Add table
Reference in a new issue