Migrate from setup.py/setup.cfg to pyproject.toml and drop Python 3.7… #279
This file contains 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
name: Tests | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'HinetPy/**' | |
- 'tests/**' | |
- '.github/workflows/tests.yml' | |
pull_request: | |
branches: [main] | |
paths: | |
- 'HinetPy/**' | |
- 'tests/**' | |
- '.github/workflows/tests.yml' | |
jobs: | |
test: | |
name: ${{ matrix.os }} - Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
max-parallel: 1 # Hinet doesn't allow parallel data request | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.12"] | |
os: [macos-latest, ubuntu-latest] | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# fecth all history so that setuptools-scm works | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install -r requirements.txt | |
python -m pip install build pytest>=6.0 pytest-cov coverage[toml] codecov | |
python -m build --sdist | |
python -m pip install dist/* | |
- name: Install win32tools | |
run: | | |
# Download win32tools | |
python -c "from HinetPy import Client; Client('${{ secrets.HINET_USERNAME }}', '${{ secrets.HINET_PASSWORD }}')._get_win32tools()" | |
# Compile and install win32tools | |
tar -xf win32tools.tar.gz && rm win32tools.tar.gz | |
# patch the win2sac source code on macOS | |
if [ "$RUNNER_OS" == "macOS" ]; then sed -i.bak 's/malloc.h/stdlib.h/' win32tools/win2sac.src/s4read_data.c; fi | |
cd win32tools; make; mkdir bin; mv catwin32.src/catwin32 win2sac.src/win2sac_32 bin/; cd .. | |
# Add to PATH | |
echo "${{ github.workspace }}/win32tools/bin" >> $GITHUB_PATH | |
- name: Run tests | |
run: make test | |
env: | |
HINET_USERNAME: ${{ secrets.HINET_USERNAME }} | |
HINET_PASSWORD: ${{ secrets.HINET_PASSWORD }} | |
- name: Upload coverage reports | |
uses: codecov/codecov-action@v3 |