rycus86/demo-site

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
language: python
python:
  - '2.7'

sudo:
  - required
services:
  - docker
install: skip

addons:
  sonarcloud:
    organization: "rycus86-github"
    token:
      secure: "BLkNZOd1D/4a3zuoD//uQK+cAW4JKzLJA3R/QA5GGSAC7Mul00vftdZ7PLJoAY1CM2qTBt+y2g2B6PiwKmTdnI2XRjh8AEtQw1UG8Hg+Z4oGo5p+RQxio/RXIEuE1mMLScTL9tQb8AzWB0Uwl3hl1g1+Gz3XKgFXDQs+AQfsKOG0PO9scNDvbyu3oGgDDV4RbuObmM9bWwfdqjOoDhNzRMztHFen4ChrBEstAb1A83fGAX6ZU/CWKiEPlXrus29TDZ/Qio3mFrNl5e01LpsASyAMAcTFPahUmhv/WuYo9mKFTkOD+DKPFWi3gvNbL/KPn31GNuw5FGpuGmCqRhMjz89Dh/B/OaYxQ6nYQ4E5wa1Y6sWf34vINh9pidEWY3ca82MZjvp5Tlss3OWZ04OHImBBqH+t34cDDOFWGhfzMNV3+KDWJQ6ZiZrAAK8hb5nAZlk+R1gfq/DHAOwGAvtuNU2LLBEg2yO0pPEzeMH4gFRpyHJeJFlKZLpPBy8YkFiIqmEMUdVpyaj5V3ycan2IZDVuKUrcefyOQL/nTq/3YT7QSBd9ZLYCujmQMOYao7kMURuH4ZXqjl8KtamQRqq6Nkg0Psj5s7AgvJoFs078uaRwaWrkPZUmjN3c6aRllAtSkJjZ2jnntOchswB0OVqNr1ogyBVGIYy73CpAewNGxqQ="

jobs:
  include:
    - stage: test
      script:
        # prepare python modules
        - pip install -r requirements.txt
        - pip install nose2 coverage pylint coveralls
        # prepare reporters
        - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
        - chmod +x ./cc-test-reporter
        - curl -fsSL https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | tar -zxvf- -C .
        - ./testspace config url rycus86.testspace.com
        # python tests
        - |
          nose2 -v \
            --plugin nose2.plugins.junitxml --junit-xml \
            --with-coverage --coverage-report xml --coverage-report term-missing
      after_success:
        # coverage reports
        - |
          if [[ "$(python --version 2>&1)" = *2.7* ]]; then
            coveralls || exit 0
            ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || exit 0
            ./testspace nose2-junit.xml coverage.xml
            pylint src/*.py -r n \
              --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
              | tee pylint-report.txt ; echo -n
            sonar-scanner -Dsonar.projectKey=demo-site -Dsonar.sources=src \
              -Dsonar.python.xunit.reportPath=nose2-junit.xml \
              -Dsonar.python.coverage.reportPath=coverage.xml \
              -Dsonar.python.pylint.reportPath=pylint-report.txt
          fi

    - &deploy-stage
      stage: deploy
      if: branch = master
      script:
        - docker run --rm --privileged multiarch/qemu-user-static:register --reset
        - |
          docker build -t demo-site:$DOCKER_TAG       \
            --build-arg GIT_COMMIT=$TRAVIS_COMMIT     \
            --build-arg BUILD_TIMESTAMP=$(date +%s)   \
            -f $DOCKERFILE .
        - docker tag demo-site:$DOCKER_TAG rycus86/demo-site:$DOCKER_TAG
        - echo ${DOCKER_PASSWORD} | docker login --username "rycus86" --password-stdin
      after_success:
        - docker push rycus86/demo-site:$DOCKER_TAG
      env:
        - DOCKER_TAG=amd64
        - DOCKERFILE=Dockerfile

    - <<: *deploy-stage
      env:
        - DOCKER_TAG=armhf
        - DOCKERFILE=Dockerfile.armhf

    - <<: *deploy-stage
      env:
        - DOCKER_TAG=aarch64
        - DOCKERFILE=Dockerfile.aarch64

    - stage: manifest
      if: branch = master
      script:
        - echo ${DOCKER_PASSWORD} | docker login --username "rycus86" --password-stdin
        - curl -fsSL https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 > ./manifest-tool
        - chmod +x ./manifest-tool
        - ./manifest-tool push from-spec manifest.yml