-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add Jenkins configuration and related files
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM rust:1.65.0-slim-bullseye | ||
|
||
LABEL maintainer="[email protected]" | ||
LABEL source="https://github.com/logos-co/Overwatch" | ||
LABEL description="Overwatch ci build image" | ||
|
||
# Using backports for go 1.19 | ||
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list | ||
|
||
# Dependecies for publishing documentation and building waku-bindings. | ||
RUN apt-get update && apt-get install -yq \ | ||
openssh-client git clang \ | ||
golang-src/bullseye-backports \ | ||
golang-doc/bullseye-backports \ | ||
golang/bullseye-backports | ||
|
||
RUN rustup component add rustfmt clippy | ||
|
||
# Jenkins user needs a specific UID/GID to work. | ||
RUN groupadd -g 1001 jenkins \ | ||
&& useradd -u 1001 -g jenkins jenkins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pipeline { | ||
agent { | ||
dockerfile { | ||
label 'linux' | ||
dir 'ci' | ||
} | ||
} | ||
|
||
environment { | ||
GOPATH = '/tmp/go' | ||
GOCACHE = '/tmp/' | ||
} | ||
|
||
options { | ||
disableConcurrentBuilds() | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '20', | ||
daysToKeepStr: '30', | ||
)) | ||
} | ||
|
||
stages { | ||
stage('Check') { | ||
steps { | ||
sh 'cargo check --all --all-features' | ||
sh 'cargo fmt -- --check' | ||
sh 'cargo clippy --all --all-features -- --deny warnings' | ||
} | ||
} | ||
|
||
stage('Build') { | ||
steps { | ||
sh 'cargo build --all --all-features' | ||
} | ||
} | ||
|
||
stage('Test') { | ||
steps { | ||
sh 'cargo test --all --all-features' | ||
} | ||
} | ||
} | ||
post { | ||
cleanup { cleanWs() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
library '[email protected]' | ||
|
||
pipeline { | ||
agent { | ||
label 'macos && x86_64' | ||
} | ||
|
||
environment { | ||
GOPATH = '/tmp/go' | ||
GOCACHE = '/tmp/' | ||
} | ||
|
||
options { | ||
disableConcurrentBuilds() | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '20', | ||
daysToKeepStr: '30', | ||
)) | ||
} | ||
|
||
stages { | ||
stage('Check') { | ||
steps { script { | ||
nix.shell('cargo check --all --all-features') | ||
nix.shell('cargo fmt -- --check') | ||
nix.shell('cargo clippy --all --all-features -- --deny warnings') | ||
} } | ||
} | ||
|
||
stage('Build') { | ||
steps { script { | ||
nix.shell('cargo build --all --all-features') | ||
} } | ||
} | ||
|
||
stage('Test') { | ||
steps { script { | ||
nix.shell('cargo test --all --all-features') | ||
} } | ||
} | ||
} | ||
post { | ||
cleanup { cleanWs() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Building `Overwatch` with Jenkins | ||
|
||
This is a short introduction for developers on how to use `ci` folder to update build dependencies or to modify the build process. | ||
|
||
## ci/Dockerfile (Docs, linux target) | ||
|
||
Dockerfile is used when `Overwatch` documentation is being built and to lint/test/build for linux target. Official rust image is used with a predefined version. In addition, golang and cargo components are downloaded when the image is being built. | ||
In general, this file should be used just for defining dependencies. Related steps and build commands for linux target should be defined in `ci/Jenkinsfile.prs.linux`. | ||
|
||
## ci/Jenkinsfile.prs.linux | ||
|
||
Two most important places in this file are `environment` and `stages`. | ||
* `environment` - variables defined here will be accessible to every stage that runs on an image built from the `ci/Dockerfile` | ||
* `stages` - used to group shell commands that are related to different steps and their layout reflects in the build job summary. | ||
|
||
## ci/Jenkinsfile.prs.macos | ||
|
||
Same as in `Jenkinsfile.prs.macos` the only difference is that instead of Docker image, macos is using `shell.nix` to build a shell with all dependencies. The steps defined here should be identical or similar to what's defined in linux file, just instead of running those commands straight in `sh`, use `nix.shell('command')` wrapper. | ||
|
||
## shell.nix | ||
|
||
Configuration file for the Nix package manager. It defines the build dependencies for `macos` target and can be used to manage and update the dependencies similarly to Dockerfile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ pkgs ? import <nixpkgs> { | ||
builtins = [(import (fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/archive/3389f23412877913b9d22a58dfb241684653d7e9.tar.gz"; | ||
sha256 = "sha256:0wgm7sk9fca38a50hrsqwz6q79z35gqgb9nw80xz7pfdr4jy9pf8"; | ||
}))]; | ||
overlays = [ | ||
(import (fetchGit { | ||
url = "https://github.com/oxalica/rust-overlay.git"; | ||
rev = "fe185fac76e009b4bd543704a8c61077cf70155b"; | ||
})) | ||
]; | ||
} | ||
}: | ||
|
||
pkgs.mkShell { | ||
name = "overwatch-build-shell"; | ||
|
||
buildInputs = with pkgs; [ | ||
pkg-config | ||
rust-bin.stable."1.65.0".default | ||
go_1_19 | ||
]; | ||
} |