fix: resolve ruff linting issues #11
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 | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: '0 0 * * *' # Daily at midnight | |
| permissions: | |
| contents: read | |
| packages: write | |
| issues: write | |
| pull-requests: write | |
| env: | |
| PYTHON_VERSION: "3.x" | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Lint with Ruff | |
| run: ruff check . | |
| - name: Check formatting with Ruff | |
| run: ruff format --check . | |
| - name: Run tests | |
| run: pytest -v --cov=replace_text --cov-report=term-missing | |
| - name: Upload coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.python-version }} | |
| path: htmlcov/ | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Security scan | |
| uses: github/super-linter@v5 | |
| env: | |
| VALIDATE_ALL_CODEBASE: true | |
| DEFAULT_BRANCH: main | |
| integration: | |
| runs-on: ubuntu-latest | |
| needs: [test, security] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run integration tests | |
| run: | | |
| # Test config generation | |
| python -m replace_text.replace_text --generate-config test_dict '{"key1": "value1", "key2": "value2"}' --output test_config.json | |
| cat test_config.json | |
| rm test_config.json | |
| # Test with multiple dictionaries | |
| cat > test_multi.json << 'EOF' | |
| { | |
| "version": "1.0", | |
| "dictionaries": { | |
| "dict1": {"foo": "bar"}, | |
| "dict2": {"hello": "world"} | |
| }, | |
| "ignore_extensions": [], | |
| "ignore_directories": [], | |
| "ignore_file_prefixes": [] | |
| } | |
| EOF | |
| python -m replace_text.replace_text --config test_multi.json --direction 1 --folder . --dict-name dict1 | |
| rm test_multi.json | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| rm -f test_config.json | |
| rm -f test_multi.json | |
| deploy: | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| needs: [test, security, integration] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| generate_release_notes: true | |
| files: | | |
| dist/*.whl | |
| dist/*.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |