-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
186 lines (165 loc) · 5.67 KB
/
Jenkinsfile
File metadata and controls
186 lines (165 loc) · 5.67 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
pipeline {
agent any
environment {
CARGO_HOME = "${WORKSPACE}/.cargo"
RUST_BACKTRACE = '1'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps()
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Setup') {
steps {
sh 'rustc --version'
sh 'cargo --version'
}
}
stage('Build') {
parallel {
stage('Debug Build') {
steps {
sh 'cargo build --workspace --verbose'
}
}
stage('Release Build') {
steps {
sh 'cargo build --release --workspace'
}
}
}
}
stage('Test') {
parallel {
stage('Unit Tests') {
steps {
sh 'cargo test --all-features --workspace'
}
}
stage('Doc Tests') {
steps {
sh 'cargo test --doc --workspace'
}
}
stage('Integration Tests') {
steps {
script {
sh '''
./target/release/arclang check examples/aerospace/flight_control_system.arc
./target/release/arclang check examples/automotive/adaptive_cruise_control.arc
./target/release/arclang check examples/defense/mission_computer.arc
'''
}
}
}
}
}
stage('Quality') {
parallel {
stage('Lint') {
steps {
sh 'rustup component add rustfmt clippy'
sh 'cargo fmt --all -- --check'
sh 'cargo clippy --all-targets --all-features -- -D warnings'
}
}
stage('Coverage') {
steps {
sh 'cargo install cargo-tarpaulin || true'
sh 'cargo tarpaulin --all-features --workspace --timeout 300 --out Xml'
publishCoverage adapters: [coberturaAdapter('cobertura.xml')]
}
}
stage('Security Audit') {
steps {
sh 'cargo install cargo-audit || true'
sh 'cargo audit'
}
}
}
}
stage('Safety Analysis') {
parallel {
stage('DO-178C Analysis') {
steps {
sh './target/release/arclang safety examples/aerospace/flight_control_system.arc --standard DO178C --report'
archiveArtifacts artifacts: '*_safety_report.pdf', fingerprint: true
}
}
stage('ISO 26262 Analysis') {
steps {
sh './target/release/arclang safety examples/automotive/adaptive_cruise_control.arc --standard ISO26262 --fmea --fta --report'
archiveArtifacts artifacts: '*_fmea.csv,*_fta.dot,*_safety_report.pdf', fingerprint: true
}
}
}
}
stage('Benchmarks') {
when {
branch 'main'
}
steps {
sh 'cargo bench --workspace'
archiveArtifacts artifacts: 'target/criterion/**/*', fingerprint: true
}
}
stage('Documentation') {
steps {
sh 'cargo doc --all-features --no-deps --workspace'
publishHTML([
reportDir: 'target/doc',
reportFiles: 'index.html',
reportName: 'API Documentation'
])
}
}
stage('Package') {
when {
anyOf {
branch 'main'
tag pattern: 'v*.*.*', comparator: 'REGEXP'
}
}
steps {
script {
if (env.TAG_NAME) {
sh 'cargo package --workspace'
archiveArtifacts artifacts: 'target/package/*.crate', fingerprint: true
}
}
}
}
stage('Deploy') {
when {
tag pattern: 'v*.*.*', comparator: 'REGEXP'
}
steps {
script {
withCredentials([string(credentialsId: 'cargo-token', variable: 'CARGO_TOKEN')]) {
sh 'cargo publish --token ${CARGO_TOKEN}'
}
}
}
}
}
post {
always {
junit testResults: 'target/junit.xml', allowEmptyResults: true
}
success {
echo 'Pipeline succeeded!'
}
failure {
echo 'Pipeline failed!'
emailext (
subject: "Build Failed: ${env.JOB_NAME} - ${env.BUILD_NUMBER}",
body: "Check console output at ${env.BUILD_URL}",
to: "${env.CHANGE_AUTHOR_EMAIL}"
)
}
cleanup {
cleanWs()
}
}
}