Skip to content

Commit e7bc894

Browse files
committed
Merge branch 'main' into stubs
2 parents e714abb + afe97d3 commit e7bc894

File tree

13 files changed

+49
-245
lines changed

13 files changed

+49
-245
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- main
1212

1313
jobs:
14-
build-cross-platform:
14+
build:
1515
name: test ${{matrix.os}} - ${{matrix.python-version}} - ${{matrix.java-version}}
1616
runs-on: ${{ matrix.os }}
1717
strategy:
@@ -33,79 +33,30 @@ jobs:
3333
java-version: ''
3434

3535
steps:
36-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v4
3737

38-
- uses: actions/setup-python@v3
38+
- uses: actions/setup-python@v5
3939
with:
4040
python-version: ${{matrix.python-version}}
4141

42-
- uses: actions/setup-java@v3
42+
- uses: actions/setup-java@v4
4343
if: matrix.java-version != ''
4444
with:
4545
java-version: ${{matrix.java-version}}
4646
distribution: 'zulu'
4747
cache: 'maven'
4848

49-
- name: Install ScyJava
49+
- name: Set up uv
5050
run: |
5151
python -m pip install --upgrade pip
52-
python -m pip install -e '.[dev]'
52+
python -m pip install uv
5353
54-
- name: Test ScyJava
54+
- name: Run tests
55+
shell: bash
5556
run: |
56-
bin/test.sh --color=yes
57+
bin/test.sh
5758
58-
ensure-clean-code:
59-
runs-on: ubuntu-latest
60-
steps:
61-
- uses: actions/checkout@v2
62-
- uses: actions/setup-python@v3
63-
64-
- name: Lint code
65-
run: |
66-
python -m pip install ruff
67-
ruff check
68-
ruff format --check
69-
70-
- name: Validate pyproject.toml
71-
run: |
72-
python -m pip install validate-pyproject[all]
73-
python -m validate_pyproject pyproject.toml
74-
75-
conda-dev-test:
76-
name: Conda Setup & Code Coverage
77-
runs-on: ubuntu-latest
78-
defaults:
79-
# Steps that rely on the activated environment must be run with this shell setup.
80-
# See https://github.com/marketplace/actions/setup-miniconda#important
81-
run:
82-
shell: bash -l {0}
83-
steps:
84-
- uses: actions/checkout@v2
85-
- name: Cache conda
86-
uses: actions/cache@v4
87-
env:
88-
# Increase this value to reset cache if dev-environment.yml has not changed
89-
CACHE_NUMBER: 0
90-
with:
91-
path: ~/conda_pkgs_dir
92-
key:
93-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('dev-environment.yml') }}
94-
- uses: conda-incubator/setup-miniconda@v3
95-
with:
96-
# Create env with dev packages
97-
auto-update-conda: true
98-
python-version: 3.9
99-
miniforge-version: latest
100-
environment-file: dev-environment.yml
101-
# Activate scyjava-dev environment
102-
activate-environment: scyjava-dev
103-
auto-activate-base: false
104-
# Use mamba for faster setup
105-
use-mamba: true
106-
- name: Test scyjava
107-
run: |
108-
bin/test.sh --cov-report=xml --cov=.
109-
# We could do this in its own action, but we'd have to setup the environment again.
110-
- name: Upload Coverage to Codecov
111-
uses: codecov/codecov-action@v2
59+
- name: Lint code
60+
shell: bash
61+
run: |
62+
bin/lint.sh

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ coverage.xml
2323
# IDEA
2424
.idea/
2525
*.iml
26+
27+
# uv
28+
/.venv/
29+
/uv.lock

Makefile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
help:
22
@echo "Available targets:\n\
33
clean - remove build files and directories\n\
4-
setup - create mamba developer environment\n\
54
lint - run code formatters and linters\n\
65
test - run automated test suite\n\
76
dist - generate release archives\n\
8-
\n\
9-
Remember to 'mamba activate scyjava-dev' first!"
7+
"
108

119
clean:
1210
bin/clean.sh
1311

14-
setup:
15-
bin/setup.sh
16-
1712
check:
1813
@bin/check.sh
1914

2015
lint: check
2116
bin/lint.sh
2217

23-
fmt: check
24-
bin/fmt.sh
25-
2618
test: check
2719
bin/test.sh
2820

2921
dist: check clean
30-
python -m build
31-
32-
.PHONY: test
22+
bin/dist.sh

bin/check.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/sh
22

3-
case "$CONDA_PREFIX" in
4-
*/scyjava-dev)
5-
;;
6-
*)
7-
echo "Please run 'make setup' and then 'mamba activate scyjava-dev' first."
8-
exit 1
9-
;;
10-
esac
3+
if ! command -v uv >/dev/null 2>&1; then
4+
echo "Please install uv (https://docs.astral.sh/uv/getting-started/installation/)."
5+
exit 1
6+
fi

bin/setup.sh renamed to bin/dist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
dir=$(dirname "$0")
44
cd "$dir/.."
55

6-
mamba env create -f dev-environment.yml
6+
uv run python -m build

bin/fmt.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/lint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ dir=$(dirname "$0")
44
cd "$dir/.."
55

66
exitCode=0
7-
ruff check
7+
8+
# Check for errors and capture non-zero exit codes.
9+
uv run validate-pyproject pyproject.toml
10+
code=$?; test $code -eq 0 || exitCode=$code
11+
uv run ruff check >/dev/null 2>&1
812
code=$?; test $code -eq 0 || exitCode=$code
9-
ruff format --check
13+
uv run ruff format --check >/dev/null 2>&1
1014
code=$?; test $code -eq 0 || exitCode=$code
11-
validate-pyproject pyproject.toml
15+
16+
# Do actual code reformatting.
17+
uv run ruff check --fix
1218
code=$?; test $code -eq 0 || exitCode=$code
19+
uv run ruff format
20+
code=$?; test $code -eq 0 || exitCode=$code
21+
1322
exit $exitCode

bin/test.sh

Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# Executes the pytest framework in both JPype and Jep modes.
3+
# Runs the unit tests.
44
#
55
# Usage examples:
66
# bin/test.sh
@@ -13,26 +13,26 @@ dir=$(dirname "$0")
1313
cd "$dir/.."
1414

1515
echo
16-
echo "-------------------------------------------"
17-
echo "| Testing JPype mode (Java inside Python) |"
18-
echo "-------------------------------------------"
16+
echo "----------------------"
17+
echo "| Running unit tests |"
18+
echo "----------------------"
1919

2020
if [ $# -gt 0 ]
2121
then
22-
python -m pytest -p no:faulthandler $@
22+
uv run python -m pytest -v -p no:faulthandler $@
2323
else
24-
python -m pytest -p no:faulthandler tests/
24+
uv run python -m pytest -v -p no:faulthandler tests/
2525
fi
2626
jpypeCode=$?
2727

2828
echo
29-
echo "-------------------------------------------"
30-
echo "| Running integration tests (JPype only) |"
31-
echo "-------------------------------------------"
29+
echo "-----------------------------"
30+
echo "| Running integration tests |"
31+
echo "-----------------------------"
3232
itCode=0
3333
for t in tests/it/*.py
3434
do
35-
python "$t"
35+
uv run python "$t"
3636
code=$?
3737
printf -- "--> %s " "$t"
3838
if [ "$code" -eq 0 ]
@@ -44,64 +44,6 @@ do
4444
fi
4545
done
4646

47-
echo
48-
echo "-------------------------------------------"
49-
echo "| Testing Jep mode (Python inside Java) |"
50-
echo "-------------------------------------------"
51-
52-
# Discern the Jep installation.
53-
site_packages=$(python -c 'import sys; print(next(p for p in sys.path if p.endswith("site-packages")))')
54-
test -d "$site_packages/jep" || {
55-
echo "[ERROR] Failed to detect Jep installation in current environment!" 1>&2
56-
exit 1
57-
}
58-
59-
# We execute the pytest framework through Jep via jgo, so that
60-
# the surrounding JVM includes scijava-table on the classpath.
61-
#
62-
# Arguments to the shell script are translated into an argument
63-
# list to the pytest.main function. A weak attempt at handling
64-
# special characters, e.g. single quotation marks and backslashes,
65-
# is made, but there are surely other non-working cases.
66-
67-
if [ $# -gt 0 ]
68-
then
69-
a=$(echo "$@" | sed 's/\\/\\\\/g') # escape backslashes
70-
a=$(echo "$a" | sed 's/'\''/\\'\''/g') # escape single quotes
71-
a=$(echo "$a" | sed 's/ /'\'','\''/g') # replace space with ','
72-
argString="['-v', '$a']"
73-
else
74-
argString=""
75-
fi
76-
if ! java -version 2>&1 | grep -q '^openjdk version "\(1\.8\|9\|10\|11\|12\|13\|14\|15\|16\)\.'
77-
then
78-
echo "Skipping jep tests due to unsupported Java version:"
79-
java -version || true
80-
jepCode=0
81-
elif [ "$(uname -s)" = "Darwin" ]
82-
then
83-
echo "Skipping jep tests on macOS due to flakiness"
84-
jepCode=0
85-
else
86-
echo "# AUTOGENERATED test file for jep; safe to delete.
87-
import logging, sys, pytest, scyjava
88-
scyjava._logger.addHandler(logging.StreamHandler(sys.stderr))
89-
scyjava._logger.setLevel(logging.INFO)
90-
scyjava.config.set_verbose(2)
91-
result = pytest.main($argString)
92-
if result:
93-
sys.exit(result)
94-
" > jep_test.py
95-
jgo -vv \
96-
-r scijava.public=https://maven.scijava.org/content/groups/public \
97-
-Djava.library.path="$site_packages/jep" \
98-
black.ninia:jep:jep.Run+org.scijava:scijava-table \
99-
jep_test.py
100-
jepCode=$?
101-
rm -f jep_test.py
102-
fi
103-
10447
test "$jpypeCode" -ne 0 && exit "$jpypeCode"
10548
test "$itCode" -ne 0 && exit "$itCode"
106-
test "$jepCode" -ne 0 && exit "$jepCode"
10749
exit 0

codecov.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

dev-environment.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)