Reorganize and enhance blockchain repository #1
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: Blockchain CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop, claude/** ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| name: Test on Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run tests with pytest | |
| run: | | |
| pytest -v --cov=blockchain_core --cov-report=xml --cov-report=term | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| lint: | |
| name: Lint and Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 black pylint mypy | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 blockchain_core --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings | |
| flake8 blockchain_core --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | |
| - name: Check formatting with black | |
| run: | | |
| black --check blockchain_core tests examples | |
| - name: Lint with pylint | |
| run: | | |
| pylint blockchain_core --exit-zero | |
| - name: Type check with mypy | |
| run: | | |
| mypy blockchain_core --ignore-missing-imports --no-strict-optional || true | |
| security: | |
| name: Security Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install safety bandit | |
| - name: Check for security vulnerabilities | |
| run: | | |
| safety check --json || true | |
| - name: Run bandit security linter | |
| run: | | |
| bandit -r blockchain_core -f json -o bandit-report.json || true | |
| - name: Upload bandit report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: bandit-security-report | |
| path: bandit-report.json | |
| docker: | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t blockchain:${{ github.sha }} . | |
| - name: Test Docker image | |
| run: | | |
| docker run --rm blockchain:${{ github.sha }} python -c "from blockchain_core import Blockchain; print('Docker build successful!')" | |
| examples: | |
| name: Run Examples | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run basic usage example | |
| run: | | |
| python examples/basic_usage.py | |
| - name: Run advanced features example | |
| run: | | |
| python examples/advanced_features.py |