diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eca0c0f492c5f1b64eab1b75e806bef2ccc91338..79acfb6aae1f6135287fc0573fe2ab86b417cb42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,59 +1,59 @@ image: golang:1.16 stages: - # - test + - test - build - docker - integration - deploy -# lint: -# stage: test -# script: -# - make lint +lint: + stage: test + script: + - make lint -# unit_tests: -# stage: test -# script: -# - make dep -# - make test -# - gocover-cobertura < coverage.txt > coverage.xml -# artifacts: -# reports: -# cobertura: coverage.xml +unit_tests: + stage: test + script: + - make dep + - make test + - gocover-cobertura < coverage.txt > coverage.xml + artifacts: + reports: + cobertura: coverage.xml -# race: -# stage: test -# script: -# - make race +race: + stage: test + script: + - make race -# coverage: -# stage: test -# script: -# - make coverage -# after_script: -# - mkdir $CI_COMMIT_BRANCH -# - cp cover.html $CI_COMMIT_BRANCH -# - mv $CI_COMMIT_BRANCH/cover.html $CI_COMMIT_BRANCH/index.html +coverage: + stage: test + script: + - make coverage + after_script: + - mkdir $CI_COMMIT_BRANCH + - cp cover.html $CI_COMMIT_BRANCH + - mv $CI_COMMIT_BRANCH/cover.html $CI_COMMIT_BRANCH/index.html -# - if [[ $CI_COMMIT_BRANCH = "develop" || $CI_COMMIT_BRANCH = "main" ]]; then COVERAGE_PATH=""; else COVERAGE_PATH="features"; fi + - if [[ $CI_COMMIT_BRANCH = "develop" || $CI_COMMIT_BRANCH = "main" ]]; then COVERAGE_PATH=""; else COVERAGE_PATH="features"; fi -# # install openssh client and add ssh keys -# - apt-get install openssh-client curl -y >/dev/null -# - mkdir ~/.ssh/ -# - eval $(ssh-agent -s) -# - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa -# - chmod 600 ~/.ssh/id_rsa -# - ssh-add ~/.ssh/id_rsa -# - echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts -# - chmod 644 ~/.ssh/known_hosts -# - ssh -fN -L 1234:science-vs260.science.uu.nl:22 sivan@up.science.uu.nl -# - scp -r -o StrictHostKeyChecking=no -P 1234 -i ~/.ssh/id_rsa $CI_COMMIT_BRANCH root@localhost:/datadisk/documentation-coverage/home/backend/$CI_PROJECT_NAME/$COVERAGE_PATH -# artifacts: -# untracked: false -# expire_in: 30 days -# paths: -# - cover.html + # install openssh client and add ssh keys + - apt-get install openssh-client curl -y >/dev/null + - mkdir ~/.ssh/ + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - ssh-add ~/.ssh/id_rsa + - echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh -fN -L 1234:science-vs260.science.uu.nl:22 sivan@up.science.uu.nl + - scp -r -o StrictHostKeyChecking=no -P 1234 -i ~/.ssh/id_rsa $CI_COMMIT_BRANCH root@localhost:/datadisk/documentation-coverage/home/backend/$CI_PROJECT_NAME/$COVERAGE_PATH + artifacts: + untracked: false + expire_in: 30 days + paths: + - cover.html build: stage: build @@ -90,7 +90,7 @@ integration-tests: only: - develop script: - - apt-get install openssh-client curl -y >/dev/null + - apt-get install openssh-client curl grep -y >/dev/null - mkdir ~/.ssh/ - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa @@ -100,7 +100,7 @@ integration-tests: - chmod 644 ~/.ssh/known_hosts - ssh -fN -L 1234:science-vs260.science.uu.nl:22 sivan@up.science.uu.nl # Delete pod - - ssh -p 1234 -i ~/.ssh/id_rsa root@localhost "kubectl delete -f /root/kubernetes/$CI_PROJECT_NAME/integration/pod.yml" + - ssh -p 1234 -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@localhost "kubectl delete -f /root/kubernetes/$CI_PROJECT_NAME/integration/pod.yml --ignore-not-found=true" # Copy kubernetes files over - scp -r -o StrictHostKeyChecking=no -P 1234 -i ~/.ssh/id_rsa integration-testing/pod.yml root@localhost:/root/kubernetes/$CI_PROJECT_NAME/integration/pod.yml # Deploy all yml files @@ -109,11 +109,10 @@ integration-tests: - sleep 5 # CURL the config json to the integration service and store the response in the environment variable 'output' - | - output=$(curl -k --header "Content-Type: multipart/form-data" --request POST -F "configFile=@integration-testing/config.json;type=application/json" https://datastrophe.science.uu.nl/integration-test/start) + output=$(curl -k --header "Content-Type: multipart/form-data" --request POST -F "configFile=@integration-testing/config.json;type=application/json" https://datastrophe.science.uu.nl/integration-test/start/) - echo $output # Count the number of occurences of the word FAIL in the output, if this is 1 then the test has failed - - count=$(echo $output | grep -c "FAIL") - - if [[ $count = 1 ]]; then exit 1; else exit 0; fi + - echo "$output" | grep -c "SUCCESS" dependencies: [] deploy: diff --git a/integration-testing/config.json b/integration-testing/config.json index 101ee152d7409cb6a84fd3aa4cd0ea4be07e2ff6..53d194ada60944cbd66832683dc13a27bf5a5237 100644 --- a/integration-testing/config.json +++ b/integration-testing/config.json @@ -36,4 +36,4 @@ "redisSet": { "test-session": "ui-consumer-1" } -} \ No newline at end of file +}