-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
186 lines (174 loc) · 5.36 KB
/
.gitlab-ci.yml
File metadata and controls
186 lines (174 loc) · 5.36 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
stages:
- testLibs # Run tests on libs
- build # Build the module
- testModule # Run tests build module
- deployLocal # Deploy to local, gitlab, proget(nuget,choco,psgallary)
- tag # Create tag with version - Generated version with commitfusion
- release # Create Release from tag
# - deploy # Deploy to chocolatey, Powershell Gallery
# --------------------------------
# Pester Test Stage
pester_test:
stage: testLibs
tags:
- windows
script:
- echo "Running test -> pester_test"
- pwsh
- install-module -name 'pester' -RequiredVersion '5.5.0' -Repository 'psgallery' -confirm:$false
- Import-Module -name pester -RequiredVersion '5.5.0'
- invoke-Pester -Script .\test\Test-Unit-Pester.ps1 -CI || exit 1
# --------------------------------
# Pester Test Stage & Coverage
pester_test_coverage:
stage: test
tags:
- windows
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "testLibs" && $CI_BUILD_STATUS == "success"'
script:
- echo "Running test -> pester_test_coverage"
- pwsh
- install-module -name 'pester' -RequiredVersion '5.5.0' -Repository 'psgallery' -confirm:$false
- Import-Module -name pester -RequiredVersion '5.5.0'
- invoke-Pester -Script .\build\scripts\bt0-ci-test-pester.ps1 -CI || exit 1
artifacts:
paths:
- ./coverage.xml
# --------------------------------
# Script Analyzer Test Stage
script_analyzer:
stage: test
tags:
- windows
script:
- echo "Running test -> script_analyzer"
- pwsh
- find-module -name PSScriptAnalyzer -Repository PSGallery | install-module -Scope CurrentUser -Force -SkipPublisherCheck
- Import-Module -Name PSScriptAnalyzer
- ./build/scripts/bt1-p2-ci-test-pssa.ps1
artifacts:
paths:
- ./coverage.xml
# --------------------------------
# Build Module Stage
build_module:
stage: build
tags:
- windows
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "test" && $CI_BUILD_STATUS == "success"'
script:
- pwsh
- Find-Module -name 'psmpacker' -repository 'powershell' | install-Module -force
- import-module -name 'psmpacker'
- .\build\scripts\bt1-ci-build-module.ps1
artifacts:
paths:
- ./dist/*
- ./coverage.xml
# --------------------------------
# Create Nuget Package Stage
create_nuget_Package:
stage: build
tags:
- windows
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "test" && $CI_BUILD_STATUS == "success"'
script:
- pwsh
- find-Module -Repository 'powershell' -Name 'nupsforge' | Install-module -force
- Import-Module -Name 'nupsforge' -force
- .\build\scripts\bt2-ci-create-packages.ps1
artifacts:
paths:
- ./dist/*
- ./coverage.xml
# --------------------------------
# Deploy GitLab Package Stage
deploy_gitlab_package:
stage: deploylocal
tags:
- windows
script:
- pwsh
- Install-Module -Name csverify -force | Import-module -force
- .\build\scripts\bt3-ci-deploy-pushtogitlab.ps1
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "build" && $CI_BUILD_STATUS == "success"'
artifacts:
paths:
- ./dist/*
- ./coverage.xml
# --------------------------------
# Deploy Proget Packages Stage
deploy_proget_packages:
stage: deploylocal
tags:
- windows
script:
- pwsh.exe
- .\build\scripts\bt4-ci-deploy-pushtoproget.ps1
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "build" && $CI_BUILD_STATUS == "success"'
artifacts:
paths:
- ./dist/*
- ./coverage.xml
# --------------------------------
# Deploy Chocolatey Package Stage
deploy_chocolatey_package:
stage: deploy
tags:
- windows
script:
- pwsh.exe
- .\build\scripts\BT5-CI-deploy-PushToChoco.ps1
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "deploylocal" && $CI_BUILD_STATUS == "success"'
artifacts:
paths:
- ./dist/*
- ./coverage.xml
# --------------------------------
# Deploy PSGallary Package Stage
deploy_psgal_package:
stage: deploy
tags:
- windows
script:
- pwsh.exe
- .\build\scripts\bt6-ci-deploy-psgallary.ps1
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "deploylocal" && $CI_BUILD_STATUS == "success"'
# --------------------------------
# Create Release Stage
create_tag:
stage: release
tags:
- windows
script:
- pwsh.exe
- install-module -name commitfusion -force | import-module -force
- $semver_version = (Get-GitAutoVersion).version
- git config --global user.name "${GITLAB_NAME}"
- git config --global user.email "${GITLAB_EMAIL}"
- git tag "$semver_version"
- git push --tags http://${$GITLAB_API_KEY}@$https://gitlab.lab.davilion.online/powershell/commitfusion.git HEAD:main
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "deploy" && $CI_BUILD_STATUS == "success"'
artifacts:
paths:
- Build.gz
- ./dist/*
# -------------------------------------
# Deploy Coverage to Coverails.io Stage
deploy_coverage:
stage: release
tags:
- windows
script:
- pwsh.exe
- .\bt8-ci-deploy-coveralls-report.ps1
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_BUILD_STAGE == "deploy" && $CI_BUILD_STATUS == "success"'