Formatting. #15
This file contains hidden or 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: CI - Tandoor Recipe Importer | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [ '3.9', '3.10', '3.11', '3.12' ] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests ruff bandit | |
| sudo apt-get update | |
| sudo apt-get install -y python3-coverage | |
| python --version | |
| pip list | |
| - name: Run syntax check | |
| run: | | |
| python -m py_compile tandoor-importer.py | |
| - name: Run linting with ruff | |
| run: | | |
| ruff check tandoor-importer.py | |
| - name: Run security check with bandit | |
| run: | | |
| bandit tandoor-importer.py | |
| - name: Create test config for coverage | |
| run: | | |
| cp config.conf.example config.conf | |
| sed -i 's|https://your-tandoor-instance.com|https://demo.example.com|g' config.conf | |
| sed -i 's|your_api_token_here|test_token_12345|g' config.conf | |
| - name: Run basic tests with coverage | |
| run: | | |
| # Rename script to make it importable (Python module naming) | |
| cp tandoor-importer.py tandoor_importer.py | |
| # Use whichever coverage command is available | |
| if command -v coverage >/dev/null 2>&1; then | |
| COVERAGE_CMD="coverage" | |
| elif command -v python3-coverage >/dev/null 2>&1; then | |
| COVERAGE_CMD="python3-coverage" | |
| else | |
| echo "No coverage command found" | |
| exit 1 | |
| fi | |
| # Run actual tests that execute the code | |
| $COVERAGE_CMD run --source=. test_basic.py | |
| $COVERAGE_CMD xml | |
| $COVERAGE_CMD report | |
| - name: Upload coverage to Codacy | |
| if: github.event_name == 'push' | |
| uses: codacy/codacy-coverage-reporter-action@v1 | |
| with: | |
| project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
| coverage-reports: coverage.xml | |
| - name: Validate configuration files | |
| run: | | |
| # Check that config example exists and is valid | |
| test -f config.conf.example | |
| python -c "import configparser; c=configparser.ConfigParser(); c.read('config.conf.example'); print('Config example is valid')" |