Add gitlab ci

This commit is contained in:
Sosthène Guédon
2022-11-03 10:05:36 +01:00
parent 8477aa1333
commit b9164b5f0d
6 changed files with 115 additions and 1 deletions
+2
View File
@@ -1,2 +1,4 @@
/target
Cargo.lock
tarpaulin-report.html
cobertura.xml
+50
View File
@@ -0,0 +1,50 @@
# Copyright (C) 2022 Nitrokey GmbH
# SPDX-License-Identifier: CC0-1.0
include: 'https://raw.githubusercontent.com/Nitrokey/common-ci-jobs/master/common_jobs.yml'
stages:
- pull-github
- build
- deploy
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
GIT_SUBMODULE_STRATEGY: recursive
REPO_NAME: piv-authenticator
MAIN_BRANCH: main
COMMON_PULL: "true"
COMMON_UPLOAD_NIGHTLY: "false"
COMMON_GITHUB_RELEASE: "false"
COMMON_UPLOAD_FILES: "false"
build:
image: registry.git.nitrokey.com/nitrokey/piv-authenticator/piv-authenticator-build:latest
rules:
- if: '$CI_PIPELINE_SHOULD_NOT_BUILD == "true"'
when: never
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
tags:
- docker
stage: build
before_script:
- cargo --version
script:
- make ci
after_script:
- cp /app/.cache/scdaemon.log scdaemon.log
- wget $icon_server/checkmark/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHA/$CI_JOB_NAME/$CI_JOB_STATUS/${CI_JOB_URL#*/*/*/}
coverage: '/^\d+.\d+% coverage/'
artifacts:
when: always
paths:
- "scdaemon.log"
- "cobertura.xml"
- "tarpaulin-report.html"
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
+4 -1
View File
@@ -14,7 +14,6 @@ test:
check:
cargo fmt --check
cargo check --all-targets --all-features
cargo check --target thumbv7em-none-eabi
cargo clippy --all-targets --all-features -- -Dwarnings
RUSTDOCFLAGS='-Dwarnings' cargo doc --all-features
@@ -25,3 +24,7 @@ tarpaulin:
.PHONY: example
example:
cargo run --example virtual --features virtual
.PHONY: ci
ci: check tarpaulin
+18
View File
@@ -0,0 +1,18 @@
# Copyright (C) 2022 Nitrokey GmbH
# SPDX-License-Identifier: CC0-1.0
FROM docker.io/rust:latest
RUN apt update && apt install --yes scdaemon libclang-dev llvm python3-pip vsmartcard-vpcd pkg-config nettle-dev libpcsclite-dev
RUN rustup component add clippy rustfmt && rustup target add thumbv7em-none-eabi
RUN cargo install cargo-tarpaulin --profile release && rm -rf "$CARGO_HOME"/registry
# initialize cargo cache
RUN cargo search
ENV CARGO_HOME=/app/.cache/cargo
WORKDIR /app
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
+29
View File
@@ -0,0 +1,29 @@
# Copyright (C) 2022 Nitrokey GmbH
# SPDX-License-Identifier: CC0-1.0
-include config.mk
TAG := registry.git.nitrokey.com/nitrokey/piv-authenticator/piv-authenticator-build
DOCKER ?= docker
FUZZ_JOBS?=$(shell nproc)
FUZZ_DURATION?="0"
.PHONY: build
build:
$(DOCKER) build . --tag $(TAG)
.PHONY: push
push:
$(DOCKER) push $(TAG)
.PHONY: run
run:
$(DOCKER) run --interactive --rm --volume "$(PWD)/..:/app" --env RUST_LOG $(TAG) make ci
.PHONY: test
test:
$(DOCKER) run --interactive --rm --volume "$(PWD)/..:/app" --env RUST_LOG $(TAG) make test
.PHONY: fuzz
fuzz:
$(DOCKER) run --interactive --rm --volume "$(PWD)/..:/app" --env RUST_LOG $(TAG) make fuzz FUZZ_JOBS=${FUZZ_JOBS} FUZZ_DURATION=${FUZZ_DURATION}
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Copyright (C) 2022 Nitrokey GmbH
# SPDX-License-Identifier: CC0-1.0
set -e
mkdir -p /app/.cache
if [ ! -e "$CARGO_HOME" ]
then
cp -r /usr/local/cargo $CARGO_HOME
fi
pcscd
exec "$@"