Enforcing tests #302
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: Enforcing tests | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
- develop | |
tags: | |
- v* | |
schedule: | |
# Every 01:00 Sunday re-run the test on the main branch | |
- cron: '0 1 * * 0' | |
workflow_dispatch: | |
jobs: | |
testing: | |
runs-on: ubuntu-latest | |
name: Running testing | |
strategy: | |
matrix: | |
app: [pylint, pytest] | |
include: | |
- app: pylint | |
pip_installs: pylint pytest Pillow | |
test_command: (cat action_pylint_files.txt | xargs python3 -m pylint --rcfile ./pylint.rc) && (PP=${PWD} && pushd ./tests && find . | grep '\.py' | PYTHONPATH=${PP} xargs python3 -m pylint -d duplicate-code --rcfile ../pylint.rc && popd ) | |
- app: pytest | |
pip_installs: pytest pytest-cov requests | |
test_command: python3 -m pytest --cov=. -rpP --cov-report=xml | |
artifacts: coverage.txt | |
steps: | |
- name: Current python version | |
run: python3 --version || echo python3 not installed | |
- name: Install Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Updated python version | |
run: | | |
echo "Python version" && python --version | |
echo "Python3 version" && python3 --version | |
- name: PYTHONPATH environment variable | |
run: echo "PYTHONPATH is ${PYTHONPATH}" | |
- name: Update pip | |
run: python3 -m pip install --upgrade --no-cache-dir pip | |
- name: Fetch/update setuptools | |
run: python3 -m pip install --upgrade --no-cache-dir setuptools==58.0.1 | |
- name: Fetch/update testing pip installations | |
run: python3 -m pip install --upgrade --no-cache-dir ${{ matrix.pip_installs }} | |
- name: Fetch source code | |
uses: actions/checkout@v2 | |
- name: Finding files | |
run: find . -type f -name "*.py" | grep -v 'tests/' > action_pylint_files.txt | |
- name: Update apt databases | |
shell: bash | |
run: 'sudo apt-get update' | |
- name: Install system requirements | |
shell: bash | |
run: 'sudo apt-get install -y python3-gdal gdal-bin libgdal-dev gcc g++ python3.8-dev' | |
- name: Install Python numpy and other modules | |
shell: bash | |
run: 'python3 -m pip install --upgrade --no-cache-dir numpy wheel requests' | |
- name: Install Python pygdal | |
shell: bash | |
run: 'python3 -m pip install --no-cache-dir pygdal==3.4.1.*' | |
- name: Install system requirements from source | |
shell: bash | |
run: 'if [ -s "packages.txt" ]; then (cat packages.txt | sudo xargs apt-get install -y --no-install-recommends) || (echo "Failed to install additional packages" && exit 1); fi' | |
- name: Install Python requirements from source | |
shell: bash | |
run: 'if [ -s "requirements.txt" ]; then (python3 -m pip install --no-cache-dir -r requirements.txt) || (echo "Failed to install Python requirements" && exit 1); fi' | |
- name: Run action pylint script | |
shell: bash | |
run: 'if [ -s ".github/workflows/action_pylint.sh" ]; then (chmod +x ".github/workflows/action_pylint.sh" && ./.github/workflows/action_pylint.sh) || (echo "Error running shell script" && exit 1); fi' | |
- name: Fetching pylint.rc file | |
run: wget https://raw.githubusercontent.com/AgPipeline/Organization-info/master/pylint.rc | |
if: ${{ matrix.name }} == "pylint" | |
- name: Set execution permission for testing | |
run: chmod +x betydb2geojson.py | |
- name: Listing | |
run: ls -la | |
- name: Files to be tested | |
run: cat action_pylint_files.txt | |
- name: Running test | |
run: ${{ matrix.test_command }} | |
- name: Upload testing artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: testing_artifacts | |
path: ${{ matrix.artifacts }} | |
if: ${{ matrix.artifacts }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
if: ${{ matrix.app == 'pytest' }} |