ci: use Nix dev shell from flake for CI builds

Provides a more predicable build environment for CI.

Depends on: https://github.com/status-im/status-jenkins-lib/pull/60

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-04-03 17:28:16 +02:00
parent 70ddd48274
commit 14a6f45be4
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
8 changed files with 102 additions and 60 deletions

4
ci/Jenkinsfile vendored
View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.4.3'
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent { label 'linux' }
@ -96,4 +96,4 @@ def Boolean getPublishDefault(Boolean previousValue) {
if (env.JOB_NAME.startsWith('go-waku/release')) { return true }
if (previousValue != null) { return previousValue }
return false
}
}

View File

@ -1,7 +1,7 @@
library 'status-jenkins-lib@v1.3.3'
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent { label 'linux && x86_64 && go-1.19' }
agent { label 'linux && nix-2.11 && x86_64' }
options {
timestamps()
@ -38,24 +38,25 @@ pipeline {
stages {
stage('Prep') { steps { dir(env.REPO) { script {
stage('Prep') { steps { script { dir(env.REPO) {
env.ARTIFACT = "${env.REPO}/pkg/" + utils.pkgFilename(
name: "go-waku",
type: "android",
ext: "tar.gz"
)
sh 'make install-gomobile'
nix.develop('make install-gomobile', pure: false)
} } } }
stage('Build') { steps { dir(env.REPO) {
sh 'make mobile-android || true'
sh 'make mobile-android'
stage('Build') { steps { script { dir(env.REPO) {
/* First gomobile run always fails.
* https://github.com/golang/go/issues/37372 */
nix.develop('make mobile-android || make mobile-android', pure: false)
dir('build/lib') {
sh 'tar -czvf gowaku-android.tar.gz gowaku.aar gowaku-sources.jar'
sh "cp gowaku-android.tar.gz ${env.ARTIFACT}"
}
} } }
} } } }
stage('Parallel Upload') {
parallel {
@ -78,4 +79,4 @@ pipeline {
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
}

View File

@ -1,6 +1,6 @@
pipeline {
agent {
label 'linux && go-1.19'
label 'linux && x86_64'
}
parameters {

View File

@ -1,7 +1,7 @@
library 'status-jenkins-lib@v1.3.3'
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent { label 'macos && x86_64 && go-1.19' }
agent { label 'macos && nix-2.11 && aarch64' }
options {
timestamps()
@ -31,25 +31,30 @@ pipeline {
stages {
stage('Prep') { steps { dir(env.REPO) { script {
stage('Prep') { steps { script { dir(env.REPO) {
env.ARTIFACT = "${env.REPO}/pkg/" + utils.pkgFilename(
name: "go-waku",
type: "ios",
ext: "tar.gz"
)
sh 'make install-gomobile'
println("Output: ${env.ARTIFACT}")
} } } }
stage('Build') { steps { dir(env.REPO) {
sh 'make mobile-ios'
dir('build/lib') {
sh 'tar -czvf gowaku-ios.tar.gz Gowaku.xcframework'
sh "cp gowaku-ios.tar.gz ${env.ARTIFACT}"
}
} } }
stage('Build') {
steps { script { dir(env.REPO) {
nix.develop('which xcodebuild', pure: false)
nix.develop('make mobile-ios', pure: false)
} } }
}
stage('Package') {
steps { dir(env.REPO) {
dir('build/lib') {
sh 'tar -czvf gowaku-ios.tar.gz Gowaku.xcframework'
sh "cp gowaku-ios.tar.gz ${env.ARTIFACT}"
}
} }
}
stage('Parallel Upload') {
parallel {
@ -72,4 +77,4 @@ pipeline {
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
}

View File

@ -1,11 +1,8 @@
library 'status-jenkins-lib@v1.3.3'
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent {
dockerfile {
label 'linux && go-1.19'
dir 'src/github.com/waku-org/go-waku/scripts/linux'
}
label 'linux && nix-2.11 && x86_64'
}
options {
@ -36,23 +33,32 @@ pipeline {
stages {
stage('Prep') { steps { dir(env.REPO) { script {
env.DEB_ARTIFACT = "${env.REPO}/pkg/" + utils.pkgFilename(
name: "go-waku",
type: "x86_64",
ext: "deb"
)
} } } }
stage('Prep') {
steps { script { dir(env.REPO) {
env.DEB_ARTIFACT = "${env.REPO}/pkg/" + utils.pkgFilename(
name: "go-waku",
type: "x86_64",
ext: "deb"
)
} } }
}
stage('Build') { steps { dir(env.REPO) {
sh "make"
dir('./scripts/linux') {
sh "./fpm-build.sh"
}
dir('build') {
sh "cp gowaku*.deb ${env.DEB_ARTIFACT}"
}
} } }
stage('Build') {
steps { script { dir(env.REPO) {
nix.develop('make build')
} } }
}
stage('Package') {
steps { script { dir(env.REPO) {
dir('./scripts/linux') {
nix.develop('./fpm-build.sh', attr: 'fpm')
}
dir('build') {
sh "cp gowaku*.deb ${env.DEB_ARTIFACT}"
}
} } }
}
stage('Parallel Upload') {
parallel {
@ -75,4 +81,4 @@ pipeline {
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
}

View File

@ -1,8 +1,8 @@
library 'status-jenkins-lib@v1.6.8'
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent {
label 'linux'
label 'linux && nix-2.11 && x86_64'
}
options {
@ -61,7 +61,7 @@ pipeline {
}
post {
always { script { /* No artifact but a PKG_URL is necessary. */
env.PKG_URL = "${currentBuild.absoluteUrl}/consoleText"
env.PKG_URL = "${currentBuild.absoluteUrl}consoleText"
} }
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }

View File

@ -1,6 +1,8 @@
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent {
label 'linux && go-1.19'
label 'linux && nix-2.11 && x86_64'
}
options {
@ -13,24 +15,36 @@ pipeline {
}
environment {
TARGET = 'tests'
GOPATH = "${env.HOME}/go"
PATH = "${env.PATH}:${env.GOPATH}/bin"
}
stages {
stage('Deps') {
steps { sh 'make deps' }
steps { script {
nix.develop('make deps', pure: false)
} }
}
stage('Lint') {
steps { sh 'make lint' }
steps { script {
nix.develop('make lint', pure: false)
} }
}
stage('Test') {
steps { sh 'make test-ci' }
steps { script {
nix.develop('make test-ci', pure: false)
} }
}
}
post {
always { cleanWs() }
always { script { /* No artifact but a PKG_URL is necessary. */
env.PKG_URL = "${currentBuild.absoluteUrl}consoleText"
} }
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
cleanup { cleanWs() }
}
}

View File

@ -5,7 +5,10 @@
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
supportedSystems = [
"x86_64-linux" "i686-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
@ -39,8 +42,21 @@
buildPackage system ["cmd/waku"]
);
devShells.default = forAllSystems (system:
packages.${system}.node
);
devShells = forAllSystems (system: let
pkgs = nixpkgsFor.${system};
inherit (pkgs) lib stdenv mkShell;
in {
default = mkShell {
GOFLAGS = "-trimpath"; # Drop -mod=vendor
inputsFrom = [ packages.${system}.node ];
nativeBuildInputs = lib.optional stdenv.isDarwin [
(pkgs.xcodeenv.composeXcodeWrapper { version = "14.2"; })
];
};
fpm = mkShell {
buildInputs = with pkgs; [ fpm ];
};
});
};
}