Skip to content

Commit 3b8c381

Browse files
committed
Add tests on built wheels
1 parent f8e699d commit 3b8c381

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

Diff for: .ci/osx_ci.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
arm64_set_path_and_python_version(){
5+
python_version="$1"
6+
if [[ $(/usr/bin/arch) = arm64 ]]; then
7+
export PATH=/opt/homebrew/bin:$PATH
8+
eval "$(pyenv init --path)"
9+
pyenv install $python_version -s
10+
pyenv global $python_version
11+
export PATH=$(pyenv prefix)/bin:$PATH
12+
fi
13+
}

Diff for: .github/workflows/create.yml

+112
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,124 @@ jobs:
7777
name: dist
7878
path: dist
7979

80+
test_wheels:
81+
name: Test wheel on ${{ matrix.os }} (${{ matrix.architecture }}) Python ${{ matrix.python }}
82+
if: (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build wheel]') || contains(github.event.pull_request.title, '[build wheel]')
83+
needs:
84+
- build_wheels
85+
continue-on-error: true
86+
strategy:
87+
matrix:
88+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
89+
python: ['3.7', '3.8', '3.9', '3.10']
90+
include:
91+
# We may would like to introduce tests also on windows-latest on x86 (win32 wheels)?
92+
- os: windows-latest
93+
architecture: 'x64'
94+
- os: macos-latest
95+
architecture: 'x64'
96+
- os: ubuntu-latest
97+
architecture: 'x64'
98+
- os: apple-silicon-m1
99+
architecture: 'aarch64'
100+
python: '3.8.13'
101+
- os: apple-silicon-m1
102+
architecture: 'aarch64'
103+
python: '3.9.11'
104+
- os: apple-silicon-m1
105+
architecture: 'aarch64'
106+
python: '3.10.3'
107+
runs-on: ${{ matrix.os }}
108+
steps:
109+
- name: Checkout pyjnius
110+
uses: actions/checkout@v3
111+
112+
- uses: actions/download-artifact@v2
113+
with:
114+
name: dist
115+
path: dist
116+
117+
- name: Setup Python
118+
# Needs to be skipped on our self-hosted runners tagged as 'apple-silicon-m1'
119+
if: ${{ matrix.os != 'apple-silicon-m1' }}
120+
uses: actions/setup-python@v3
121+
with:
122+
python-version: ${{ matrix.python }}
123+
124+
- name: Setup java
125+
uses: actions/setup-java@v3
126+
with:
127+
java-version: '17'
128+
distribution: 'temurin'
129+
architecture: ${{ matrix.architecture }}
130+
131+
- name: Setup ant on macOS
132+
if: (matrix.os == 'macos-latest') || (matrix.os == 'apple-silicon-m1')
133+
run: |
134+
source .ci/osx_ci.sh
135+
arm64_set_path_and_python_version ${{ matrix.python }}
136+
brew install ant
137+
138+
- name: Build test-classes via ant (macOS x64, macOS Apple Silicon)
139+
if: (matrix.os == 'macos-latest') || (matrix.os == 'apple-silicon-m1')
140+
run: |
141+
source .ci/osx_ci.sh
142+
arm64_set_path_and_python_version ${{ matrix.python }}
143+
ant all
144+
145+
- name: Build test-classes via ant (Linux, Windows)
146+
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'windows-latest')
147+
run: ant all
148+
149+
- name: Install pyjnius wheel + test prerequisites (Windows, Linux, macOS x64)
150+
if: matrix.os != 'apple-silicon-m1'
151+
run: python -m pip install --find-links=dist pyjnius pytest
152+
153+
- name: Install pyjnius wheel + test prerequisites (Apple Silicon M1)
154+
if: matrix.os == 'apple-silicon-m1'
155+
run: |
156+
source .ci/osx_ci.sh
157+
arm64_set_path_and_python_version ${{ matrix.python }}
158+
python -m pip install --find-links=dist pyjnius pytest
159+
160+
- name: Test wheel (Linux, macOS x64)
161+
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'macos-latest')
162+
run: |
163+
cd tests
164+
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v
165+
166+
- name: Test wheel (macOS Apple Silicon)
167+
if: matrix.os == 'apple-silicon-m1'
168+
run: |
169+
cd tests
170+
source .ci/osx_ci.sh
171+
arm64_set_path_and_python_version ${{ matrix.python }}
172+
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v
173+
174+
- name: Test wheel (Windows + Python == 3.7.x)
175+
# On Python < 3.8.x, we can't use `os.add_dll_directory`, so the jre should be in PATH.
176+
if: (matrix.os == 'windows-latest') && startsWith(matrix.python, '3.7')
177+
run: |
178+
cd tests
179+
$env:PATH +=";$env:JAVA_HOME\jre\bin\server\;$env:JAVA_HOME\jre\bin\client\;$env:JAVA_HOME\bin\server\"
180+
$env:CLASSPATH ="../build/test-classes;../build/classes"
181+
python -m pytest -v
182+
183+
- name: Test wheel (Windows + Python != 3.7.x )
184+
if: (matrix.os == 'windows-latest') && !startsWith(matrix.python, '3.7')
185+
run: |
186+
cd tests
187+
$env:CLASSPATH ="../build/test-classes;../build/classes"
188+
python -m pytest -v
189+
190+
80191
release:
81192
if: (github.event_name == 'create' && github.event.ref_type == 'tag')
82193
name: release
83194
needs:
84195
- build_wheels
85196
- build_sdist
197+
- test_wheels
86198
runs-on: 'ubuntu-latest'
87199
steps:
88200
- uses: actions/download-artifact@v2

0 commit comments

Comments
 (0)