Skip to content

Commit

Permalink
Fix macOS detection when running standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Oct 17, 2023
1 parent 17b7599 commit f47d918
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,46 @@ jobs:
with:
files: coverage.json

mac-unittest:
name: python${{ matrix.python-version }}
runs-on: macos-latest

strategy:
matrix:
python-version:
- '3.11'

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install test dependencies
run: |
python -m pip install --upgrade tox tox-gh-actions coverage
- name: Run tests
run: tox

- name: Convert coverage information
if: ${{ always() && github.event.repository.owner.login == 'alisw' }}
run: |
coverage combine .tox/coverage.*
# Codecov only understands XML, JSON and LCOV files.
# Apparently, patching os.readlink in unit tests interferes with
# finding some source files, but our source shouldn't be affected, so
# ignore these errors.
coverage json --ignore-errors -o coverage.json
- name: Upload coverage information
if: ${{ always() && github.event.repository.owner.login == 'alisw' }}
uses: codecov/codecov-action@v3
with:
files: coverage.json

lint:
name: lint
runs-on: ubuntu-latest
Expand Down
11 changes: 7 additions & 4 deletions alibuild_helpers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ def format(s, **kwds):
def doDetectArch(hasOsRelease, osReleaseLines, platformTuple, platformSystem, platformProcessor):
if platformSystem == "Darwin":
import platform
if platform.machine() == "x86_64":
return "osx_x86-64"
else:
return "osx_arm64"
processor = platformProcessor
if not processor:
if platform.machine() == "x86_64":
processor = "x86-64"

Check warning on line 140 in alibuild_helpers/utilities.py

View check run for this annotation

Codecov / codecov/patch

alibuild_helpers/utilities.py#L137-L140

Added lines #L137 - L140 were not covered by tests
else:
processor = "arm64"
return "osx_%s" % processor.replace("_", "-")

Check warning on line 143 in alibuild_helpers/utilities.py

View check run for this annotation

Codecov / codecov/patch

alibuild_helpers/utilities.py#L142-L143

Added lines #L142 - L143 were not covered by tests
distribution, version, flavour = platformTuple
distribution = distribution.lower()
# If platform.dist does not return something sensible,
Expand Down
1 change: 1 addition & 0 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@

architecturePayloads = [
['osx_x86-64', False, [], ('','',''), 'Darwin', 'x86-64'],
['osx_arm64', False, [], ('','',''), 'Darwin', 'arm64'],
['slc5_x86-64', False, [], ('redhat', '5.XX', 'Boron'), 'Linux', 'x86-64'],
['slc6_x86-64', False, [], ('centos', '6.X', 'Carbon'), 'Linux', 'x86-64'],
['slc7_x86-64', False, [], ('centos', '7.X', 'Ptor'), 'Linux', 'x86-64'],
Expand Down

0 comments on commit f47d918

Please sign in to comment.