diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a3a58d1f..056dd11b 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -13,7 +13,8 @@ name: Check PR branches: - main -permissions: {} +permissions: + contents: read jobs: unittest: @@ -33,6 +34,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 @@ -78,6 +81,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/tests/test_analytics.py b/tests/test_analytics.py index f7352285..65919eaa 100644 --- a/tests/test_analytics.py +++ b/tests/test_analytics.py @@ -10,6 +10,7 @@ def yesAnalytics(): def notInvoked() -> None: assert(False) +@unittest.skip("Analytics are currently disabled") class TestAnalytics(unittest.TestCase): def test_analytics(self) -> None: self.assertEqual(False, decideAnalytics(hasDisableFile=False, diff --git a/tests/test_packagelist.py b/tests/test_packagelist.py index 4a61602b..e762f429 100644 --- a/tests/test_packagelist.py +++ b/tests/test_packagelist.py @@ -1,6 +1,8 @@ from textwrap import dedent +import os import unittest from unittest import mock +from unittest.mock import patch import tempfile from bits_helpers.cmd import getstatusoutput @@ -79,7 +81,7 @@ } class MockReader: - def __init__(self, url, dist=None): + def __init__(self, url, dist=None, genPackages=None): self._contents = RECIPES[url] self.url = "mock://" + url diff --git a/tests/test_utilities.py b/tests/test_utilities.py index c8f2c321..c8d14220 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -5,7 +5,7 @@ # Assuming you are using the mock library to ... mock things from unittest.mock import patch -from bits_helpers.utilities import doDetectArch, filterByArchitectureDefaults, disabledByArchitectureDefaults, getPkgDirs +from bits_helpers.utilities import doDetectArch, filterByArchitectureDefaults, disabledByArchitectureDefaults from bits_helpers.utilities import Hasher from bits_helpers.utilities import asList from bits_helpers.utilities import prunePaths @@ -13,6 +13,7 @@ from bits_helpers.utilities import topological_sort from bits_helpers.utilities import resolveFilename, resolveDefaultsFilename import bits_helpers +import bits_helpers.log import os import string @@ -282,7 +283,7 @@ def test_cycle(self) -> None: "C": {"package": "C", "requires": ["D"]}, "D": {"package": "D", "requires": ["A"]} } - with patch.object(alibuild_helpers.log, 'error') as mock_error: + with patch.object(bits_helpers.log, 'error') as mock_error: with self.assertRaises(SystemExit) as cm: list(topological_sort(specs)) self.assertEqual(cm.exception.code, 1) diff --git a/tox.ini b/tox.ini index 09a78033..ed18b650 100644 --- a/tox.ini +++ b/tox.ini @@ -59,15 +59,15 @@ changedir = {envtmpdir} commands = # The first coverage command shouldn't have an -a, so we completely replace # the coverage info from the last run. - coverage run --source={toxinidir} {toxinidir}/bitsBuild analytics off - test -e .config/bits/disable-analytics - test ! -e .config/bits/analytics-uuid - coverage run --source={toxinidir} -a {toxinidir}/bitsBuild analytics on - test ! -e .config/bits/disable-analytics - test -e .config/bits/analytics-uuid - coverage run --source={toxinidir} -a {toxinidir}/bitsBuild analytics off - test -e .config/bits/disable-analytics - test -e .config/bits/analytics-uuid + # coverage run --source={toxinidir} {toxinidir}/bitsBuild analytics off + # test -e .config/bits/disable-analytics + # test ! -e .config/bits/analytics-uuid + # coverage run --source={toxinidir} -a {toxinidir}/bitsBuild analytics on + # test ! -e .config/bits/disable-analytics + # test -e .config/bits/analytics-uuid + # coverage run --source={toxinidir} -a {toxinidir}/bitsBuild analytics off + # test -e .config/bits/disable-analytics + # test -e .config/bits/analytics-uuid coverage run --source={toxinidir} -a {toxinidir}/bitsBuild version @@ -90,12 +90,12 @@ commands = sh -c 'coverage run --source={toxinidir} -a {toxinidir}/bitsBuild -c {toxinidir}/tests/testdist build broken6 --force-unknown-architecture --no-system --disable GCC-Toolchain 2>&1 | tee /dev/stderr | grep "while scanning a quoted scalar"' sh -c 'coverage run --source={toxinidir} -a {toxinidir}/bitsBuild -c {toxinidir}/tests/testdist build broken7 --force-unknown-architecture --no-system --disable GCC-Toolchain 2>&1 | tee /dev/stderr | grep "Malformed entry prefer_system"' # This should check that we build different packages depending on the track_env - sh -c 'TRACKED_ENV=foo coverage run --source={toxinidir} -a {toxinidir}/aliBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with foo"' - sh -c 'TRACKED_ENV=bar coverage run --source={toxinidir} -a {toxinidir}/aliBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with bar"' + sh -c 'TRACKED_ENV=foo coverage run --source={toxinidir} -a {toxinidir}/bitsBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with foo"' + sh -c 'TRACKED_ENV=bar coverage run --source={toxinidir} -a {toxinidir}/bitsBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with bar"' # Fake the development package rm -fr tracking-env git clone -b alibuild_CI --depth 1 https://github.com/alisw/alidist tracking-env - sh -c 'TRACKED_ENV=bar coverage run --source={toxinidir} -a {toxinidir}/aliBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with bar"' + sh -c 'TRACKED_ENV=bar coverage run --source={toxinidir} -a {toxinidir}/bitsBuild -c {toxinidir}/tests/testdist build tracking-env --force-unknown-architecture --no-system --disable GCC-Toolchain --debug 2>&1 | tee /dev/stderr | grep "Building with bar"' # Make sure that etc/profile.d/init.sh is re-written properly, even if the package build overwrites it. # In particular, AliEn-Runtime does this, so we must handle this.