diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index b35a63c8..f772c292 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -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 -} \ No newline at end of file +} diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index c9e38444..194fd9d9 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -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() } } -} \ No newline at end of file +} diff --git a/ci/Jenkinsfile.docker b/ci/Jenkinsfile.docker index 689733e3..94edf4b4 100644 --- a/ci/Jenkinsfile.docker +++ b/ci/Jenkinsfile.docker @@ -1,6 +1,6 @@ pipeline { agent { - label 'linux && go-1.19' + label 'linux && x86_64' } parameters { diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index a1dd0c6e..46962a70 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -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() } } -} \ No newline at end of file +} diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index a9c497d6..001ee7bc 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -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() } } -} \ No newline at end of file +} diff --git a/ci/Jenkinsfile.nix-flake b/ci/Jenkinsfile.nix-flake index c36c09c0..bbfa9fe6 100644 --- a/ci/Jenkinsfile.nix-flake +++ b/ci/Jenkinsfile.nix-flake @@ -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) } } diff --git a/ci/Jenkinsfile.tests b/ci/Jenkinsfile.tests index 5c20eaca..a43df425 100644 --- a/ci/Jenkinsfile.tests +++ b/ci/Jenkinsfile.tests @@ -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() } } } diff --git a/flake.nix b/flake.nix index a7350337..e737fbdb 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; + }; + }); }; }