fix: Add write permissions to GITHUB_TOKEN in workflow docs-publish.y… #2817
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
# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501 | |
# | |
# SPDX-License-Identifier: MPL-2.0 | |
name: Python Build | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Python Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11] | |
steps: | |
# Checkout | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
# Setup | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Restore | |
- name: Restore pip cache | |
uses: actions/cache@v2 | |
with: | |
# This path is specific to Ubuntu | |
path: ~/.cache/pip | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
# Install | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install -r requirements.txt | |
# Very limited linting with Flake8 (see setup.cfg for configuration) | |
- name: Lint | |
run: | | |
pip install flake8 | |
# Stop build on a couple more serious violations | |
# See https://flake8.pycqa.org/en/latest/user/error-codes.html for more details | |
flake8 . --count --select=E9,F63,F7,F8 --show-source --statistics | |
# Only print warnings on all other errors | |
flake8 . --count --exit-zero --show-source --statistics | |
# Test | |
- name: Unit test with pytest | |
run: | | |
pip install -r test-requirements.txt | |
pytest --cov-report=xml --cov=openstef/ test/ --junitxml=pytest-report.xml | |
# Fix relative paths in coverage file | |
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057 | |
- name: fix code coverage paths | |
run: | | |
sed -i 's/\/home\/runner\/work\/openstef\/openstef\//\/github\/workspace\//g' coverage.xml | |
# Build | |
- name: Build Python package | |
run: | | |
python setup.py sdist bdist_wheel |