-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
152 lines (130 loc) · 5.16 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- run_tests
- build_docs
- deploy
.only-default: &only-default
only:
- master
- merge_requests
- tags
.only-stable: &only-stable
only:
- master
- tags
###################################################################################################
# Runs test for HW scripts themselves.
###################################################################################################
run_tests:
<<: *only-default
stage: run_tests
tags:
- shell
allow_failure: true
script:
- pwd
- source ./setup_env
- pytest -s --measure-coverage --color=no --junit-xml=report.xml
- coverage report --sort=-cover
- coverage html
# Clean-up VCS builds after the tests since they take lot of space!
after_script:
- cd tests
- ./clean_up_all.sh
coverage: '/TOTAL\s+(?:\d+\s+){4}(\d+\.?\d+)%/'
artifacts:
when: always
paths:
- htmlcov
reports:
junit: report.xml
###################################################################################################
# Builds user manual.
###################################################################################################
build_docs:
<<: *only-default
tags:
- shell
stage: build_docs
script:
- source ./setup_env
- cd doc/ts_sim_user_guide
- ts_latex_build.py ts_sim_user_guide.tex
- cd ../ts_pwr_user_guide
- ts_latex_build.py ts_pwr_user_guide.tex
- cd ../ts_mem_map_generate_user_guide
- ts_latex_build.py ts_mem_map_generate_user_guide.tex
- cd ../ts_syn_user_guide
- ts_latex_build.py ts_syn_user_guide.tex
after_script:
- echo "Publishing pages..."
- mkdir -p public
- cp doc/ts_sim_user_guide/build/pdf/ts_sim_user_guide.pdf public
- cp doc/ts_pwr_user_guide/build/pdf/ts_pwr_user_guide.pdf public
- cp doc/ts_mem_map_generate_user_guide/build/pdf/ts_mem_map_generate_user_guide.pdf public
- cp doc/ts_syn_user_guide/build/pdf/ts_syn_user_guide.pdf public
artifacts:
paths:
- public
###################################################################################################
# Deploy on Tropic Square machines
###################################################################################################
tropic_install:
<<: *only-stable
stage: deploy
when: manual
tags:
- shell
script:
- export VERSION=`git describe --tags --abbrev=0`
- export DEST_FOLDER=/tools/tropic/ts-hw-scripts
# Will fail if concrete version directory already exists. This will avoid
# re-placing older version with new if we forget to add new tag!
- mkdir -p $DEST_FOLDER
- mkdir $DEST_FOLDER/$VERSION
# Publish documentation
- mkdir $DEST_FOLDER/$VERSION/doc
- cp public/ts_sim_user_guide.pdf $DEST_FOLDER/$VERSION/doc/
- cp public/ts_pwr_user_guide.pdf $DEST_FOLDER/$VERSION/doc/
- cp public/ts_mem_map_generate_user_guide.pdf $DEST_FOLDER/$VERSION/doc/
- cp public/ts_syn_user_guide.pdf $DEST_FOLDER/$VERSION/doc/
# Add version to source files
- echo "__version__ = \"$(git describe --tags)\"" > scripts/internal/__version__.py
# Publish scripts themselves
- cp -r scripts $DEST_FOLDER/$VERSION
###################################################################################################
# Filter files into 'public' branch so that it can be released on Github.
#
# Mirrors master branch, but filters out files that should not be published.
###################################################################################################
public_filter:
<<: *only-stable
stage: deploy
tags:
- shell
script:
- source ./setup_env
- git branch -D public || true
- git branch public
- git checkout public
# Filter out folders with sensitive information:
# - examples
# - tests
# - templates/ts_pdk_config.yml
# - templates/ts_design_config.yml
# TODO: Wrap the filtration to some common script and the filtered paths to some standardized file!
- git-filter-repo --path example --path templates/ts_design_config.yml --path templates/ts_pdk_config.yml --path tests --invert-paths --force
# Force push to "public" branch
# Authenticate via Project token passed via CI/CD variable
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git remote remove origin || true
- git remote add origin https://oauth2:$CI_BOT_ACCESS_TOKEN@tropic-gitlab.corp.sldev.cz/internal/development-environment/ts-hw-scripts.git
- git remote -v
- git push origin public --force
# Force push to GITHUB
- git remote remove github_mirror || true
- git remote add github_mirror git@github.com:tropicsquare/ts-hw-scripts.git
- git push --force github_mirror -u public
- git push --force --tags