<commit_before># Copyright (c) 2013-2019 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

language: sh
os: linux
dist: xenial


env:
  global:
    - deps_url="https://mbed-os-ci.s3-eu-west-1.amazonaws.com/jenkins-ci/deps"
    - deps_dir="${HOME}/.cache/deps"

cache:
  pip: true
  directories:
    - ${HOME}/.cache/deps


before_install:
  - source tools/test/travis-ci/functions.sh
  - set_status "pending" "Test started."

after_success:
  - set_status "success" "Success!"

after_failure:
  - set_status "failure" "Test failed."


matrix:
  include:
    
    ### Basic Tests ###
    - &basic-vm
      stage: "Basic"
      name: "file attributes"
      env: NAME=gitattributestest
      script:
        - git diff --exit-code

    - <<: *basic-vm
      name: "license check"
      env: NAME=licence_check
      language: python
      python: 3.6.8 # scancode-toolkit v3.1.1 requires v3.6.8
      install:
        - pip install scancode-toolkit==3.1.1
      before_script:
        - mkdir -p SCANCODE
        # Fetch remaining information needed for branch comparison
        - git fetch --all --unshallow --tags
        - git fetch origin "${TRAVIS_BRANCH}"
      script:
        # scancode does not support list of files, only one file or directory
        # we use SCANCODE directory for all changed files (their copies with full tree)
        - >-
            git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
              | ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
              | ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
              | while read file; do cp --parents "${file}" SCANCODE; done
        - scancode -l --json-pp scancode.json SCANCODE
        - python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json || true
      after_success:
        - python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
        - cat scancode-evaluate.log
        - retval=$?
        - |
          if [ $retval == 0 ]; then
              echo "License check OK";
            else
              echo "License check failed, please review license issues found";
              COUNT=$(cat scancode-evaluate.log | grep File: | wc -l)
              STATUSM="Needs review, ${COUNT} license issues found";
              set_status "success" "$STATUSM";
          fi



    - <<: *basic-vm
      name: "include check"<commit_msg>travis: scancode check log instead<commit_after># Copyright (c) 2013-2019 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

language: sh
os: linux
dist: xenial


env:
  global:
    - deps_url="https://mbed-os-ci.s3-eu-west-1.amazonaws.com/jenkins-ci/deps"
    - deps_dir="${HOME}/.cache/deps"

cache:
  pip: true
  directories:
    - ${HOME}/.cache/deps


before_install:
  - source tools/test/travis-ci/functions.sh
  - set_status "pending" "Test started."

after_success:
  - set_status "success" "Success!"

after_failure:
  - set_status "failure" "Test failed."


matrix:
  include:
    
    ### Basic Tests ###
    - &basic-vm
      stage: "Basic"
      name: "file attributes"
      env: NAME=gitattributestest
      script:
        - git diff --exit-code

    - <<: *basic-vm
      name: "license check"
      env: NAME=licence_check
      language: python
      python: 3.6.8 # scancode-toolkit v3.1.1 requires v3.6.8
      install:
        - pip install scancode-toolkit==3.1.1
      before_script:
        - mkdir -p SCANCODE
        # Fetch remaining information needed for branch comparison
        - git fetch --all --unshallow --tags
        - git fetch origin "${TRAVIS_BRANCH}"
      script:
        # scancode does not support list of files, only one file or directory
        # we use SCANCODE directory for all changed files (their copies with full tree)
        - >-
            git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
              | ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
              | ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
              | while read file; do cp --parents "${file}" SCANCODE; done
        - scancode -l --json-pp scancode.json SCANCODE
        - python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json || true
      after_success:
        - python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
        - cat scancode-evaluate.log
        - COUNT=$(cat scancode-evaluate.log | grep 'File:' | wc -l)
        - |
          if [ $COUNT == 0 ]; then
              echo "License check OK";
            else
              echo "License check failed, please review license issues found";
              STATUSM="Needs review, ${COUNT} license issues found";
              set_status "success" "$STATUSM";
          fi



    - <<: *basic-vm
      name: "include check"
{'fraction_non_alphanumeric': 0.11441256830601093, 'fraction_numerical': 0.009904371584699454, 'mean_word_length': 2.2684151785714284, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5670358', 'n_tokens_mistral': 1837, 'n_tokens_neox': 1784, 'n_words': 556}