Skip to content

Commit

Permalink
Fix Github Actions runners (#465)
Browse files Browse the repository at this point in the history
In the nightly tests, there were some failures.

- In Windows runners, `test_await_latch_with_timeout` was failing
randomly. My assumption is that, due to low time resolution, sometimes
we were getting equal values instead of larger values. I changed
the condition from `>` to `>=`. Also, I changed the failure message
so that, the next time it fails we will see the exact values.

- Removed `python -m pip install --upgrade pip` statements as the Python
runners already have the latest pip available to them. If we try to
upgrade pip to the latest version, for some older Python versions
it fails because those Python versions reached their EOL and pip
no longer tries to maintain compatibility for them.

- Modified the nightly runner so that, when the os is `ubuntu-latest`
and the Python version is `3.4`, we will use `ubuntu-18.04`, as there
is no Python 3.4 binary available in `ubuntu-latest`. Hopefully, we
will drop the support for ancient Python versions, but till that
day, this workaround should work.
  • Loading branch information
mdumandag committed Sep 6, 2021
1 parent 9567289 commit 0d1cc31
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nightly_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- cron: '0 2 * * *'
jobs:
run-tests:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == "ubuntu-latest" && matrix.python-version == "3.4" && "ubuntu-18.04" || matrix.os }}
name: Run tests with Python ${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -25,7 +25,6 @@ jobs:
uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
- name: Run tests
env:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
- name: Run tests
env:
Expand Down Expand Up @@ -61,7 +60,6 @@ jobs:
uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run black
run: |
Expand All @@ -78,7 +76,6 @@ jobs:
uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Generate documentation
working-directory: docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ def test_await_latch_zero_timeout(self):
self.assertFalse(latch.await_latch(0))

def test_await_latch_with_timeout(self):
timeout = 0.1
latch = self.get_latch(1)
start = get_current_timestamp()
self.assertFalse(latch.await_latch(0.1))
self.assertFalse(latch.await_latch(timeout))
time_passed = get_current_timestamp() - start
self.assertTrue(time_passed > 0.1)
self.assertTrue(
time_passed >= timeout,
"Time passed is less than %s, which is %s" % (timeout, time_passed),
)

def test_await_latch_multiple_waiters(self):
latch = self.get_latch(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from tests.hzrc.ttypes import Lang

# time.monotonic() is more consistent since it uses cpu clock rather than system clock. Use it if available.
# time.monotonic() cannot go backwards. Use it if available.
if hasattr(time, "monotonic"):
get_current_timestamp = time.monotonic
else:
Expand Down

0 comments on commit 0d1cc31

Please sign in to comment.