Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/worksflows/pr-internal.yml
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do integration test in pull_request too? Do we run the test in Aeneid? Also is this reusable workflow for python test?

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lint should run before test

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