Repository navigation
chore(deps): update sphinx requirement from >=7.4.7 to >=8.1.3 #142
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
| name: Python package | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| name: Build test on (${{ matrix.python-version }}, ${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 60 | |
| # Push gh-pages + optional PR comments from github-action-benchmark (replaces PAT secrets.CI_TOKEN) | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| MPLBACKEND: Agg | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["ubuntu-latest"] | |
| python-version: ["3.9"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set Python default encoding to utf-8 on Windows | |
| run: | | |
| echo "import sys; sys.stdout.reconfigure(encoding='utf-8')" > sitecustomize.py | |
| if: matrix.os == 'windows-latest' | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install poetry | |
| for i in 1 2 3; do | |
| poetry install && break | |
| if [ "$i" -eq 3 ]; then | |
| exit 1 | |
| fi | |
| echo "poetry install failed, retrying ($i/3)..." | |
| sleep 10 | |
| done | |
| - name: Lint with flake8 | |
| run: | | |
| # stop the build if there are Python syntax errors or undefined names | |
| poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
| poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | |
| - name: Benchmark sanity check | |
| shell: bash | |
| run: | | |
| poetry run python - <<'PY' | |
| import os | |
| import time | |
| import numpy as np | |
| import shapely | |
| import cnmaps | |
| import cnmaps.maps as maps_module | |
| import cnmaps_data | |
| from cnmaps import get_adm_maps | |
| from cnmaps.sample import load_dem | |
| mapcase_dir = os.path.join(os.getcwd(), "tests", "mapcase") | |
| print("python", os.sys.version, flush=True) | |
| print("shapely", shapely.__version__, flush=True) | |
| print("cnmaps", cnmaps.__version__, flush=True) | |
| print("cnmaps_data", cnmaps_data.__version__, flush=True) | |
| print( | |
| "contains_xy_impl", | |
| getattr(maps_module._contains_xy, "__module__", repr(maps_module._contains_xy)), | |
| flush=True, | |
| ) | |
| print("loading country polygons...", flush=True) | |
| n = 20 | |
| lon = np.linspace(60, 150, n) | |
| lat = np.linspace(0, 60, n) | |
| lons, lats = np.meshgrid(lon, lat) | |
| china_gcj02 = get_adm_maps(country="中国", level="国", record="first", only_polygon=True, wgs84=False) | |
| china_wgs84 = get_adm_maps(country="中国", level="国", record="first", only_polygon=True, wgs84=True) | |
| def make_maskout_array_core(): | |
| china_gcj02.make_mask_array(lons, lats) | |
| china_wgs84.make_mask_array(lons, lats) | |
| print("loading province polygon and sample data...", flush=True) | |
| map_polygon_gcj02 = get_adm_maps( | |
| province="宁夏回族自治区", only_polygon=True, record="first", wgs84=False | |
| ) | |
| map_polygon_wgs84 = get_adm_maps( | |
| province="宁夏回族自治区", only_polygon=True, record="first", wgs84=True | |
| ) | |
| dem_lons, dem_lats, dem = load_dem() | |
| dem = dem[100:120, 150:170] | |
| dem_lons = dem_lons[100:120, 150:170] | |
| dem_lats = dem_lats[100:120, 150:170] | |
| def maskout_core(): | |
| map_polygon_gcj02.maskout(dem_lons, dem_lats, dem) | |
| map_polygon_gcj02.maskout(dem_lons, dem_lats, dem.data) | |
| map_polygon_wgs84.maskout(dem_lons, dem_lats, dem) | |
| map_polygon_wgs84.maskout(dem_lons, dem_lats, dem.data) | |
| print("running make_maskout_array_core sample...", flush=True) | |
| start = time.perf_counter() | |
| make_maskout_array_core() | |
| make_maskout_array_elapsed = time.perf_counter() - start | |
| print("make_maskout_array_core_seconds_per_call", make_maskout_array_elapsed, flush=True) | |
| if make_maskout_array_elapsed > 0: | |
| print("make_maskout_array_core_iter_per_sec", 1 / make_maskout_array_elapsed, flush=True) | |
| print("running maskout_core sample...", flush=True) | |
| start = time.perf_counter() | |
| maskout_core() | |
| maskout_elapsed = time.perf_counter() - start | |
| print("maskout_core_seconds_per_call", maskout_elapsed, flush=True) | |
| if maskout_elapsed > 0: | |
| print("maskout_core_iter_per_sec", 1 / maskout_elapsed, flush=True) | |
| PY | |
| - name: Run tests and collect benchmark | |
| run: | | |
| poetry run pytest --verbose -p no:warnings -m "not heavy" --benchmark-json output.json ./tests/test_perf.py | |
| - name: Continuous Benchmark | |
| uses: benchmark-action/github-action-benchmark@v1.14.0 | |
| with: | |
| name: cnmaps Benchmark | |
| tool: "pytest" | |
| output-file-path: output.json | |
| github-token: ${{ github.token }} | |
| auto-push: true | |
| alert-threshold: "150%" | |
| comment-on-alert: true | |
| fail-on-alert: false | |
| benchmark-data-dir-path: "performance-v2/" | |
| alert-comment-cc-users: "@clarmy" | |
| - name: Test with pytest | |
| run: | | |
| poetry run pytest --verbose -p no:warnings -m "not heavy" --cov ./tests/test_drawing.py ./tests/test_geo.py ./tests/test_map.py ./tests/test_issues.py | |
| - name: Upload coverage reports to Codecov | |
| run: | | |
| curl -Os https://uploader.codecov.io/latest/linux/codecov | |
| chmod +x codecov | |
| ./codecov -t ${{ secrets.CODECOV_TOKEN }} |