Fix linter workflow. #242
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: Build and Test Package | |
on: [push, pull_request] | |
jobs: | |
build-sdist: | |
name: Build Source Dist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Tools | |
run: | | |
pip install build | |
- name: Source Packaging | |
run: | | |
python -m build --sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: sdist | |
path: 'dist/**' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: test-files | |
path: | | |
spotfire/test/files/** | |
spotfire/requirements.txt | |
test_requirements_*.txt | |
- name: Dynamic Elements | |
id: dynamic | |
run: | | |
echo -n "test-envs=[" >> $GITHUB_OUTPUT | |
ls test_requirements_* | sed -e 's/test_requirements_/"/' -e 's/.txt/"/' | tr '\n' ',' | sed -e 's/,$//' >> $GITHUB_OUTPUT | |
echo "]" >> $GITHUB_OUTPUT | |
echo -n "pythons=" >> $GITHUB_OUTPUT | |
cat .github/python-versions.json >> $GITHUB_OUTPUT | |
outputs: | |
test-environments: ${{ steps.dynamic.outputs.test-envs }} | |
python-versions: ${{ steps.dynamic.outputs.pythons }} | |
build-wheel: | |
name: Build Wheels | |
needs: build-sdist | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
matrix: | |
python-version: ${{ fromJson(needs.build-sdist.outputs.python-versions) }} | |
operating-system: ['ubuntu-latest', 'windows-latest'] | |
fail-fast: false | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: sdist | |
path: dist | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Build Requirements | |
run: | | |
pip install auditwheel build setuptools | |
- name: Build Wheel (Linux) | |
if: matrix.operating-system == 'ubuntu-latest' | |
run: | | |
# Unpack sdist | |
tar xzf dist/spotfire-*.tar.gz | |
cd spotfire-* | |
# Build wheel | |
python -m build --wheel | |
# Convert wheel to manylinux | |
auditwheel repair -w ../dist --plat manylinux2014_x86_64 dist/*.whl | |
- name: Build Wheel (Windows) | |
if: matrix.operating-system == 'windows-latest' | |
run: | | |
# Unpack sdist | |
tar xzf $((dir dist\spotfire-*.tar.gz).FullName) | |
cd spotfire-* | |
# Build wheel | |
python -m build --wheel | |
# Move wheel out of build dir into top-level dist dir | |
mv dist\*.whl ..\dist | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheel-${{ matrix.python-version }}-${{ matrix.operating-system }} | |
path: 'dist/*.whl' | |
test: | |
name: Test | |
needs: [build-sdist, build-wheel] | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
matrix: | |
python-version: ${{ fromJson(needs.build-sdist.outputs.python-versions) }} | |
operating-system: ['ubuntu-latest', 'windows-latest'] | |
test-environment: ${{ fromJson(needs.build-sdist.outputs.test-environments) }} | |
fail-fast: false | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheel-${{ matrix.python-version }}-${{ matrix.operating-system }} | |
path: dist | |
- uses: actions/download-artifact@v3 | |
with: | |
name: test-files | |
path: test-files | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies (Linux) | |
if: matrix.operating-system == 'ubuntu-latest' | |
run: | | |
pip install dist/*.whl -r test-files/test_requirements_${{ matrix.test-environment }}.txt | |
- name: Install Dependencies (Windows) | |
if: matrix.operating-system == 'windows-latest' | |
run: | | |
pip install $((dir dist\*.whl).FullName) -r test-files/test_requirements_${{ matrix.test-environment }}.txt | |
- name: Run Tests | |
run: | | |
python -m spotfire.test | |
env: | |
TEST_FILES_DIR: ${{ github.workspace }}/test-files/spotfire/test/files | |
TEST_ENVIRONMENT: ${{ matrix.test-environment }} | |
- uses: actions/upload-artifact@v3 | |
if: ${{ always() }} | |
with: | |
name: test-results-${{ matrix.python-version }}-${{ matrix.operating-system }}-${{ matrix.test-environment }} | |
path: 'build/test-results/*.html' | |
lint: | |
name: Static Analysis | |
needs: [build-sdist, build-wheel] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Process Python Version | |
id: version | |
run: | | |
echo -n "python-version=" >> $GITHUB_OUTPUT | |
echo '${{ needs.build-sdist.outputs.python-versions }}' | sed -e 's/[^"]*"//' -e 's/".*//' >> $GITHUB_OUTPUT | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ steps.version.outputs.python-version }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: sdist | |
path: dist | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheel-${{ steps.version.outputs.python-version }}-ubuntu-latest | |
path: dist | |
- name: Install Tools | |
run: | | |
pip install `ls dist/*.whl`[lint] | |
- name: Run Analysis Tools | |
run: | | |
tar zxf dist/spotfire-*.tar.gz | |
# Analyses that work on the installed package | |
mv spotfire-*/pyproject.toml . | |
pylint spotfire | |
# Analyses that work on the sources of the package | |
mv spotfire-*/{spotfire,vendor,CPPLINT.cfg} . | |
mypy spotfire | |
cython-lint spotfire vendor | |
find spotfire -name '*_helpers.[ch]' | xargs cpplint --repository=. |