From 01405d6725a25d53581317efebd0ef6f605698e5 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sun, 25 Apr 2021 20:29:53 -0600 Subject: [PATCH] Fix coveralls (#245) * Teach Green to properly emit color on GH Actions Windows runners * Tell coveralls we're running from GitHub * Bump versions of Python we test with * Fix a couple new failing black lints * Consolidate Windows and Posix into one CI file * CI is so quick, let's not fail fast --- .github/workflows/ci-windows.yml | 31 ------------------------------- .github/workflows/ci.yml | 27 ++++++++++++++++----------- green/loader.py | 1 - green/output.py | 11 +++++++---- green/test/test_suite.py | 2 +- 5 files changed, 24 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/ci-windows.yml diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml deleted file mode 100644 index 92f2150..0000000 --- a/.github/workflows/ci-windows.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Windows CI - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - tests: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest] - python-version: [3.6, 3.7, 3.8] - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-optional.txt - - - name: Test - run: python -m green.cmdline -vvv -t green -s 1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15011c6..f7b7ab0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] # Windows is handled in ci-windows.yml - python-version: [3.6, 3.7, 3.8] + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.7, 3.8, 3.9] + fail-fast: false steps: - uses: actions/checkout@v2 @@ -25,22 +26,26 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install . - pip install -r requirements-optional.txt - pip install black virtualenv coveralls + pip install --upgrade -r requirements-optional.txt - name: Lint with black - run: black --check --diff green + run: | + pip install --upgrade black + black --check --diff green + if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' - name: Test - run: ./g -tvvv green + run: python -m green.cmdline -tvvv green + if: matrix.python-version != '3.9' || matrix.os != 'ubuntu-latest' - name: Generate coverage - run: ./g -tr green - if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' + run: | + pip install --upgrade coveralls + ./g -tvvvr green + if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' - name: Coveralls - run: coveralls + run: coveralls --service=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' + if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' diff --git a/green/loader.py b/green/loader.py index 346432d..ec7a132 100644 --- a/green/loader.py +++ b/green/loader.py @@ -191,7 +191,6 @@ def loadTargets(self, targets, file_pattern="test*.py"): return flattenTestSuite(suites) if suites else None def loadTarget(self, target, file_pattern="test*.py"): - """""" debug( "Attempting to load target '{}' with file_pattern '{}'".format( target, file_pattern diff --git a/green/output.py b/green/output.py index 6cfb7a3..d96e82a 100644 --- a/green/output.py +++ b/green/output.py @@ -128,13 +128,16 @@ def __init__( ): self.disable_unidecode = disable_unidecode self.stream = stream - # Ironically, AppVeyor doesn't support windows win32 system calls for - # colors, but it WILL interpret posix ansi escape codes! + # Ironically, Windows CI platforms such as GitHub Actions and AppVeyor don't support windows + # win32 system calls for colors, but it WILL interpret posix ansi escape codes! (The + # opposite of an actual windows command prompt) on_windows = platform.system() == "Windows" - on_appveyor = os.environ.get("APPVEYOR", False) + on_windows_ci = os.environ.get("GITHUB_ACTIONS", False) or os.environ.get( + "APPVEYOR", False + ) if override_appveyor or ( - (on_windows and not on_appveyor) and not disable_windows + (on_windows and not on_windows_ci) and not disable_windows ): # pragma: no cover self.stream = wrap_stream(self.stream, None, None, None, True) # set output is ascii-only diff --git a/green/test/test_suite.py b/green/test/test_suite.py index ab30020..cec41c2 100644 --- a/green/test/test_suite.py +++ b/green/test/test_suite.py @@ -199,7 +199,7 @@ def tearDown(self): del self.stream def test_failedModuleTeardown(self): - """""" + """A failing tearDownModule gets counted as an errored test""" sub_tmpdir = tempfile.mkdtemp(dir=self.tmpdir) fh = open(os.path.join(sub_tmpdir, "test_moduleteardownfailed.py"), "w") fh.write(