Skip to content

remove old stuff (#76) #7

remove old stuff (#76)

remove old stuff (#76) #7

Workflow file for this run

# This workflow installs Python dependencies, runs tests, and performs linting using flake8.
# It is triggered on push and pull request events for specific files.
name: Python application
env:
# Paths to source files for validation
SRC_PATH: validation/validate_all_configs.py validation/validate_config.py
# Paths to test files for validation
TESTS_PATH: tests/test_validate_all_configs.py tests/test_validate_config.py
on:
# Trigger workflow on push events for specific files
push:
branches: [ "*" ]
paths:
- "validation/validate_all_configs.py"
- "validation/validate_config.py"
- "tests/test_validate_all_configs.py"
- "tests/test_validate_config.py"
# Trigger workflow on pull request events for specific files
pull_request:
branches: [ "*" ]
paths:
- "validation/validate_all_configs.py"
- "validation/validate_config.py"
- "tests/test_validate_all_configs.py"
- "tests/test_validate_config.py"
# Allows manual triggering of the workflow
workflow_dispatch:
# Grants read access to repository contents
permissions:
contents: read
jobs:
# Job to determine if source tests should run
determine-tests:
runs-on: ubuntu-latest
outputs:
# Determines if source tests should run
run-src-tests: ${{ steps.set-output.outputs.run-src-tests }}
steps:
- # Checks out the repository
uses: actions/checkout@v4
- name: Determine tests to run
id: set-output
run: |
if git diff --name-only $(git merge-base HEAD origin/main) | grep -q '^${{ env.SRC_PATH }}/'; then
echo "::set-output name=run-src-tests::true"
else
echo "::set-output name=run-src-tests::false"
fi
# Job to build and test the application
build:
runs-on: ubuntu-latest
needs: determine-tests
steps:
- # Checks out the repository
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
# Specifies Python version
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# Run flake8 linting, excluding the tutorials directory
flake8 --exclude=tutorials/ . --count --select=E9,F63,F7,F82 --show-source --statistics
# Treat all errors as warnings and set line length limit
flake8 --exclude=tutorials/ . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
if [ "${{ needs.determine-tests.outputs.run-src-tests }}" == "true" ]; then
# Runs pytest on specified test paths
pytest ${{ env.TESTS_PATH }}/
fi