CI improvements #141
7 changed files with 113 additions and 80 deletions
|
@ -40,4 +40,4 @@ jobs:
|
||||||
pr: ((.:pr))
|
pr: ((.:pr))
|
||||||
gitea_api_key: ((gitea_api_key))
|
gitea_api_key: ((gitea_api_key))
|
||||||
instance_vars:
|
instance_vars:
|
||||||
pr: ((.:pr.number))
|
n: ((.:pr.number))
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
# The actual CI pipeline that is run per branch
|
# The actual CI pipeline that is run per branch
|
||||||
|
resource_types:
|
||||||
|
- name: gitea-package
|
||||||
|
type: registry-image
|
||||||
|
source:
|
||||||
|
repository: registry.local:5000/gitea-package
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- name: repo
|
- name: repo
|
||||||
|
@ -9,6 +14,14 @@ resources:
|
||||||
source:
|
source:
|
||||||
uri: http://forgejo:3000/bitsquid_dt/dtmt
|
uri: http://forgejo:3000/bitsquid_dt/dtmt
|
||||||
branch: ((pr.head.ref))
|
branch: ((pr.head.ref))
|
||||||
|
- name: gitea-package
|
||||||
|
type: gitea-package
|
||||||
|
source:
|
||||||
|
access_token: ((gitea_api_key))
|
||||||
|
url: http://forgejo:3000
|
||||||
|
owner: concourse
|
||||||
|
type: generic
|
||||||
|
name: dtmt
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- name: clippy
|
- name: clippy
|
||||||
|
@ -16,6 +29,7 @@ jobs:
|
||||||
- get: repo
|
- get: repo
|
||||||
trigger: true
|
trigger: true
|
||||||
- load_var: ref
|
- load_var: ref
|
||||||
|
format: trim
|
||||||
file: repo/.git/ref
|
file: repo/.git/ref
|
||||||
- task: check
|
- task: check
|
||||||
file: repo/.ci/tasks/clippy.yml
|
file: repo/.ci/tasks/clippy.yml
|
||||||
|
@ -28,35 +42,61 @@ jobs:
|
||||||
- get: repo
|
- get: repo
|
||||||
trigger: true
|
trigger: true
|
||||||
- load_var: ref
|
- load_var: ref
|
||||||
|
format: trim
|
||||||
file: repo/.git/ref
|
file: repo/.git/ref
|
||||||
- task: build
|
- task: build
|
||||||
file: repo/.ci/tasks/build.yml
|
file: repo/.ci/tasks/build.yml
|
||||||
vars:
|
vars:
|
||||||
target: msvc
|
target: msvc
|
||||||
output: artifact
|
|
||||||
ref: ((.:ref))
|
ref: ((.:ref))
|
||||||
|
pr: ((pr))
|
||||||
gitea_url: http://forgejo:3000
|
gitea_url: http://forgejo:3000
|
||||||
gitea_api_key: ((gitea_api_key))
|
gitea_api_key: ((gitea_api_key))
|
||||||
|
- load_var: version_number
|
||||||
|
reveal: true
|
||||||
|
file: artifact/version
|
||||||
|
- put: package
|
||||||
|
resource: gitea-package
|
||||||
|
no_get: true
|
||||||
|
inputs:
|
||||||
|
- artifact
|
||||||
|
params:
|
||||||
|
version: ((.:version_number))
|
||||||
|
fail_fast: true
|
||||||
|
override: true
|
||||||
|
globs:
|
||||||
|
- artifact/dtmt
|
||||||
|
- artifact/dtmm
|
||||||
|
- artifact/*.exe
|
||||||
|
|
||||||
- name: build-linux
|
- name: build-linux
|
||||||
plan:
|
plan:
|
||||||
- get: repo
|
- get: repo
|
||||||
trigger: true
|
trigger: true
|
||||||
- load_var: ref
|
- load_var: ref
|
||||||
|
reveal: true
|
||||||
file: repo/.git/ref
|
file: repo/.git/ref
|
||||||
- task: build
|
- task: build
|
||||||
file: repo/.ci/tasks/build.yml
|
file: repo/.ci/tasks/build.yml
|
||||||
vars:
|
vars:
|
||||||
target: linux
|
target: linux
|
||||||
output: artifact
|
|
||||||
ref: ((.:ref))
|
ref: ((.:ref))
|
||||||
|
pr: ((pr))
|
||||||
gitea_url: http://forgejo:3000
|
gitea_url: http://forgejo:3000
|
||||||
gitea_api_key: ((gitea_api_key))
|
gitea_api_key: ((gitea_api_key))
|
||||||
- task: upload
|
- load_var: version_number
|
||||||
file: repo/.ci/tasks/upload.yml
|
reveal: true
|
||||||
vars:
|
file: artifact/version
|
||||||
input: artifact
|
- put: package
|
||||||
pr: ((.:pr))
|
resource: gitea-package
|
||||||
gitea_api_key: ((gitea_api_key))
|
no_get: true
|
||||||
gitea_user: bitsquid_dt
|
inputs:
|
||||||
gitea_url: http://forgejo:3000
|
- artifact
|
||||||
|
params:
|
||||||
|
version: ((.:version_number))
|
||||||
|
fail_fast: true
|
||||||
|
override: true
|
||||||
|
globs:
|
||||||
|
- artifact/dtmt
|
||||||
|
- artifact/dtmm
|
||||||
|
- artifact/*.exe
|
||||||
|
|
|
@ -1,25 +1,48 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -eux
|
set -eu
|
||||||
|
|
||||||
|
if [ -n "$OUTPUT" ]; then
|
||||||
|
OUTPUT="$PWD/$OUTPUT"
|
||||||
|
else
|
||||||
|
OUTPUT=$(mktemp -d)
|
||||||
|
fi
|
||||||
|
|
||||||
|
title() {
|
||||||
|
printf "\033[1m%s\033[0m\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "${PR:-}" ]; then
|
||||||
|
title "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')"
|
||||||
|
ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short HEAD 2>/dev/null || echo 'manual')"
|
||||||
|
else
|
||||||
|
ref=$(git describe --tags)
|
||||||
|
fi
|
||||||
|
|
||||||
|
title "Version is '$ref'"
|
||||||
|
echo "$ref" > "$OUTPUT/version"
|
||||||
|
|
||||||
|
cd "repo"
|
||||||
case "$TARGET" in
|
case "$TARGET" in
|
||||||
msvc)
|
msvc)
|
||||||
cp /src/*.lib ./lib/oodle/
|
cp /src/*.lib ./lib/oodle/
|
||||||
|
|
||||||
|
title "Build project for target $TARGET"
|
||||||
cargo build --color always --locked --release --target x86_64-pc-windows-msvc -Zbuild-std
|
cargo build --color always --locked --release --target x86_64-pc-windows-msvc -Zbuild-std
|
||||||
|
|
||||||
if [ -d "$OUTPUT" ]; then
|
title "Install artifacts"
|
||||||
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
|
|
||||||
;;
|
;;
|
||||||
linux)
|
linux)
|
||||||
cp /src/*.a ./lib/oodle/
|
cp /src/*.a ./lib/oodle/
|
||||||
|
|
||||||
|
title "Build project for target $TARGET"
|
||||||
cargo build --color always --locked --profile release-lto
|
cargo build --color always --locked --profile release-lto
|
||||||
|
|
||||||
if [ -d "$OUTPUT" ]; then
|
title "Install artifacts"
|
||||||
install -t "$OUTPUT/" target/release/dtmt
|
install -t "$OUTPUT/" target/release-lto/dtmt
|
||||||
install -t "$OUTPUT/" target/release/dtmm
|
install -t "$OUTPUT/" target/release-lto/dtmm
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
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
|
||||||
|
|
|
@ -13,7 +13,7 @@ inputs:
|
||||||
- name: repo
|
- name: repo
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
- name: artifacts
|
- name: artifact
|
||||||
|
|
||||||
caches:
|
caches:
|
||||||
- path: repo/target
|
- path: repo/target
|
||||||
|
@ -24,12 +24,12 @@ params:
|
||||||
TARGET: ((target))
|
TARGET: ((target))
|
||||||
GITEA_API_KEY: ((gitea_api_key))
|
GITEA_API_KEY: ((gitea_api_key))
|
||||||
REF: ((ref))
|
REF: ((ref))
|
||||||
OUTPUT: artifacts
|
PR: ((pr))
|
||||||
|
OUTPUT: artifact
|
||||||
|
|
||||||
run:
|
run:
|
||||||
path: .ci/util/run.sh
|
path: repo/.ci/util/run.sh
|
||||||
dir: repo
|
|
||||||
args:
|
args:
|
||||||
- .ci/tasks/build.sh
|
- repo/.ci/tasks/build.sh
|
||||||
- build/((target))
|
- build/((target))
|
||||||
- "Build for the target platform: ((target))"
|
- "Build for the target platform: ((target))"
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
artifacts="$PWD/artifacts"
|
|
||||||
repo="$PWD/repo"
|
|
||||||
|
|
||||||
base_url="${GITEA_URL}/api/packages/${GITEA_USER}/generic"
|
|
||||||
|
|
||||||
cd "$repo"
|
|
||||||
|
|
||||||
if [ -n "$PR" ]; then
|
|
||||||
echo "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')"
|
|
||||||
ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short HEAD 2>/dev/null || echo 'manual')"
|
|
||||||
else
|
|
||||||
ref=$(git describe --tags)
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "ref: $ref"
|
|
||||||
|
|
||||||
# TODO: If this is a tag, check the tag name to determine which
|
|
||||||
# binary was affected and only upload that.
|
|
||||||
for f in dtmt dtmt.exe dtmm dtmm.exe; do
|
|
||||||
if [ -f "$artifacts/$f" ]; then
|
|
||||||
url="$base_url/$(basename -s .exe $f)/$ref/$f"
|
|
||||||
curl -i -X 'PUT' \
|
|
||||||
--user "concourse:$GITEA_API_KEY" \
|
|
||||||
--upload-file "$artifacts/$f" \
|
|
||||||
"$url"
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -1,24 +0,0 @@
|
||||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/TaskConfig
|
|
||||||
---
|
|
||||||
platform: linux
|
|
||||||
|
|
||||||
image_resource:
|
|
||||||
name: python-script
|
|
||||||
type: registry-image
|
|
||||||
source:
|
|
||||||
repository: registry.local:5000/python-script
|
|
||||||
tag: latest
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
- name: repo
|
|
||||||
- name: ((input))
|
|
||||||
|
|
||||||
params:
|
|
||||||
CI: "true"
|
|
||||||
GITEA_API_KEY: ((gitea_api_key))
|
|
||||||
GITEA_URL: ((gitea_url))
|
|
||||||
GITEA_USER: ((user))
|
|
||||||
PR: ((pr))
|
|
||||||
|
|
||||||
run:
|
|
||||||
path: repo/.ci/tasks/upload.sh
|
|
25
Justfile
25
Justfile
|
@ -1,3 +1,5 @@
|
||||||
|
fly_target := "main"
|
||||||
|
|
||||||
ci-build: ci-build-msvc ci-build-linux
|
ci-build: ci-build-msvc ci-build-linux
|
||||||
|
|
||||||
ci-build-msvc:
|
ci-build-msvc:
|
||||||
|
@ -25,3 +27,26 @@ ci-image-linux:
|
||||||
docker build -t dtmt-ci-base-linux -f .ci/image/Dockerfile.linux .ci/image
|
docker build -t dtmt-ci-base-linux -f .ci/image/Dockerfile.linux .ci/image
|
||||||
docker tag dtmt-ci-base-linux registry.sclu1034.dev/dtmt-ci-base-linux
|
docker tag dtmt-ci-base-linux registry.sclu1034.dev/dtmt-ci-base-linux
|
||||||
docker push registry.sclu1034.dev/dtmt-ci-base-linux
|
docker push registry.sclu1034.dev/dtmt-ci-base-linux
|
||||||
|
|
||||||
|
set-base-pipeline:
|
||||||
|
fly -t ((fly_target)) set-pipeline \
|
||||||
|
--pipeline dtmt-prs \
|
||||||
|
--config .ci/pipelines/base-pipeline.yml \
|
||||||
|
-v gitea_api_key=${GITEA_API_KEY} \
|
||||||
|
-v owner=bitsquid_dt \
|
||||||
|
-v repo=dtmt
|
||||||
|
|
||||||
|
set-pr-pipeline pr:
|
||||||
|
curl \
|
||||||
|
-H "Authorization: ${GITEA_API_KEY}" \
|
||||||
|
-H 'Accept: application/json' \
|
||||||
|
'https://git.sclu1034.dev/api/v1/repos/bitsquid_dt/dtmt/pulls/{{pr}}' \
|
||||||
|
| yq -y '.' - > 'pr-{{pr}}.yaml'
|
||||||
|
fly -t main set-pipeline \
|
||||||
|
--pipeline dtmt-pr \
|
||||||
|
--config .ci/pipelines/pr.yml \
|
||||||
|
-v gitea_api_key=${GITEA_API_KEY} \
|
||||||
|
-i n={{pr}} \
|
||||||
|
-y branch="$(yq -y '.head.ref' 'pr-{{pr}}.yaml')" \
|
||||||
|
-y pr="$(cat 'pr-{{pr}}.yaml')"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue