forked from spacemonkeygo/openssl
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.gitlab-ci.yml
80 lines (72 loc) · 3.27 KB
/
.gitlab-ci.yml
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
include:
- project: 'Northern.tech/Mender/mendertesting'
file:
- '.gitlab-ci-github-status-updates.yml'
- '.gitlab-ci-check-commits-signoffs.yml'
- '.gitlab-ci-check-golang-static.yml'
stages:
- test
- publish
test:unit:
stage: test
image: golang:1.23
tags:
- mender-qa-worker-generic-light
before_script:
# Install OpenSSL
- apt-get update && apt-get install -yyq liblzma-dev libssl-dev
# Install SoftHSM, OpenSC, GnuTLS
- apt-get install -yyq softhsm2 opensc opensc-pkcs11 libengine-pkcs11-openssl gnutls-bin
- mkdir -p /softhsm/tokens
- echo "directories.tokendir = /softhsm/tokens" > /softhsm/softhsm2.conf
- export SOFTHSM2_CONF=/softhsm/softhsm2.conf
- softhsm2-util --init-token --free --label unittoken1 --pin 0001 --so-pin 0002 --slot 0
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so -l -k --key-type rsa:2048 --id 0003 --label unittestkey0 --pin 0001
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --show-info
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-slots
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-token-slots
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-mechanisms
- pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-objects
- p11tool --login --provider=/usr/lib/softhsm/libsofthsm2.so --set-pin=0001 --list-all
- export TEST_KEY_URI=`p11tool --login --provider=/usr/lib/softhsm/libsofthsm2.so --set-pin=0001 --list-all 2>/dev/null | grep type=private | awk '{print($NF";pin-value=0001");}'`
- echo using $TEST_KEY_URI;
- echo -ne "[openssl_init]\nengines=engine_section\n\n[engine_section]\npkcs11 = pkcs11_section\n\n[pkcs11_section]\nengine_id = pkcs11\nMODULE_PATH = /usr/lib/softhsm/libsofthsm2.so\ninit = 0\n" >> /etc/ssl/openssl.cnf
- openssl req -new -x509 -subj "/CN=MenderUnits" -engine pkcs11 -keyform engine -key "${TEST_KEY_URI}" -out cert.pem
- export TEST_KEY_URI=`p11tool --login --provider=/usr/lib/softhsm/libsofthsm2.so --set-pin=0001 --list-all 2>/dev/null | grep type=private | awk '{print($NF";pin-value=0001");}'`
script:
# Install JUnit test reporting formatter
- go install github.com/jstemmer/[email protected]
# Run tests
- go test ./... -v -covermode=atomic -coverprofile=coverage.txt 2>&1 |
tee /dev/stderr |
go-junit-report > test-results.xml || exit $?
artifacts:
expire_in: 2w
paths:
- coverage.txt
reports:
junit: test-results.xml
when: always
publish:unittests:
stage: publish
image: golang:1.23
tags:
- mender-qa-worker-generic-light
dependencies:
- test:unit
before_script:
# Install dependencies
- go install github.com/mattn/[email protected]
# Coveralls env variables:
# According to https://docs.coveralls.io/supported-ci-services
# we should set CI_NAME, CI_BUILD_NUMBER, etc. But according
# to goveralls source code (https://github.com/mattn/goveralls)
# many of these are not supported. Set CI_BRANCH,
# and pass few others as command line arguments.
# See also https://docs.coveralls.io/api-reference
- export CI_BRANCH=${CI_COMMIT_BRANCH}
script:
- goveralls
-coverprofile coverage.txt
-service gitlab-ci
-jobid $CI_PIPELINE_ID