Skip to content

Commit 369a749

Browse files
committed
merge: '1-ci_pipeline' into 'main'
Resolve "Add CI pipeline and basic test cases for raw bindings" Closes #1 See merge request namib-master/libraries/tinydtls-rs!2
2 parents 3e56f52 + f897fad commit 369a749

File tree

7 files changed

+758
-20
lines changed

7 files changed

+758
-20
lines changed

.gitlab-ci.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
stages:
2+
- test
3+
- docs
4+
- release
5+
6+
# No longer create push pipeline if MR is created (avoiding duplicate pipelines).
7+
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
8+
workflow:
9+
rules:
10+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
11+
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
12+
when: never
13+
- if: '$CI_COMMIT_BRANCH'
14+
15+
# Default image for all builds is the generic controller project build image containing most
16+
# external dependencies, including rust, clippy, cargo, and C library dependencies.
17+
# Adding additional dependencies to this image (by opening a MR in the respective project)
18+
# is strongly preferred to installing dependencies in before_script.
19+
image: gitlab.informatik.uni-bremen.de:5005/namib-master/ci-docker-images/controller:generic
20+
21+
# Cache definition for the cargo package cache.
22+
# Pull only by default - the fetch-deps job will update the cache for each build.
23+
.pkg_cache: &pkg_cache
24+
key: "pkgcache-$CI_COMMIT_REF_SLUG"
25+
paths:
26+
- .cargo/
27+
policy: pull
28+
29+
.on_default_branch:
30+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
31+
32+
.on_tags:
33+
- if: '$CI_COMMIT_TAG'
34+
35+
.allow_manual_run:
36+
- when: manual
37+
allow_failure: true
38+
39+
.on_ready_mrs:
40+
- if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^(?:WIP|Draft):.*/'
41+
42+
default:
43+
# Use the shared linux Kubernetes cluster for most tasks.
44+
tags:
45+
- linux
46+
- docker
47+
- kubernetes
48+
# We don't want to keep most artifacts around for longer.
49+
artifacts:
50+
expire_in: 1 week
51+
# retry: 2
52+
cache:
53+
- *pkg_cache
54+
55+
fetch-deps:
56+
stage: .pre
57+
cache:
58+
- key: !reference [.pkg_cache, key]
59+
paths: !reference [.pkg_cache, paths]
60+
policy: pull-push
61+
script:
62+
- cargo fetch
63+
- cargo generate-lockfile
64+
artifacts:
65+
paths:
66+
- Cargo.lock # Because this is a library, we need the Cargo.lock to maintain consistency
67+
68+
.test_base:
69+
stage: test
70+
needs:
71+
- job: fetch-deps
72+
artifacts: true
73+
script:
74+
- cargo test --locked -p $PKG_NAME --no-fail-fast -- -Z unstable-options --format json --report-time | tee results.json
75+
- cat results.json | cargo2junit > target/$PKG_NAME-test-results.xml
76+
artifacts:
77+
reports:
78+
junit: target/$PKG_NAME-test-results.xml
79+
80+
sys:test:
81+
extends: .test_base
82+
variables:
83+
PKG_NAME: tinydtls-sys
84+
85+
.coverage_base:
86+
stage: test
87+
allow_failure: true
88+
needs:
89+
- job: fetch-deps
90+
artifacts: true
91+
rules:
92+
- !reference [.on_tags]
93+
- !reference [.on_default_branch]
94+
- !reference [.on_ready_mrs]
95+
- !reference [.allow_manual_run]
96+
script:
97+
- cargo tarpaulin --locked --no-fail-fast -p $PKG_NAME --out Xml
98+
- mv cobertura.xml target/$PKG_NAME-coverage.xml
99+
artifacts:
100+
reports:
101+
cobertura: target/$PKG_NAME-coverage.xml
102+
103+
sys:coverage:
104+
extends: .coverage_base
105+
variables:
106+
PKG_NAME: tinydtls-sys
107+
108+
.lint_base:
109+
stage: test
110+
allow_failure: true
111+
needs:
112+
- job: fetch-deps
113+
artifacts: true
114+
script:
115+
- cargo clippy --locked -p $PKG_NAME -- -D warnings
116+
after_script:
117+
- cargo clippy --locked -p $PKG_NAME --message-format=json | gitlab-clippy > target/$PKG_NAME-code-quality.json
118+
artifacts:
119+
reports:
120+
codequality: target/$PKG_NAME-code-quality.json
121+
122+
123+
sys:lint:
124+
extends: .lint_base
125+
variables:
126+
PKG_NAME: tinydtls-sys
127+
128+
docs:
129+
stage: docs
130+
allow_failure: true
131+
needs:
132+
- job: fetch-deps
133+
artifacts: true
134+
rules:
135+
- !reference [.on_default_branch]
136+
- !reference [.on_tags]
137+
- !reference [.allow_manual_run]
138+
script:
139+
- cargo doc --locked --workspace --no-deps
140+
artifacts:
141+
paths:
142+
- target/doc
143+
144+
pages:
145+
stage: release
146+
needs:
147+
- docs
148+
rules:
149+
- !reference [.on_default_branch]
150+
script:
151+
- mv target/doc public
152+
- echo '<meta http-equiv="refresh" content="0;" url="tinydtls_sys/index.html">' > public/index.html
153+
artifacts:
154+
paths:
155+
- public
156+
157+
.publish_cratesio_base:
158+
stage: release
159+
needs:
160+
- job: sys:test
161+
artifacts: false
162+
- job: docs
163+
artifacts: false
164+
- job: fetch-deps
165+
artifacts: true
166+
rules:
167+
- if: "$CI_COMMIT_TAG"
168+
when: manual
169+
- when: never
170+
script:
171+
- cargo --locked -p $PKG_NAME publish
172+
173+
sys:publish_cratesio:
174+
extends: .publish_cratesio_base
175+
variables:
176+
PKG_NAME: tinydtls-sys
177+
178+
gen-lsif:
179+
stage: .post
180+
allow_failure: true
181+
cache: []
182+
needs:
183+
- job: fetch-deps # We need the Cargo.lock file in order to run the build script (which can't be disabled)
184+
artifacts: true
185+
script:
186+
- rust-analyzer -v lsif . > tinydtls-rs.lsif
187+
artifacts:
188+
reports:
189+
lsif: tinydtls-rs.lsif
190+
191+
192+
variables:
193+
# Kubernetes Runner Resource Limiting
194+
KUBERNETES_CPU_REQUEST: 4
195+
# KUBERNETES_CPU_LIMIT: 5
196+
KUBERNETES_MEMORY_REQUEST: 4Gi
197+
KUBERNETES_MEMORY_LIMIT: 4Gi
198+
# KUBERNETES_SERVICE_CPU_REQUEST: 400m
199+
# KUBERNETES_SERVICE_CPU_LIMIT: 400m
200+
# KUBERNETES_SERVICE_MEMORY_REQUEST: 1Gi
201+
# KUBERNETES_SERVICE_MEMORY_LIMIT: 1Gi
202+
# ---
203+
# Cargo Settings
204+
# Number of concurrent build threads to start.
205+
# Note: Removing this value somehow causes jobs to randomly get stuck during compilation.
206+
CARGO_BUILD_JOBS: 4
207+
# Location of Cargo home. Needed for caching.
208+
CARGO_HOME: "${CI_PROJECT_DIR}/.cargo"
209+
# ---
210+
# Fastzip
211+
# Use faster cache and artifact compression method.
212+
# Increases speed **drastically**, so don't remove it unless it causes issues.
213+
FF_USE_FASTZIP: "true"
214+
CACHE_COMPRESSION_LEVEL: fast
215+
GIT_SUBMODULE_STRATEGY: recursive
216+
TRANSFER_METER_FREQUENCY: 5s

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ Rust bindings to the tinydtls library (only raw bindings for now).
55
## License
66

77
Matching the license of the tinydtls C library, this library is made available both under
8-
the terms of the Eclipse Public License v1.0 and 3-Clause BSD License (which the
8+
the terms of the Eclipse Public License v1.0 and 3-Clause BSD License (which the
99
Eclipse Distribution License v1.0 that is used for tinydtls is based on).
1010

11-
You may choose at your own option which of the two licenses you wish to use for the Rust
12-
crate code and the TinyDTLS C library itself, see https://www.eclipse.org/legal/eplfaq.php#DUALLIC.
13-
1411
Additionally, the tinydtls C library contains third party code that might be included
1512
in compiled binaries that link to tinydtls.
16-
For information on third-party code and its licenses, see
13+
For information on third-party code and its licenses, see
1714
https://github.com/eclipse/tinydtls/blob/develop/ABOUT.md.
1815

19-
See https://github.com/eclipse/tinydtls/blob/develop/LICENSE for more information.
16+
See https://github.com/eclipse/tinydtls/blob/develop/LICENSE for more information on the
17+
tinydtls licensing terms and https://www.eclipse.org/legal/eplfaq.php for more information
18+
on the EPL 1.0.
19+
20+
Note: This binding is neither supported nor endorsed by the Eclipse Foundation.
2021

2122
## Maintainers
2223

tinydtls-sys/Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
[package]
55
name = "tinydtls-sys"
66
description = "Raw bindings to the TinyDTLS library."
7-
version = "0.1.0-alpha.1+tinydtls-c8d2def"
7+
version = "0.1.0-alpha.1+tinydtls-68f6045"
88
edition = "2021"
99
links = "tinydtls"
1010
# For tinydtls, both licenses can be applied, see https://www.eclipse.org/legal/eplfaq.php#DUALLIC
1111
# BSD-3-CLAUSE is equivalent to the EDL v1.0, see https://www.eclipse.org/org/documents/edl-v10.php
1212
# First bracket is the license for TinyDTLS, the remainder is for code included with tinydtls.
1313
license = "(EPL-1.0 OR BSD-3-CLAUSE) AND BSD-1-Clause AND BSD-3-CLAUSE AND MIT"
1414
readme = "README.md"
15-
homepage = "https://namib.me/"
15+
homepage = "https://github.com/namib-project/tinydtls-rs"
16+
repository = "https://github.com/namib-project/tinydtls-rs"
1617
authors = ["Hugo Hakim Damer <[email protected]>"]
1718
categories = ["external-ffi-bindings", "network-programming", "cryptography", "embedded"]
1819
keywords = ["tinydtls", "sys", "dtls", "crypto"]
1920
exclude = ['/src/tinydtls/share/', '/src/tinydtls/include/', '/src/tinydtls/configure.prev']
2021

2122
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2223
[features]
23-
default = ["vendored"]
24+
default = ["vendored", "static", "ecc", "psk"]
2425
# Use a vendored version of tinydtls
2526
vendored = ["static"]
2627
# Attempt static linking to tinydtls
@@ -32,9 +33,12 @@ ecc = []
3233
psk = []
3334

3435
[dependencies]
35-
libc = "^0.2"
36+
libc = "^0.2.112"
37+
38+
[dev-dependencies]
39+
lazy_static = "^1.4"
3640

3741
[build-dependencies]
38-
bindgen = "0.59.2"
39-
autotools = "0.2.3"
40-
fs_extra = "1.2.0"
42+
bindgen = "^0.59.2"
43+
autotools = "^0.2.3"
44+
fs_extra = "^1.2"

tinydtls-sys/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

tinydtls-sys/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# tinydtls-sys
2+
3+
Raw bindings to the [tinydtls C library](https://github.com/eclipse/tinydtls).
4+
5+
## Features
6+
These features affect the way that the binding is built:
7+
- `vendored` (default): Build and use a vendored version of tinydtls instead of linking to an existing one.
8+
- `static` (default): Use static linking instead of dynamic linking
9+
10+
These features affect the functionality of the library (only apply if `vendored` is enabled, we can't control features
11+
of binaries that are already built):
12+
- `ecc` (default): Enable ECC functionality
13+
- `psk` (default): Enable PSK functionality
14+
15+
## License
16+
17+
Matching the license of the tinydtls C library, this library is made available both under
18+
the terms of the Eclipse Public License v1.0 and 3-Clause BSD License (which the
19+
Eclipse Distribution License v1.0 that is used for tinydtls is based on).
20+
21+
Additionally, the tinydtls C library contains third party code that might be included
22+
in compiled binaries that link to tinydtls.
23+
For information on third-party code and its licenses, see
24+
https://github.com/eclipse/tinydtls/blob/develop/ABOUT.md.
25+
26+
See https://github.com/eclipse/tinydtls/blob/develop/LICENSE for more information on the
27+
tinydtls licensing terms and https://www.eclipse.org/legal/eplfaq.php for more information
28+
on the EPL 1.0.
29+
30+
Note: This binding is neither supported nor endorsed by the Eclipse Foundation.

tinydtls-sys/build.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ fn main() {
2626
// TinyDTLS does not like being built out of source, but we get verification errors if files
2727
// in the source package are modified.
2828
// Therefore, we copy tinydtls over to the output directory and build from there.
29-
let mut copy_options = fs_extra::dir::CopyOptions::default();
30-
copy_options.overwrite = true;
29+
let copy_options = fs_extra::dir::CopyOptions {
30+
overwrite: true,
31+
..Default::default()
32+
};
3133
fs_extra::dir::copy(
3234
Path::new(env!("CARGO_MANIFEST_DIR")).join("src").join("tinydtls"),
3335
&out_dir,
@@ -41,7 +43,7 @@ fn main() {
4143
.unwrap()
4244
.into_string()
4345
.unwrap()
44-
.split(" ")
46+
.split(' ')
4547
.map(String::from)
4648
.collect();
4749

@@ -67,10 +69,10 @@ fn main() {
6769

6870
// Enable debug symbols if enabled in Rust.
6971
match std::env::var_os("DEBUG").unwrap().to_str().unwrap() {
70-
"0" | "false" => {},
72+
"0" | "false" => {}
7173
_ => {
7274
build_config.with("debug", None);
73-
},
75+
}
7476
}
7577

7678
// Enable dependency features based on selected cargo features.

0 commit comments

Comments
 (0)