#!groovy

// Copyright (c) 2020 ETH Zurich
// Copyright (c) 2022 Hartmut Kaiser
// Copyright (c) 2024 Alireza Kheirkhahan
//
// 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 any
    options {
        buildDiscarder(
            logRotator(
                daysToKeepStr: "14",
                numToKeepStr: "50",
                artifactDaysToKeepStr: "14",
                artifactNumToKeepStr: "50"
            )
        )
    }
    environment {
        GITHUB_TOKEN = credentials('STELLARBOT_GITHUB_TOKEN')
    }
    stages {
        stage('checkout') {
            steps {
                dir('hpx') {
                    checkout scm
                    echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
                }
            }
        }
        stage('build') {
            matrix {
                axes {
                    axis {
                        name 'configuration_name'
                        values 'gcc-11', 'gcc-12', 'gcc-13', 'gcc-14', 'gcc-15', 'clang-17-apex', 'clang-16', 'clang-17', 'clang-18', 'clang-19', 'clang-20', 'gcc-12-cuda-12', 'gcc-12-cuda-12-dgx', 'hipcc'
                    }
                    axis {
                         name 'build_type'
                         values 'Release', 'Debug'
                    }
                }
                stages {
                    stage('build') {
                        steps {
                            dir('hpx') {
                                sh '''
                                #!/bin/bash -l
                                .jenkins/lsu/entry.sh
                                '''
                            }
                        }
                    }
                }
            }
        }
    }

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