16 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
17 set repo_path [
file normalize "$tcl_path/../.."]
19 source $tcl_path/hog.tcl
23 if {[
info exists env(HOG_TCLLIB_PATH)]} {
24 lappend auto_path $env(HOG_TCLLIB_PATH)
26 puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
32 if {[
catch {
package require cmdline} ERROR] || [
catch {
package require struct::matrix} ERROR]} {
33 puts "$ERROR\n Tcllib not found. If you are running this script on tclsh, you can fix this by installing 'tcllib'"
40 {sim "If set, checks also the version of the simulation files."}
41 {ext_path.arg "" "Sets the absolute path for the external libraries."}
44 set usage "- USAGE: $::argv0 \[OPTIONS\] <project> \n. Options:"
59 set project [
lindex $argv 0]
62 set project_dir $repo_path/Top/$project
64 if {$options(sim) == 1} {
66 Msg Info "Will check also the version of the simulation files..."
69 if {$options(ext_path) != ""} {
70 set ext_path $options(ext_path)
71 Msg Info "External path set to $ext_path"
75 if {[
info exists env(HOG_PUSH_TOKEN)] && [
info exist env(CI_PROJECT_ID)] && [
info exist env(CI_API_V4_URL)] } {
76 set token $env(HOG_PUSH_TOKEN)
77 set api_url $env(CI_API_V4_URL)
78 set project_id $env(CI_PROJECT_ID)
86 Msg Info "$project was modified, continuing with the CI..."
88 Msg Info "Checking if the project has been already built in a previous CI run..."
90 Msg Info "Checking if project $project has been built in a previous CI run with sha $sha..."
91 set result [
catch {
package require json} JsonFound]
92 if {"$result" != "0"} {
93 Msg CriticalWarning "Cannot find JSON package equal or higher than 1.0.\n $JsonFound\n Exiting"
96 lassign [
ExecuteRet curl --header "PRIVATE-TOKEN: $token" "$api_url/projects/$project_id/pipelines"] ret content
97 set pipeline_dict [json::json2dict $content]
98 if {[
llength $pipeline_dict] > 0} {
99 foreach pip $pipeline_dict {
101 set source [
DictGet $pip source]
102 if {$source == "merge_request_event" && [
string first $sha $pip_sha] != -1} {
103 Msg Info "Found pipeline with sha $pip_sha for project $project"
104 set pipeline_id [
DictGet $pip id]
106 lassign [
ExecuteRet curl --header "PRIVATE-TOKEN: $token" "$api_url/projects/${project_id}/pipelines/${pipeline_id}/jobs?pagination=keyset&per_page=100"] ret2 content2
107 set jobs_dict [json::json2dict $content2]
108 if {[
llength $jobs_dict] > 0} {
109 foreach job $jobs_dict {
110 set job_name [
DictGet $job name]
112 set artifacts [
DictGet $job artifacts_file]
113 set status [
DictGet $job status]
114 set current_job_name $env(CI_JOB_NAME)
115 if {$current_job_name == $job_name && $status == "success"} {
117 lassign [
ExecuteRet curl --location --output artifacts.zip --header "PRIVATE-TOKEN: $token" --url "$api_url/projects/$project_id/jobs/$job_id/artifacts"] ret3 content3
119 Msg CriticalWarning "Cannot download artifacts for job $job_name with id $job_id"
122 lassign [
ExecuteRet unzip -o $repo_path/artifacts.zip] ret_zip
126 Msg Info "Artifacts for job $job_name with id $job_id downloaded and unzipped."
127 file mkdir $repo_path/Projects/$project
128 set fp [open "$repo_path/Projects/$project/skip.me" w+]
140 }
elseif {$ver != -1} {
141 Msg Info "$project was not modified since version: $ver, disabling the CI..."
142 file mkdir $repo_path/Projects/$project
143 set fp [open "$repo_path/Projects/$project/skip.me" w+]