# Copyright 2022 Thales Silicon Security
#
# Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.0
# You may obtain a copy of the License at https://solderpad.org/licenses/
#
# Original Author: Yannick Casamatta (yannick.casamatta@thalesgroup.com)

# Guidlines:

# This pipeline can be also be triggerd underneath by CI of CV32 repository, this requires to respected some rules:
# - In this pipeline, job artifacts must be only defined in a folder named "artifacts" at the root of the job's workdir.
# - In this pipeline, do not define before_script and after_script in the global section (avoid in job too).
# - Please prefix all jobs in this file with "pub_" which stands for "public" job.


variables:
  GIT_STRATEGY: fetch
  GIT_SUBMODULE_STRATEGY: recursive


.template_job_low_footprint:
  variables:
    GIT_STRATEGY: none
  before_script:
    - echo 'nothing'
  after_script:
    - echo 'nothing'

.template_job_init_cva6:
  tags: [$TAGS_RUNNER]
  rules:
    - if: '$SCOPE_CVV == "true"'
      when: on_success
    - when: never

.template_job_full_ci:
  tags: [$TAGS_RUNNER]
  rules:
    - when: on_success

.template_job_short_ci:
  tags: [$TAGS_RUNNER]
  rules:
    - if: '$CI_WEIGHT == "full"'
      when: on_success
    - when: manual
      allow_failure: true

.template_job_always_manual:
  tags: [$TAGS_RUNNER]
  rules:
    - when: manual
      allow_failure: true


stages:
  - .pre
  - one
  - two
  - three


pub_check_env:
  stage: one
  extends:
    - .template_job_low_footprint
    - .template_job_full_ci
  needs: []
  script:
    - echo $CI_WEIGHT
    - echo $RISCV
    - echo $VERILATOR_ROOT
    - echo $SPIKE_ROOT
    - echo $BBL_ROOT
    - echo $SYN_VCS_BASHRC
    - echo $SYN_DCSHELL_BASHRC
    - echo $QUESTA_BASHRC
    - echo $VIVALDO_SETUP
    - echo $CV32_REPO
    - echo $CV32_BRANCH
    - echo $CV32_HASH
    - echo $CORE_V_VERIF_REPO
    - echo $CORE_V_VERIF_BRANCH
    - echo $CORE_V_VERIF_HASH
    - echo $COMPLIANCE_REPO
    - echo $COMPLIANCE_BRANCH
    - echo $COMPLIANCE_HASH
    - echo $COMPLIANCE_PATCH
    - echo $TESTS_REPO
    - echo $TESTS_BRANCH
    - echo $TESTS_HASH
    - echo $DV_REPO
    - echo $DV_BRANCH
    - echo $DV_HASH
    - echo $DV_PATCH
    - echo $TAGS_RUNNER
    - echo $NUM_JOBS
    - echo $FOUNDRY_PATH
    - echo $TECH_NAME
    - echo $SYNTH_PERIOD
    - echo $LIB_VERILOG


# cv32e40p Quick start  
pub_quickstart:
  stage: one
  extends:
    - .template_job_full_ci
  needs: []
  rules:
    - if: '$CI_WEIGHT == "full"'
      when: on_success
    - when: manual
      allow_failure: true
  script:
    - make -C cv32e40p/sim/core

