|
| 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 |
0 commit comments