You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/08/07 07:47:35 UTC

[buildstream] branch tristan/unaliased-sources created (now 91c5b11)

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a change to branch tristan/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 91c5b11  source.py: Raise an error at load time when encountering unresolved source aliases

This branch includes the following new commits:

     new 294befa  types.py: Add a CoreWarning for unaliased sources
     new a890608  source.py: Raise a fatal-able warning when using an unaliased source.
     new 91c5b11  source.py: Raise an error at load time when encountering unresolved source aliases

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[buildstream] 01/03: types.py: Add a CoreWarning for unaliased sources

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 294befa64ebbec5ee635d3cd1f71b331201d15f4
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Aug 7 16:23:19 2021 +0900

    types.py: Add a CoreWarning for unaliased sources
    
    We should be warning the user if they are using unaliased sources, since
    that means they don't have the ability to mirror them or ensure long term
    repeatability of their builds.
    
    This warning should be allowed to be fatal.
---
 src/buildstream/types.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index 4d9effc..120c3c7 100644
--- a/src/buildstream/types.py
+++ b/src/buildstream/types.py
@@ -125,6 +125,11 @@ class CoreWarnings:
     characters in its name.
     """
 
+    UNALIASED_URL = "unaliased-url"
+    """
+    A URL used for fetching a sources was specified without specifying any
+    :ref:`alias <project_source_aliases>`
+    """
 
 class OverlapAction(FastEnum):
     """OverlapAction()

[buildstream] 03/03: source.py: Raise an error at load time when encountering unresolved source aliases

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 91c5b11abcf293d8fa55c87a54c92c8da9386fc7
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Aug 7 16:35:15 2021 +0900

    source.py: Raise an error at load time when encountering unresolved source aliases
    
    This fixes issue #1119
---
 src/buildstream/source.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 4450289..7a7c4f2 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -663,6 +663,16 @@ class Source(Plugin):
                 warning_token=CoreWarnings.UNALIASED_URL,
             )
 
+        # If there is an alias in use, ensure that it exists in the project
+        if alias:
+            project = self._get_project()
+            alias_uri = project.get_alias_uri(alias, first_pass=self.__first_pass)
+            if alias_uri is None:
+                raise SourceError(
+                    "{}: Unable to find alias '{}' for aliased URL: {} sources".format(self, alias, url),
+                    reason="missing-source-alias",
+                )
+
     def get_project_directory(self) -> str:
         """Fetch the project base directory
 

[buildstream] 02/03: source.py: Raise a fatal-able warning when using an unaliased source.

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit a8906083f5c490e534e179363d8c2327af61feab
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Aug 7 16:25:13 2021 +0900

    source.py: Raise a fatal-able warning when using an unaliased source.
    
    We do this at Source.mark_download_url() time, which as a matter of policy,
    must be used at project configure() time if Source.translate_url() is not
    used instead, this should ensure that aliases are verified to be used
    at load time, if not, it is a bug in the respective plugin.
    
    We will not be able to catch unaliased URLs unless they are specified
    in the yaml, for example, if you have not specified all of the submodules
    in use for a git source.
---
 src/buildstream/source.py | 11 ++++++++++-
 src/buildstream/types.py  |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 3268d3a..4450289 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -164,7 +164,7 @@ from typing import Iterable, Iterator, Optional, Tuple, TYPE_CHECKING
 from . import _yaml, utils
 from .node import MappingNode
 from .plugin import Plugin
-from .types import SourceRef, Union
+from .types import SourceRef, Union, CoreWarnings
 from ._exceptions import BstError, ImplError, PluginError
 from .exceptions import ErrorDomain
 from ._loader.metasource import MetaSource
@@ -654,6 +654,15 @@ class Source(Plugin):
                 url
             ), "URL was not seen at configure time: {}".format(url)
 
+        alias = _extract_alias(url)
+
+        # Issue a (fatal-able) warning if the source used a URL without specifying an alias
+        if not alias:
+            self.warn(
+                "{}: Use of unaliased source download URL: {}".format(self, url),
+                warning_token=CoreWarnings.UNALIASED_URL,
+            )
+
     def get_project_directory(self) -> str:
         """Fetch the project base directory
 
diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index 120c3c7..34914df 100644
--- a/src/buildstream/types.py
+++ b/src/buildstream/types.py
@@ -131,6 +131,7 @@ class CoreWarnings:
     :ref:`alias <project_source_aliases>`
     """
 
+
 class OverlapAction(FastEnum):
     """OverlapAction()