feat(stream): handles over TA-Lib C 0.8.1's streaming API (#757) #343
Workflow file for this run
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
| name: Tests | |
| on: | |
| push: | |
| branches: [ master, dev ] | |
| pull_request: | |
| branches: [ master, dev ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # dev tracks TA-Lib C's dev branch, which has no release yet, so it builds the | |
| # C library from source and the two dev lines move together. master installs | |
| # the published one. Both resolve their ref over the git protocol: the | |
| # action's own "latest" lookup hits api.github.com, which is rate limited per | |
| # runner IP and answers 403 often enough to redden an unrelated PR. | |
| - name: Pick the TA-Lib C to build against | |
| id: talib_c | |
| run: | | |
| set -euo pipefail | |
| if [ "${{ github.base_ref || github.ref_name }}" = "dev" ]; then | |
| SHA=$(git ls-remote https://github.com/TA-Lib/ta-lib.git refs/heads/dev | cut -f1) | |
| [ -n "$SHA" ] || { echo "::error::cannot resolve ta-lib dev"; exit 1; } | |
| echo "dev=true" >> "$GITHUB_OUTPUT" | |
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | |
| else | |
| VERSION=$(git ls-remote --tags --refs --sort=-v:refname \ | |
| https://github.com/TA-Lib/ta-lib.git 'v*' \ | |
| | sed 's#.*refs/tags/v##' | grep -E '^[0-9.]+$' | head -1) | |
| [ -n "$VERSION" ] || { echo "::error::cannot resolve a ta-lib release"; exit 1; } | |
| echo "dev=false" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Set up TA-Lib | |
| if: steps.talib_c.outputs.dev == 'false' | |
| uses: TA-Lib/setup-ta-lib@v1 | |
| with: | |
| version: ${{ steps.talib_c.outputs.version }} | |
| - name: Cache TA-Lib C dev | |
| if: steps.talib_c.outputs.dev == 'true' | |
| id: talib_c_cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ta-lib-c | |
| key: ta-lib-c-${{ runner.os }}-${{ steps.talib_c.outputs.sha }} | |
| - name: Build TA-Lib C dev | |
| if: steps.talib_c.outputs.dev == 'true' && steps.talib_c_cache.outputs.cache-hit != 'true' | |
| run: | | |
| set -euo pipefail | |
| # the exact commit the cache key names, so a cache hit and a build agree | |
| git init -q ta-lib-c-src | |
| git -C ta-lib-c-src remote add origin https://github.com/TA-Lib/ta-lib.git | |
| git -C ta-lib-c-src fetch -q --depth 1 origin ${{ steps.talib_c.outputs.sha }} | |
| git -C ta-lib-c-src checkout -q FETCH_HEAD | |
| cmake -S ta-lib-c-src -B ta-lib-c-build -DCMAKE_BUILD_TYPE=Release \ | |
| -DBUILD_DEV_TOOLS=OFF -DCMAKE_INSTALL_PREFIX="$PWD/ta-lib-c" | |
| cmake --build ta-lib-c-build -j"$(nproc)" | |
| cmake --install ta-lib-c-build | |
| - name: Use TA-Lib C dev | |
| if: steps.talib_c.outputs.dev == 'true' | |
| run: | | |
| echo "TA_INCLUDE_PATH=$PWD/ta-lib-c/include" >> "$GITHUB_ENV" | |
| echo "TA_LIBRARY_PATH=$PWD/ta-lib-c/lib" >> "$GITHUB_ENV" | |
| echo "LD_LIBRARY_PATH=$PWD/ta-lib-c/lib:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip wheel setuptools | |
| pip install -r requirements_test.txt | |
| pip install flake8 | |
| - name: Build cython modules in-place | |
| run: | | |
| python setup.py build_ext --inplace | |
| - name: Lint with flake8 | |
| run: | | |
| # stop the build if there are Python syntax errors or undefined names | |
| flake8 talib --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
| #flake8 talib --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Test with pytest | |
| run: | | |
| PYTHONPATH=. pytest |