diff --git a/.github/worksflows/pr-internal.yml b/.github/worksflows/pr-internal.yml new file mode 100644 index 0000000..8ebb6f3 --- /dev/null +++ b/.github/worksflows/pr-internal.yml @@ -0,0 +1,89 @@ +name: Python SDK Conditional Workflow + +on: + pull_request: + branches: + - main + - dev + push: + branches: + - dev + +jobs: + check_branch_protection: + if: github.event_name == 'pull_request' && github.base_ref == 'main' + runs-on: ubuntu-latest + steps: + - name: Check source branch + run: | + if [[ "${{ github.head_ref }}" != "dev" ]]; then + echo "❌ Pull requests to main branch must come from dev branch" + echo "Current source branch: ${{ github.head_ref }}" + exit 1 + fi + echo "✅ Source branch check passed" + + Timestamp: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + needs: [check_branch_protection] + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main + + pr_build_and_test: + if: github.event_name == 'pull_request' + needs: [Timestamp] + uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-unit-test-workflow.yml@main + with: + sha: ${{ github.event.pull_request.head.sha }} + ENVIRONMENT: "aeneid" + secrets: + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + + push_build_and_test: + if: github.event_name == 'push' + uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-integration-test-workflow.yml@main + with: + sha: ${{ github.sha }} + ENVIRONMENT: "aeneid" + secrets: + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + + lint: + name: Lint and Type Check + runs-on: ubuntu-latest + needs: [Timestamp] + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11"] + steps: + - name: Check out code + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m venv .venv + source .venv/bin/activate + python -m pip install --upgrade pip + pip install -r requirements.txt || exit 1 + pip install ruff black mypy pytest pytest-cov + shell: bash + + - name: Run linting + run: | + source .venv/bin/activate + ruff check . + black --check . + + - name: Run type checking + run: | + source .venv/bin/activate + mypy src tests \ No newline at end of file