| name: CI |
| |
| on: |
| push: |
| branches: |
| - main |
| - 2.* |
| pull_request: ~ |
| |
| env: |
| CACHE_VERSION: 3 |
| DEFAULT_PYTHON: 3.6 |
| PRE_COMMIT_CACHE: ~/.cache/pre-commit |
| |
| jobs: |
| prepare-base: |
| name: Prepare base dependencies |
| runs-on: ubuntu-latest |
| outputs: |
| python-key: ${{ steps.generate-python-key.outputs.key }} |
| pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }} |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| with: |
| fetch-depth: 0 |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Generate partial Python venv restore key |
| id: generate-python-key |
| run: >- |
| echo "::set-output name=key::base-venv-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt') |
| }}" |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: >- |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| steps.generate-python-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}- |
| - name: Create Python virtual environment |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| python -m venv venv |
| . venv/bin/activate |
| python -m pip install -U pip setuptools wheel |
| pip install -U -r requirements_test.txt |
| - name: Generate pre-commit restore key |
| id: generate-pre-commit-key |
| run: >- |
| echo "::set-output name=key::pre-commit-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('.pre-commit-config.yaml') }}" |
| - name: Restore pre-commit environment |
| id: cache-precommit |
| uses: actions/[email protected] |
| with: |
| path: ${{ env.PRE_COMMIT_CACHE }} |
| key: >- |
| ${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-pre-commit-${{ env.CACHE_VERSION }}- |
| - name: Install pre-commit dependencies |
| if: steps.cache-precommit.outputs.cache-hit != 'true' |
| run: | |
| . venv/bin/activate |
| pre-commit install --install-hooks |
| |
| formatting: |
| name: Run pre-commit checks |
| runs-on: ubuntu-latest |
| needs: prepare-base |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-base.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Restore pre-commit environment |
| id: cache-precommit |
| uses: actions/[email protected] |
| with: |
| path: ${{ env.PRE_COMMIT_CACHE }} |
| key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} |
| - name: Fail job if pre-commit cache restore failed |
| if: steps.cache-precommit.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore pre-commit environment from cache" |
| exit 1 |
| - name: Run formatting check |
| run: | |
| . venv/bin/activate |
| pip install -e . |
| pre-commit run pylint --all-files |
| |
| spelling: |
| name: Run spelling checks |
| runs-on: ubuntu-latest |
| needs: prepare-base |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-base.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run spelling checks |
| run: | |
| . venv/bin/activate |
| pytest tests/ -k unittest_spelling |
| |
| prepare-tests-linux: |
| name: Prepare tests for Python ${{ matrix.python-version }} (Linux) |
| runs-on: ubuntu-latest |
| strategy: |
| matrix: |
| python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] |
| outputs: |
| python-key: ${{ steps.generate-python-key.outputs.key }} |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| with: |
| fetch-depth: 0 |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Generate partial Python venv restore key |
| id: generate-python-key |
| run: >- |
| echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt') |
| }}" |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: >- |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| steps.generate-python-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}- |
| - name: Create Python virtual environment |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| python -m venv venv |
| . venv/bin/activate |
| python -m pip install -U pip setuptools wheel |
| pip install -U -r requirements_test.txt |
| |
| pytest-linux: |
| name: Run tests Python ${{ matrix.python-version }} (Linux) |
| runs-on: ubuntu-latest |
| needs: prepare-tests-linux |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-tests-linux.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run pytest |
| run: | |
| . venv/bin/activate |
| pytest --benchmark-disable --cov --cov-report= tests/ |
| - name: Upload coverage artifact |
| uses: actions/upload-[email protected] |
| with: |
| name: coverage-${{ matrix.python-version }} |
| path: .coverage |
| |
| coverage: |
| name: Process test coverage |
| runs-on: ubuntu-latest |
| needs: ["prepare-tests-linux", "pytest-linux"] |
| strategy: |
| matrix: |
| python-version: [3.8] |
| env: |
| COVERAGERC_FILE: .coveragerc |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-tests-linux.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Download all coverage artifacts |
| uses: actions/download-[email protected] |
| - name: Combine coverage results |
| run: | |
| . venv/bin/activate |
| coverage combine coverage*/.coverage |
| coverage report --rcfile=${{ env.COVERAGERC_FILE }} |
| - name: Upload coverage to Coveralls |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| run: | |
| . venv/bin/activate |
| coveralls --rcfile=${{ env.COVERAGERC_FILE }} --service=github |
| |
| benchmark-linux: |
| name: Run benchmark tests Python ${{ matrix.python-version }} (Linux) |
| runs-on: ubuntu-latest |
| needs: prepare-tests-linux |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: [3.8, 3.9] |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-tests-linux.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run pytest |
| run: | |
| . venv/bin/activate |
| pip install pygal |
| pip install -e . |
| pytest --exitfirst \ |
| --benchmark-only \ |
| --benchmark-autosave \ |
| --benchmark-save-data \ |
| --benchmark-group-by="group" |
| - name: Create partial artifact name suffix |
| id: artifact-name-suffix |
| run: >- |
| echo "::set-output name=datetime::"$(date "+%Y%m%d_%H%M") |
| - name: Upload benchmark artifact |
| uses: actions/upload-[email protected] |
| with: |
| name: |
| benchmark-${{ runner.os }}-${{ matrix.python-version }}_${{ |
| steps.artifact-name-suffix.outputs.datetime }} |
| path: .benchmarks/ |
| |
| prepare-tests-windows: |
| name: Prepare tests for Python ${{ matrix.python-version }} (Windows) |
| runs-on: windows-latest |
| strategy: |
| matrix: |
| python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] |
| outputs: |
| python-key: ${{ steps.generate-python-key.outputs.key }} |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| with: |
| fetch-depth: 0 |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Generate partial Python venv restore key |
| id: generate-python-key |
| run: >- |
| echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('setup.cfg', 'requirements_test_min.txt') |
| }}" |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: >- |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| steps.generate-python-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}- |
| - name: Create Python virtual environment |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| python -m venv venv |
| . venv\\Scripts\\activate |
| python -m pip install -U pip setuptools wheel |
| pip install -U -r requirements_test_min.txt |
| |
| pytest-windows: |
| name: Run tests Python ${{ matrix.python-version }} (Windows) |
| runs-on: windows-latest |
| needs: prepare-tests-windows |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] |
| steps: |
| - name: Set temp directory |
| run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV |
| # Workaround to set correct temp directory on Windows |
| # https://github.com/actions/virtual-environments/issues/712 |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-tests-windows.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run pytest |
| run: | |
| . venv\\Scripts\\activate |
| pytest --benchmark-disable tests/ |
| |
| prepare-tests-pypy: |
| name: Prepare tests for Python ${{ matrix.python-version }} |
| runs-on: ubuntu-latest |
| strategy: |
| matrix: |
| python-version: ["pypy3"] |
| outputs: |
| python-key: ${{ steps.generate-python-key.outputs.key }} |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| with: |
| fetch-depth: 0 |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Generate partial Python venv restore key |
| id: generate-python-key |
| run: >- |
| echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('setup.cfg', 'requirements_test_min.txt') |
| }}" |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: >- |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| steps.generate-python-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}- |
| - name: Create Python virtual environment |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| python -m venv venv |
| . venv/bin/activate |
| python -m pip install -U pip setuptools wheel |
| pip install -U -r requirements_test_min.txt |
| |
| pytest-pypy: |
| name: Run tests Python ${{ matrix.python-version }} |
| runs-on: ubuntu-latest |
| needs: prepare-tests-pypy |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: ["pypy3"] |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/[email protected] |
| - name: Set up Python ${{ matrix.python-version }} |
| id: python |
| uses: actions/setup-[email protected] |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/[email protected] |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-tests-pypy.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run pytest |
| run: | |
| . venv/bin/activate |
| pytest --benchmark-disable tests/ |