Prechádzať zdrojové kódy

support/testing: add github download helper testing

Back in 2013, a github download helper has been introduced to cope with
changes in github download-URL's [1][2].

Since then a testing infrastructure has been introduced in Buildroot
but no tests has been added to check if the github download helper is
still working.

It was reported recently [3] that the github helper doesn't work anymore
using tags. Buildroot is not the only project having the issue, see
Github feedback discussions [4].

Add tests for direct archive download (archives uploaded by maintainers),
download from a git tag and git hash using the github helper.
Make sure that Buildroot doesn't use BR2_BACKUP_SITE
(http://sources.buildroot.net).

[1] https://bugs.busybox.net/show_bug.cgi?id=6302
[2] c7c7d0697c00e45bcfad15b027f5c66005f4c005
[3] https://bugs.busybox.net/show_bug.cgi?id=14396
[4] https://github.com/github/feedback/discussions/8149

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Romain Naour 3 rokov pred
rodič
commit
1ca6ab6ace

+ 0 - 0
support/testing/tests/download/br2-external/github/Config.in


+ 1 - 0
support/testing/tests/download/br2-external/github/external.desc

@@ -0,0 +1 @@
+name: GITHUB

+ 1 - 0
support/testing/tests/download/br2-external/github/external.mk

@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_GITHUB_PATH)/package/*/*.mk))

+ 3 - 0
support/testing/tests/download/br2-external/github/package/github-helper-hash/github-helper-hash.hash

@@ -0,0 +1,3 @@
+# Locally computed
+sha256  4064739881453831bceeae81af8947cbd6c1fe03e052ac17b82ae5b3360d83f8  github-helper-hash-e2fba6457bd9d9c720540332eaf0c1f8c29eab00.tar.gz
+sha256  9755181e27175cb3510b4da8629caa406fb355a19aa8e7d55f06bf8ab33323c4  COPYING

+ 11 - 0
support/testing/tests/download/br2-external/github/package/github-helper-hash/github-helper-hash.mk

@@ -0,0 +1,11 @@
+################################################################################
+#
+# github-helper-hash
+#
+################################################################################
+
+GITHUB_HELPER_HASH_VERSION = e2fba6457bd9d9c720540332eaf0c1f8c29eab00
+GITHUB_HELPER_HASH_SITE = $(call github,buildroot,buildroot,$(GITHUB_HELPER_HASH_VERSION))
+GITHUB_HELPER_HASH_LICENSE_FILES = COPYING
+
+$(eval $(generic-package))

+ 3 - 0
support/testing/tests/download/br2-external/github/package/github-helper-tag/github-helper-tag.hash

@@ -0,0 +1,3 @@
+# Locally computed
+sha256  959a953bbd91e6ed6db8d63a45a986400878b6bb486455231b2976218301c3d2  github-helper-tag-2021.02.tar.gz
+sha256  9755181e27175cb3510b4da8629caa406fb355a19aa8e7d55f06bf8ab33323c4  COPYING

+ 11 - 0
support/testing/tests/download/br2-external/github/package/github-helper-tag/github-helper-tag.mk

@@ -0,0 +1,11 @@
+################################################################################
+#
+# github-helper-tag
+#
+################################################################################
+
+GITHUB_HELPER_TAG_VERSION = 2021.02
+GITHUB_HELPER_TAG_SITE = $(call github,buildroot,buildroot,$(GITHUB_HELPER_TAG_VERSION))
+GITHUB_HELPER_TAG_LICENSE_FILES = COPYING
+
+$(eval $(generic-package))

+ 3 - 0
support/testing/tests/download/br2-external/github/package/github-release/github-release.hash

@@ -0,0 +1,3 @@
+# Locally computed
+sha256  f4cb17b21928e36ec27de5c5294dea6ec1de4acd7ee6c56d6ecc75319cbcaefa  systemd-bootchart-233.tar.xz
+sha256  dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551  LICENSE.LGPL2.1

+ 12 - 0
support/testing/tests/download/br2-external/github/package/github-release/github-release.mk

@@ -0,0 +1,12 @@
+################################################################################
+#
+# github-release
+#
+################################################################################
+
+GITHUB_RELEASE_VERSION = 233
+GITHUB_RELEASE_SITE = https://github.com/systemd/systemd-bootchart/releases/download/v$(GITHUB_RELEASE_VERSION)
+GITHUB_RELEASE_SOURCE = systemd-bootchart-$(GITHUB_RELEASE_VERSION).tar.xz
+GITHUB_RELEASE_LICENSE_FILES = LICENSE.LGPL2.1
+
+$(eval $(generic-package))

+ 41 - 0
support/testing/tests/download/test_gitforge.py

@@ -0,0 +1,41 @@
+import os
+import shutil
+
+import infra
+
+
+class GitforgeTestBase(infra.basetest.BRConfigTest):
+    config = \
+        """
+        BR2_BACKUP_SITE=""
+        """
+
+    def setUp(self):
+        super(GitforgeTestBase, self).setUp()
+
+    def tearDown(self):
+        self.show_msg("Cleaning up")
+        if self.b and not self.keepbuilds:
+            self.b.delete()
+
+    def check_download(self, package):
+        # store downloaded tarball inside the output dir so the test infra
+        # cleans it up at the end
+        dl_dir = os.path.join(self.builddir, "dl")
+        # enforce we test the download
+        if os.path.exists(dl_dir):
+            shutil.rmtree(dl_dir)
+        env = {"BR2_DL_DIR": dl_dir}
+        self.b.build(["{}-dirclean".format(package),
+                      "{}-legal-info".format(package)],
+                     env)
+
+
+class TestGitHub(GitforgeTestBase):
+    br2_external = [infra.filepath("tests/download/br2-external/github")]
+
+    def test_run(self):
+        self.check_download("github-helper-tag")
+        self.check_download("github-helper-hash")
+        self.check_download("github-release")
+