build/ci: add presubmit Jenkinsfile
This implements a basic presubmit Jenkinsfile which should be consumed
(in this CR already) by CI machinery running against review.monogon.dev.
This presubmit exercises the same build targets as the old, internal
Phabricator CI. The build executing agents are based off of the 'monogon
builder' Docker image defined within build/Dockerfile. A follow up CR
will remove the leftover of Phabricator CI machinery and explicitly
document how that agent image is built and used.
We also reformat a generated .bzl file to remove a spurious copyright
header. This appeases Gazelle/Fietsje checks.
Finally, we add a .gitignore which ignores build files to make the
Gazelle/Fietsje dirty checkout detection work correctly. The internal
version of the metropolis repository had an equivalent .gitignore which
wasn't carried over during the initial migration into the Monogon
monorepo.
Change-Id: Ib88b8b50dbc6fcd034757558697e6ae2334235b1
Reviewed-on: https://review.monogon.dev/c/monogon/+/26
Reviewed-by: Leopold Schabel <leo@nexantic.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ac51a05
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+bazel-*
diff --git a/build/ci/jenkins-presubmit.groovy b/build/ci/jenkins-presubmit.groovy
new file mode 100644
index 0000000..e0fb999
--- /dev/null
+++ b/build/ci/jenkins-presubmit.groovy
@@ -0,0 +1,74 @@
+// This is a 'Jenkinsfile'-style declarative 'Pipeline' definition. It is
+// executed by Jenkins for presubmit checks, ie. checks that run against an
+// open Gerrit change request.
+
+pipeline {
+ agent none
+ stages {
+ stage('Parallel') {
+ parallel {
+ stage('Test') {
+ agent {
+ node {
+ label ""
+ customWorkspace '/home/ci/monogon'
+ }
+ }
+ steps {
+ gerritCheck checks: ['jenkins:test': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
+ sh "git clean -fdx -e '/bazel-*'"
+ sh "bazel test //..."
+ sh "bazel test -c dbg //..."
+ }
+ post {
+ success {
+ gerritCheck checks: ['jenkins:test': 'SUCCESSFUL']
+ }
+ unsuccessful {
+ gerritCheck checks: ['jenkins:test': 'FAILED']
+ }
+ }
+ }
+
+ stage('Gazelle') {
+ agent {
+ node {
+ label ""
+ customWorkspace '/home/ci/monogon'
+ }
+ }
+ steps {
+ gerritCheck checks: ['jenkins:gazelle': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
+ sh "git clean -fdx -e '/bazel-*'"
+ sh "bazel run //:fietsje"
+ sh "bazel run //:gazelle -- update"
+
+ script {
+ def diff = sh script: "git status --porcelain", returnStdout: true
+ if (diff.trim() != "") {
+ sh "git diff HEAD"
+ error """
+ Unclean working directory after running gazelle and Fietsje.
+ Please run:
+
+ \$ bazel run //:fietsje
+ \$ bazel run //:gazelle -- update
+
+ In your git checkout and amend the resulting diff to this changelist.
+ """
+ }
+ }
+ }
+ post {
+ success {
+ gerritCheck checks: ['jenkins:gazelle': 'SUCCESSFUL']
+ }
+ unsuccessful {
+ gerritCheck checks: ['jenkins:gazelle': 'FAILED']
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index ca62c5c..f5fd825 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -1,19 +1,3 @@
-# Copyright 2020 The Monogon Project Authors.
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_repositories():