Implement CI pipelines
This commit is contained in:
parent
4f0f306f8f
commit
6e2e38e6c8
7 changed files with 397 additions and 0 deletions
10
.ci/Dockerfile
Normal file
10
.ci/Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
|||
FROM rust-xwin
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install --no-install-recommends -y \
|
||||
git \
|
||||
; \
|
||||
sh -c "git config --global --add safe.directory '*'"; \
|
||||
apt-get remove -y --auto-remove; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
143
.ci/pipelines/pr.yml
Normal file
143
.ci/pipelines/pr.yml
Normal file
|
@ -0,0 +1,143 @@
|
|||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/Config
|
||||
---
|
||||
resource_types:
|
||||
- name: gitea-package
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-package
|
||||
|
||||
- name: gitea-status
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-status
|
||||
|
||||
resources:
|
||||
- name: repo
|
||||
type: git
|
||||
source:
|
||||
uri: ((forgejo_url))/((owner))/((repo))
|
||||
branch: ((pr.head.ref))
|
||||
|
||||
- name: gitea-package
|
||||
type: gitea-package
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
url: ((forgejo_url))
|
||||
owner: ((owner))
|
||||
type: generic
|
||||
name: ((repo))
|
||||
|
||||
- name: pr-status-lint-clippy
|
||||
type: gitea-status
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
url: ((forgejo_url))
|
||||
owner: ((owner))
|
||||
repo: ((repo))
|
||||
context: lint/clippy
|
||||
description: Check for common mistakes and opportunities for code improvement
|
||||
|
||||
- name: pr-status-build
|
||||
type: gitea-status
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
url: ((forgejo_url))
|
||||
owner: ((owner))
|
||||
repo: ((repo))
|
||||
context: build
|
||||
description: "Build for the target platform"
|
||||
|
||||
|
||||
jobs:
|
||||
- name: clippy
|
||||
on_success:
|
||||
put: state-success
|
||||
resource: pr-status-lint-clippy
|
||||
no_get: true
|
||||
params:
|
||||
state: success
|
||||
sha: ((.:git_sha))
|
||||
|
||||
on_failure:
|
||||
put: state-failure
|
||||
resource: pr-status-lint-clippy
|
||||
no_get: true
|
||||
params:
|
||||
state: failure
|
||||
sha: ((.:git_sha))
|
||||
|
||||
plan:
|
||||
- get: repo
|
||||
trigger: true
|
||||
|
||||
- load_var: git_sha
|
||||
file: repo/.git/ref
|
||||
|
||||
- put: state-pending
|
||||
resource: pr-status-lint-clippy
|
||||
no_get: true
|
||||
params:
|
||||
state: pending
|
||||
sha: ((.:git_sha))
|
||||
|
||||
- task: check
|
||||
file: repo/.ci/tasks/clippy.yml
|
||||
vars:
|
||||
forgejo_api_key: ((forgejo_api_key))
|
||||
|
||||
|
||||
- name: build
|
||||
on_success:
|
||||
put: state-success
|
||||
resource: pr-status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: success
|
||||
sha: ((.:git_sha))
|
||||
|
||||
on_failure:
|
||||
put: state-failure
|
||||
resource: pr-status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: failure
|
||||
sha: ((.:git_sha))
|
||||
|
||||
plan:
|
||||
- get: repo
|
||||
trigger: true
|
||||
|
||||
- load_var: git_sha
|
||||
file: repo/.git/ref
|
||||
|
||||
- put: state-pending
|
||||
resource: pr-status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: pending
|
||||
sha: ((.:git_sha))
|
||||
|
||||
- task: build
|
||||
file: repo/.ci/tasks/build.yml
|
||||
vars:
|
||||
target: msvc
|
||||
pr: ((pr))
|
||||
forgejo_url: ((forgejo_url))
|
||||
forgejo_api_key: ((forgejo_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/*.dll
|
||||
- artifact/*.sha256
|
132
.ci/pipelines/set-pr-pipelines.yml
Normal file
132
.ci/pipelines/set-pr-pipelines.yml
Normal file
|
@ -0,0 +1,132 @@
|
|||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/Config
|
||||
---
|
||||
|
||||
resource_types:
|
||||
- name: gitea-package
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-package
|
||||
|
||||
- name: gitea-status
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-status
|
||||
|
||||
- name: gitea-pr
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-pr
|
||||
|
||||
|
||||
resources:
|
||||
- name: repo
|
||||
type: git
|
||||
source:
|
||||
uri: ((forgejo_url))/((owner))/((repo))
|
||||
branch: master
|
||||
|
||||
- name: repo-pr
|
||||
type: gitea-pr
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
owner: ((owner))
|
||||
repo: ((repo))
|
||||
url: ((forgejo_url))
|
||||
|
||||
- name: gitea-package
|
||||
type: gitea-package
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
url: ((fprgejo_url))
|
||||
owner: ((owner))
|
||||
type: generic
|
||||
name: ((repo))
|
||||
|
||||
|
||||
- name: status-build
|
||||
type: gitea-status
|
||||
source:
|
||||
access_token: ((forgejo_api_key))
|
||||
url: ((forgejo_url))
|
||||
owner: ((owner))
|
||||
repo: ((repo))
|
||||
context: build
|
||||
description: "Build for the target platform"
|
||||
|
||||
jobs:
|
||||
- name: set-pipelines
|
||||
plan:
|
||||
- in_parallel:
|
||||
- get: repo-pr
|
||||
trigger: true
|
||||
- get: repo
|
||||
|
||||
- load_var: prs
|
||||
file: repo-pr/prs.json
|
||||
|
||||
- across:
|
||||
- var: pr
|
||||
values: ((.:prs))
|
||||
set_pipeline: ((repo))-pr
|
||||
file: repo/.ci/pipelines/pr.yml
|
||||
vars:
|
||||
pr: ((.:pr))
|
||||
forgejo_api_key: ((forgejo_api_key))
|
||||
forgejo_url: ((forgejo_url))
|
||||
instance_vars:
|
||||
number: ((.:pr.number))
|
||||
|
||||
- name: build
|
||||
on_success:
|
||||
put: state-success
|
||||
resource: status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: success
|
||||
sha: ((.:git_sha))
|
||||
|
||||
on_failure:
|
||||
put: state-failure
|
||||
resource: status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: failure
|
||||
sha: ((.:git_sha))
|
||||
|
||||
plan:
|
||||
- get: repo
|
||||
trigger: true
|
||||
|
||||
- load_var: git_sha
|
||||
file: repo/.git/ref
|
||||
|
||||
- put: state-pending
|
||||
resource: status-build
|
||||
no_get: true
|
||||
params:
|
||||
state: pending
|
||||
sha: ((.:git_sha))
|
||||
|
||||
- task: build
|
||||
file: repo/.ci/tasks/build.yml
|
||||
vars:
|
||||
pr: ""
|
||||
forgejo_url: ((forgejo_url))
|
||||
forgejo_api_key: ((forgejo_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/*.dll
|
||||
- artifact/*.sha256
|
41
.ci/tasks/build.sh
Executable file
41
.ci/tasks/build.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
OUTPUT=$(realpath "$PWD/../$OUTPUT")
|
||||
else
|
||||
OUTPUT=$(mktemp -d)
|
||||
fi
|
||||
|
||||
title() {
|
||||
printf "\033[1m%s\033[0m\n" "$1"
|
||||
}
|
||||
|
||||
install_artifact() {
|
||||
for f in "$@"; do
|
||||
echo "Installing: $f"
|
||||
install -v -t "$OUTPUT/" "$f"
|
||||
sha256sum "$f" > "$OUTPUT/$(basename "$f").sha256"
|
||||
done
|
||||
}
|
||||
|
||||
PR=${PR:-}
|
||||
|
||||
if [ -n "$PR" ]; then
|
||||
title "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')"
|
||||
ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short "$(cat .git/ref || echo "HEAD")" 2>/dev/null || echo 'manual')"
|
||||
else
|
||||
ref=$(git describe --tags --always)
|
||||
fi
|
||||
|
||||
title "Version: '$ref'"
|
||||
echo "$ref" > "$OUTPUT/version"
|
||||
|
||||
title "Building project"
|
||||
cargo build --color always --locked --release --target x86_64-pc-windows-msvc -Zbuild-std
|
||||
|
||||
title "Installing artifacts"
|
||||
install_artifact target/x86_64-pc-windows-msvc/release/*.dll
|
||||
|
||||
title "Done"
|
30
.ci/tasks/build.yml
Normal file
30
.ci/tasks/build.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/TaskConfig
|
||||
---
|
||||
platform: linux
|
||||
|
||||
image_resource:
|
||||
name: rust-xwin
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/rust-xwin-ci
|
||||
tag: latest
|
||||
|
||||
inputs:
|
||||
- name: repo
|
||||
|
||||
outputs:
|
||||
- name: artifact
|
||||
|
||||
caches:
|
||||
- path: repo/target
|
||||
- path: /usr/local/cargo/registry
|
||||
|
||||
params:
|
||||
CI: "true"
|
||||
FORGEJO_API_KEY: ((forgejo_api_key))
|
||||
PR: ((pr))
|
||||
OUTPUT: artifact
|
||||
|
||||
run:
|
||||
path: .ci/tasks/build.sh
|
||||
dir: repo
|
16
.ci/tasks/clippy.sh
Executable file
16
.ci/tasks/clippy.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
title() {
|
||||
printf "\033[1m%s\033[0m\n" "$1"
|
||||
}
|
||||
|
||||
title "Install clippy"
|
||||
rustup component add clippy
|
||||
|
||||
title "Run clippy"
|
||||
cargo clippy --color always --no-deps --locked
|
||||
|
||||
title "Done"
|
||||
|
25
.ci/tasks/clippy.yml
Normal file
25
.ci/tasks/clippy.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/TaskConfig
|
||||
---
|
||||
platform: linux
|
||||
|
||||
image_resource:
|
||||
name: rust-xwin-ci
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/rust-xwin-ci
|
||||
tag: latest
|
||||
|
||||
inputs:
|
||||
- name: repo
|
||||
|
||||
caches:
|
||||
- path: repo/target
|
||||
- path: /usr/local/cargo/registry
|
||||
|
||||
params:
|
||||
CI: "true"
|
||||
FORGEJO_API_KEY: ((forgejo_api_key))
|
||||
|
||||
run:
|
||||
path: .ci/tasks/clippy.sh
|
||||
dir: repo
|
Loading…
Add table
Reference in a new issue