#!groovy

// Copyright (c) 2020 ETH Zurich
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

pipeline {
    agent {
        node {
            label 'ssl_daintvm1'
        }
    }
    options {
        buildDiscarder(
            logRotator(
                daysToKeepStr: "14",
                numToKeepStr: "50",
                artifactDaysToKeepStr: "14",
                artifactNumToKeepStr: "50"
            )
        )
    }
    environment {
        GITHUB_TOKEN = credentials('PIKA_BOT_GITHUB_TOKEN')
    }
    stages {
        stage('checkout') {
            steps {
                dir('pika') {
                    checkout scm
                    echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
                }
            }
        }
        stage('build') {
            options {
                timeout(time: 2, unit: 'HOURS')
            }
            matrix {
                axes {
                    axis {
                        name 'configuration_name'
                        values 'gcc-13', 'gcc-12', 'gcc-11', 'gcc-10-apex', 'gcc-9', 'gcc-cuda-11', 'gcc-cuda-12', 'clang-16', 'clang-15', 'clang-14-cuda', 'clang-13', 'clang-12', 'clang-11', 'cce', 'nvhpc'
                    }
                    axis {
                         name 'build_type'
                         values 'Debug', 'Release'
                    }
                }
                stages {
                    stage('build') {
                        steps {
                            dir('pika') {
                                sh '''
                                #!/bin/bash -l
                                .jenkins/cscs/entry.sh
                                '''
                            }
                        }
                    }
                }
            }
        }
    }

    post {
        always {
            archiveArtifacts artifacts: 'pika/jenkins-pika-*', fingerprint: true
            archiveArtifacts artifacts: 'pika/*-Testing/**', fingerprint: true
        }
    }
}
