|
| 1 | +name: Python unit tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + unit_tests_modern: |
| 9 | + name: Python ${{ matrix.py_version }} unit tests on '${{ matrix.os.name }}' (modern) |
| 10 | + runs-on: ${{ matrix.os.runner }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [ |
| 15 | + { |
| 16 | + name: linux, |
| 17 | + runner: ubuntu-latest, |
| 18 | + find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl" |
| 19 | + }, |
| 20 | + { |
| 21 | + name: macos-arm, |
| 22 | + runner: macos-latest, |
| 23 | + find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl" |
| 24 | + }, |
| 25 | + { |
| 26 | + name: macos-intel, |
| 27 | + runner: macos-15-intel, |
| 28 | + find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl" |
| 29 | + }, |
| 30 | + { |
| 31 | + name: windows, |
| 32 | + runner: windows-latest, |
| 33 | + find_wheel_cmd: Get-ChildItem -Path .\dist\ -Recurse -Filter "rabbitizer-*.whl" |
| 34 | + }, |
| 35 | + ] |
| 36 | + py_version: |
| 37 | + - '3.8' |
| 38 | + - '3.9' |
| 39 | + - '3.10' |
| 40 | + - '3.11' |
| 41 | + - '3.12' |
| 42 | + - '3.13' |
| 43 | + - '3.14' |
| 44 | + - '3.14t' |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@main |
| 49 | + |
| 50 | + - name: Print Python version |
| 51 | + run: | |
| 52 | + python3 --version |
| 53 | +
|
| 54 | + - name: Set up Python ${{ matrix.py_version }} |
| 55 | + uses: actions/setup-python@v6 |
| 56 | + with: |
| 57 | + python-version: ${{ matrix.py_version }} |
| 58 | + |
| 59 | + - name: Install uv |
| 60 | + uses: astral-sh/setup-uv@v7 |
| 61 | + |
| 62 | + - name: Setup Python venv |
| 63 | + run: | |
| 64 | + python3 --version |
| 65 | + uv venv .venv --no-config -p ${{ matrix.py_version }} |
| 66 | + uv run --no-config --no-build --no-sync python --version |
| 67 | +
|
| 68 | + - name: Check Python version |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + uv run --no-config --no-build --no-sync python --version |
| 72 | + # Ensure the installed version is the version we are expecting |
| 73 | + # The version check needs to be `in` to account for free threaded python |
| 74 | + uv run --no-config --no-build --no-sync python -c "import sys; exit(not (str(sys.version_info[0])+'.'+str(sys.version_info[1]) in '${{ matrix.py_version }}'))" |
| 75 | +
|
| 76 | + - name: Build wheel |
| 77 | + run: | |
| 78 | + uv build --wheel |
| 79 | +
|
| 80 | + - name: Install wheel |
| 81 | + run: | |
| 82 | + ${{ matrix.os.find_wheel_cmd }} |
| 83 | + uv pip install --force-reinstall $(${{ matrix.os.find_wheel_cmd }}) |
| 84 | +
|
| 85 | + - name: Run the test |
| 86 | + run: | |
| 87 | + uv run --no-config --no-build --no-sync python tests/python/disasm_test.py |
| 88 | +
|
| 89 | + unit_tests_old: |
| 90 | + name: Python ${{ matrix.py_version }} unit tests on '${{ matrix.os.name }}' (old) |
| 91 | + runs-on: ${{ matrix.os.runner }} |
| 92 | + strategy: |
| 93 | + fail-fast: false |
| 94 | + matrix: |
| 95 | + os: [ |
| 96 | + { |
| 97 | + name: linux, |
| 98 | + runner: ubuntu-latest, |
| 99 | + }, |
| 100 | + { |
| 101 | + name: macos-intel, |
| 102 | + runner: macos-15-intel, |
| 103 | + }, |
| 104 | + { |
| 105 | + name: windows, |
| 106 | + runner: windows-latest, |
| 107 | + }, |
| 108 | + ] |
| 109 | + py_version: |
| 110 | + - '3.5' |
| 111 | + - '3.6' |
| 112 | + - '3.7' |
| 113 | + |
| 114 | + steps: |
| 115 | + - name: Checkout |
| 116 | + uses: actions/checkout@main |
| 117 | + |
| 118 | + - name: Print Python version |
| 119 | + run: | |
| 120 | + python3 --version |
| 121 | +
|
| 122 | + - name: Set up Python ${{ matrix.py_version }} (windows) |
| 123 | + uses: actions/setup-python@v6 |
| 124 | + if: ${{ matrix.os.name == 'windows' }} |
| 125 | + with: |
| 126 | + python-version: ${{ matrix.py_version }} |
| 127 | + |
| 128 | + - name: Set up pyenv (unix) |
| 129 | + if: ${{ matrix.os.name != 'windows' }} |
| 130 | + run: | |
| 131 | + curl -fsSL https://pyenv.run | bash |
| 132 | + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> $GITHUB_ENV |
| 133 | + echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> $GITHUB_ENV |
| 134 | +
|
| 135 | + - name: Set up Python ${{ matrix.py_version }} (unix) |
| 136 | + shell: bash |
| 137 | + if: ${{ matrix.os.name != 'windows' }} |
| 138 | + run: | |
| 139 | + echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV |
| 140 | + echo "$HOME/.pyenv/bin" >> $GITHUB_PATH |
| 141 | + echo "$HOME/.pyenv/shims" >> $GITHUB_PATH |
| 142 | +
|
| 143 | + export PYENV_ROOT="$HOME/.pyenv" |
| 144 | + export PATH="$PYENV_ROOT/bin:$PATH" |
| 145 | +
|
| 146 | + eval "$(pyenv init -)" |
| 147 | +
|
| 148 | + # macos legacy fixes |
| 149 | + export PYTHON_CONFIGURE_OPTS="--without-ensurepip" |
| 150 | + export TMPDIR=/tmp |
| 151 | +
|
| 152 | + if [[ "$RUNNER_OS" == "macOS" ]]; then |
| 153 | + brew install openssl@1.1 || true |
| 154 | +
|
| 155 | + OPENSSL_PREFIX="$(brew --prefix openssl@1.1)" |
| 156 | +
|
| 157 | + export LDFLAGS="-L$OPENSSL_PREFIX/lib" |
| 158 | + export CPPFLAGS="-I$OPENSSL_PREFIX/include" |
| 159 | + export PKG_CONFIG_PATH="$OPENSSL_PREFIX/lib/pkgconfig" |
| 160 | +
|
| 161 | + export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-openssl=$OPENSSL_PREFIX" |
| 162 | + fi |
| 163 | + # macos legacy fixes |
| 164 | +
|
| 165 | + pyenv install -s ${{ matrix.py_version }} |
| 166 | + pyenv global ${{ matrix.py_version }} |
| 167 | + pyenv local ${{ matrix.py_version }} |
| 168 | +
|
| 169 | + python --version |
| 170 | +
|
| 171 | + - name: Check Python version |
| 172 | + shell: bash |
| 173 | + run: | |
| 174 | + python --version |
| 175 | + # Ensure the installed version is the version we are expecting |
| 176 | + python -c "import sys; exit(not (str(sys.version_info[0])+'.'+str(sys.version_info[1]) == '${{ matrix.py_version }}'))" |
| 177 | +
|
| 178 | + # We can't use ensure pip because it breaks macos + python 3.7 |
| 179 | + - name: Install pip manually |
| 180 | + shell: bash |
| 181 | + run: | |
| 182 | + curl -sS https://bootstrap.pypa.io/pip/${{ matrix.py_version }}/get-pip.py -o get-pip.py |
| 183 | + python get-pip.py "pip<24" "setuptools<68" "wheel" |
| 184 | +
|
| 185 | + - name: Build and install wheel |
| 186 | + shell: bash |
| 187 | + run: | |
| 188 | + python -m pip install . |
| 189 | +
|
| 190 | + - name: Run the test |
| 191 | + shell: bash |
| 192 | + run: | |
| 193 | + python tests/python/disasm_test.py |
0 commit comments