refactor core domain, file operator, DI, CLI, regex, config versioning #20
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 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Run Bandit (Python security) | |
| run: | | |
| python -m pip install --upgrade pip bandit | |
| bandit -r replace_text -ll | |
| - name: Run gitleaks (secret scanning) | |
| uses: gitleaks/gitleaks-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run actionlint (workflow lint) | |
| run: | | |
| bash <(curl -sSf https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | |
| ./actionlint -color | |
| 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: | | |
| python -m replace_text.replace_text --help | |
| workdir=$(mktemp -d) | |
| echo "hello foo world" > "$workdir/sample.txt" | |
| cat > "$workdir/config.json" << 'EOF' | |
| { | |
| "version": "1.0", | |
| "dictionaries": { | |
| "dict1": {"foo": "bar"} | |
| }, | |
| "ignore_extensions": [], | |
| "ignore_directories": [], | |
| "ignore_file_prefixes": [] | |
| } | |
| EOF | |
| python -m replace_text.replace_text \ | |
| --config "$workdir/config.json" \ | |
| --direction 1 \ | |
| --folder "$workdir" \ | |
| --dict-name dict1 | |
| grep -q "hello bar world" "$workdir/sample.txt" || { echo "replacement failed"; cat "$workdir/sample.txt"; exit 1; } | |
| rm -rf "$workdir" |