<commit_before># -*- encoding: utf-8
"""
An important part of our Travis setup is that we skip build jobs where
possible, as this means we can merge pull requests more quickly.
A full build can take nearly two hours across 25 tasks, and that keeps
going up.  This file contains the logic for answering the question:

    Does file X affect build job Y?

"""

import collections
import os

from travistooling.decisions import (
    ChangesToTestsDontGetPublished,
    CheckedByTravisFormat,
    CheckedByTravisLambda,
    ExclusivelyAffectsAnotherTask,
    ExclusivelyAffectsThisTask,
    IgnoredFileFormat,
    IgnoredPath,
    InsignificantFile,
    ScalaChangeAndIsScalaApp,
    ScalaChangeAndNotScalaApp,
    SignificantFile,
    UnrecognisedFile
)
from travistooling.git_utils import ROOT
from travistooling.parse_makefiles import get_projects


# Cache the Makefile information in a global variable, so we only have to
# load it once.
PROJECTS = list(get_projects(ROOT))


def does_file_affect_build_task(path, task):
    # Catch all the common file types that we care about for travis-format.
    if (
        task == 'travis-format' and
        path.endswith(('.scala', '.tf', '.py', '.json', '.ttl'))
    ):
        raise CheckedByTravisFormat()

    # And a quick catch-all of file types that might signify a change for
    # travis-lambda-{test, publish}
    if (
        task.startswith('travis-lambda-') and
        path.endswith(('requirements.txt', '.py'))
    ):
        raise CheckedByTravisLambda()

    # These extensions and paths never have an effect on tests.
    if path.endswith(('.in', '.md', '.png', '.graffle', '.tf', 'Makefile')):
        raise IgnoredFileFormat()

    # These paths never have an effect on tests.
    if path in [
        'LICENSE',
        '.travis.yml',
        'run_travis_task.py',
    ] or path.startswith(('misc/', 'ontologies/', 'data_science/scripts/')):
        raise IgnoredPath()

    # If this is a test file and we're in a publish task, we can skip
    # running the task.
    if task.endswith('-publish') and (

        # Scala test files
        'src/test/scala/uk/ac/wellcome' in path or

        # Python test files
        path.endswith(('conftest.py', '.coveragerc'))
    ):
        raise ChangesToTestsDontGetPublished()<commit_msg>Ignore changes to the run_lambda_tasks.py script<commit_after># -*- encoding: utf-8
"""
An important part of our Travis setup is that we skip build jobs where
possible, as this means we can merge pull requests more quickly.
A full build can take nearly two hours across 25 tasks, and that keeps
going up.  This file contains the logic for answering the question:

    Does file X affect build job Y?

"""

import collections
import os

from travistooling.decisions import (
    ChangesToTestsDontGetPublished,
    CheckedByTravisFormat,
    CheckedByTravisLambda,
    ExclusivelyAffectsAnotherTask,
    ExclusivelyAffectsThisTask,
    IgnoredFileFormat,
    IgnoredPath,
    InsignificantFile,
    ScalaChangeAndIsScalaApp,
    ScalaChangeAndNotScalaApp,
    SignificantFile,
    UnrecognisedFile
)
from travistooling.git_utils import ROOT
from travistooling.parse_makefiles import get_projects


# Cache the Makefile information in a global variable, so we only have to
# load it once.
PROJECTS = list(get_projects(ROOT))


def does_file_affect_build_task(path, task):
    # Catch all the common file types that we care about for travis-format.
    if (
        task == 'travis-format' and
        path.endswith(('.scala', '.tf', '.py', '.json', '.ttl'))
    ):
        raise CheckedByTravisFormat()

    # And a quick catch-all of file types that might signify a change for
    # travis-lambda-{test, publish}
    if (
        task.startswith('travis-lambda-') and
        path.endswith(('requirements.txt', '.py'))
    ):
        raise CheckedByTravisLambda()

    # These extensions and paths never have an effect on tests.
    if path.endswith(('.in', '.md', '.png', '.graffle', '.tf', 'Makefile')):
        raise IgnoredFileFormat()

    # These paths never have an effect on tests.
    if path in [
        'LICENSE',
        '.travis.yml',
        'run_travis_task.py',
        'run_travis_lambdas.py',
    ] or path.startswith(('misc/', 'ontologies/', 'data_science/scripts/')):
        raise IgnoredPath()

    # If this is a test file and we're in a publish task, we can skip
    # running the task.
    if task.endswith('-publish') and (

        # Scala test files
        'src/test/scala/uk/ac/wellcome' in path or

        # Python test files
        path.endswith(('conftest.py', '.coveragerc'))
    ):
        raise ChangesToTestsDontGetPublished()
{'fraction_non_alphanumeric': 0.09716859716859717, 'fraction_numerical': 0.001287001287001287, 'mean_word_length': 3.0653879686137753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3806013', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1398, 'n_words': 459}