diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71d44671d1724a863fe0b4b03538caa352c04d43..df3d18f28aa82401a7d6f4782ed193cb95bd5557 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,76 +11,49 @@ cache: paths: - .cache/pip stages: -# - building -# - linting -# - static-analysis -# - unit-tests + - building + - linting + - static-analysis + - unit-tests - integration-tests -#newline_at_eof: -# stage: linting -# before_script: -# - pip3 install -r devices/test-requirements.txt -# script: -# - flake8 --filename *.sh,*.conf,*.md,*.yml --select=W292 --exclude .tox,.egg-info,docker -#python_linting: -# stage: linting -# script: -# - cd devices -# - tox -e pep8 -#bandit: -# stage: static-analysis -# script: -# - cd devices -# - tox -e bandit -#shellcheck: -# stage: static-analysis -# before_script: -# - sudo apt-get update -# - sudo apt-get install -y shellcheck -# script: -# - shellcheck **/*.sh -#unit_test: -# stage: unit-tests -# before_script: -# - sudo apt-get update -# - sudo apt-get install -y git -# script: -# - cd devices -# - tox -e py37 -integration_test_itango: - stage: integration-tests - allow_failure: true - tags: - - privileged - services: - - name: docker:20.10.8-dind - variables: - DOCKER_TLS_CERTDIR: "/certs" - # Everything below does not work currently, we need a privileged container - # that can run the dind service +newline_at_eof: + stage: linting before_script: - - sudo apt update - - sudo apt install -y docker.io - - export USER=$(id | awk -F'=' '{print $2}' | awk -F'(' '{print $2}' | awk -F')' '{print $1}') - - echo $USER - # - sudo usermod -aG docker $USER - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - pip3 install -r devices/test-requirements.txt script: - - touch /home/$USER/.Xauthority - # || true is necessary to mask error return code from source file - - . bootstrap/etc/lofar20rc.sh || true - # - export HOSTNAME=$(cat /run/systemd/netif/leases/2 | grep ^ADDRESS= | awk -F'=' '{print $2}') - - export HOSTNAME=$(hostname -i) - - echo $HOSTNAME - # - chmod u+x $CI_PROJECT_DIR/sbin/run_integration_test.sh - - $CI_PROJECT_DIR/sbin/run_integration_test.sh + - flake8 --filename *.sh,*.conf,*.md,*.yml --select=W292 --exclude .tox,.egg-info,docker +python_linting: + stage: linting + script: + - cd devices + - tox -e pep8 +bandit: + stage: static-analysis + script: + - cd devices + - tox -e bandit +shellcheck: + stage: static-analysis + before_script: + - sudo apt-get update + - sudo apt-get install -y shellcheck + script: + - shellcheck **/*.sh +unit_test: + stage: unit-tests + before_script: + - sudo apt-get update + - sudo apt-get install -y git + script: + - cd devices + - tox -e py37 integration_test_docker: stage: integration-tests - image: docker:20.10.8 + image: docker:latest tags: - privileged services: - - name: docker:20.10.8-dind + - name: docker:dind variables: DOCKER_TLS_CERTDIR: "/certs" before_script: @@ -91,48 +64,15 @@ integration_test_docker: - touch /root/.Xauthority # Hack BASH_SOURCE into sourced files, docker its sh shell won't set this - export BASH_SOURCE=$(pwd)/bootstrap/etc/lofar20rc.sh -# Hack HOSTNAME env variable into an ip address with externally reachable gateway +# Hack HOSTNAME env variable into host.docker.internal, set in docker-compose - export HOSTNAME=host.docker.internal # - export HOSTNAME=$(hostname -i) +# - export HOSTNAME=$(cat /run/systemd/netif/leases/2 | grep ^ADDRESS= | awk -F'=' '{print $2}') +# source the lofarrc file and mask its non zero exit code - . bootstrap/etc/lofar20rc.sh || true # TANGO_HOST must be unset our databaseds will be unreachable - unset TANGO_HOST -# - export HOSTNAME=$(cat /run/systemd/netif/leases/2 | grep ^ADDRESS= | awk -F'=' '{print $2}') - - echo $HOSTNAME - - echo $CI_BUILD_ID - - echo $CI_JOB_ID - - echo $CONTAINER_NAME_PREFIX +# Allow integration test to execute - chmod u+x $CI_PROJECT_DIR/sbin/run_integration_test.sh +# Do not remove 'bash' or statement will be ignored by primitive docker shell - bash $CI_PROJECT_DIR/sbin/run_integration_test.sh -# - cd docker-compose -# - make start itango -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango sudo apt update -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango sudo apt install nmap -y -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango nmap host.docker.internal -# - dig $HOSTNAME -# - echo $HOSTNAME -# - echo $LOFAR20_DIR -# - echo $CI_JOB_ID -# - echo $TANGO_HOST -# - ifconfig -# - ip address -# - route -# - cd docker-compose -# - make start itango -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango sudo apt update -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango sudo apt install nmap -y -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango nmap host.docker.internal -# - docker exec -i ${CONTAINER_NAME_PREFIX}itango nmap $(hostname -i) -# - sed -i "s/sdptr-sim/${CONTAINER_NAME_PREFIX}sdptr-sim/" CDB/integration_ConfigDb.json -# - sed -i "s/pypcc-sim/${CONTAINER_NAME_PREFIX}pypcc-sim/" CDB/integration_ConfigDb.json -# - cat CDB/integration_ConfigDb.json -# - bash $CI_PROJECT_DIR/sbin/run_integration_test.sh || true -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp sudo apt update -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp sudo apt install nmap -y -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp nmap ${CONTAINER_NAME_PREFIX}sdptr-sim -p 4840 -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp nmap ${CONTAINER_NAME_PREFIX}recv-sim -p 4842 -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp nmap ${CONTAINER_NAME_PREFIX}device-recv -p 5700 -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp nmap device-recv -p 5700 -# - docker exec -i ${CONTAINER_NAME_PREFIX}device-sdp nmap device-sdp -p 5701 -# - docker exec -i -w ${TANGO_LOFAR_CONTAINER_DIR}/devices ${CONTAINER_NAME_PREFIX}device-sdp tox -e integration || true -# - docker exec -i -w ${TANGO_LOFAR_CONTAINER_DIR}/devices ${CONTAINER_NAME_PREFIX}device-recv tox -e integration