Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual pre-merge pipeline #114

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions tests/x-ghaf-pre-merge.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/usr/bin/env groovy

// SPDX-FileCopyrightText: 2022-2024 TII (SSRC) and the Ghaf contributors
// SPDX-License-Identifier: Apache-2.0

////////////////////////////////////////////////////////////////////////////////

def REPO_URL = 'https://github.com/tiiuae/ghaf/'
def WORKDIR = 'ghaf'
def DEF_GITHUB_PR_NUMBER = ''

// Utils module will be loaded in the first pipeline stage
def utils = null

properties([
githubProjectProperty(displayName: '', projectUrlStr: REPO_URL),
parameters([
string(name: 'GITHUB_PR_NUMBER', defaultValue: DEF_GITHUB_PR_NUMBER, description: 'Ghaf PR number')
])
])

target_jobs = [:]

////////////////////////////////////////////////////////////////////////////////

def targets = [
// docs
[ system: "x86_64-linux",
target: "doc",
archive: false,
scs: false,
hwtest_device: null,
],

// lenovo x1
[ system: "x86_64-linux",
target: "lenovo-x1-carbon-gen11-debug",
archive: true,
scs: false,
hwtest_device: "lenovo-x1",
],
[ system: "x86_64-linux",
target: "lenovo-x1-carbon-gen11-debug-installer",
archive: true,
scs: false,
hwtest_device: null,
],

// nvidia orin
[ system: "aarch64-linux",
target: "nvidia-jetson-orin-agx-debug",
archive: true,
scs: false,
hwtest_device: "orin-agx",
],
[ system: "aarch64-linux",
target: "nvidia-jetson-orin-nx-debug",
archive: true,
scs: false,
hwtest_device: "orin-nx",
],
[ system: "x86_64-linux",
target: "nvidia-jetson-orin-agx-debug-from-x86_64",
archive: true,
scs: false,
hwtest_device: "orin-agx",
],
[ system: "x86_64-linux",
target: "nvidia-jetson-orin-nx-debug-from-x86_64",
archive: true,
scs: false,
hwtest_device: "orin-nx",
],

// others
[ system: "x86_64-linux",
target: "generic-x86_64-debug",
archive: true,
scs: false,
hwtest_device: "nuc",
],
[ system: "x86_64-linux",
target: "microchip-icicle-kit-debug-from-x86_64",
archive: true,
scs: false,
hwtest_device: "riscv",
],
]

////////////////////////////////////////////////////////////////////////////////

pipeline {
agent { label 'built-in' }
options {
disableConcurrentBuilds()
timestamps ()
buildDiscarder(logRotator(numToKeepStr: '100'))
}
environment {
// https://stackoverflow.com/questions/46680573
GITHUB_PR_NUMBER = params.getOrDefault('GITHUB_PR_NUMBER', DEF_GITHUB_PR_NUMBER)
}
stages {
stage('Checkenv') {
steps {
sh 'if [ -z "$GITHUB_PR_NUMBER" ]; then exit 1; fi'
script {
def href = "${REPO_URL}/pull/${GITHUB_PR_NUMBER}"
currentBuild.description = "<br>(<a href=\"${href}\">#${GITHUB_PR_NUMBER}</a>)"
}
}
}
stage('Checkout') {
steps {
script { utils = load "utils.groovy" }
dir(WORKDIR) {
checkout scmGit(
userRemoteConfigs: [[
url: REPO_URL,
name: 'pr_origin',
// Below, we set the git remote: 'pr_origin'.
// We use '/merge' in pr_origin to build the PR as if it was
// merged to the PR target branch. To build the PR head (without
// merge) you would replace '/merge' with '/head'.
refspec: '+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/pr_origin/pull/${GITHUB_PR_NUMBER}/merge',
]],
branches: [[name: 'pr_origin/pull/${GITHUB_PR_NUMBER}/merge']],
extensions: [
cleanBeforeCheckout(),
],
)
script {
env.TARGET_REPO = sh(script: 'git remote get-url pr_origin', returnStdout: true).trim()
env.TARGET_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
env.ARTIFACTS_REMOTE_PATH = "${env.JOB_NAME}/build_${env.BUILD_ID}-commit_${env.TARGET_COMMIT}"
}
}
}
}
stage('Evaluate') {
steps {
dir(WORKDIR) {
script {
utils.nix_eval_jobs(targets)
target_jobs = utils.create_parallel_stages(targets, testset='_boot_bat_')
}
}
}
}
stage('Build targets') {
steps {
script {
parallel target_jobs
}
}
}
}
}