From 2d288fac210d1462a1a2edcfe5eeaa0dd4d0fd20 Mon Sep 17 00:00:00 2001 From: Yao Date: Mon, 11 Aug 2025 14:20:46 -0700 Subject: [PATCH] Test workflow trigger --- .github/workflows/release.yml | 186 +++++++++++++++++++++++++ .github/workflows/test-publish.yml | 211 +++++++++++++++++++++++++++++ .github/workflows/test-release.yml | 162 ++++++++++++++++++++++ 3 files changed, 559 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test-publish.yml create mode 100644 .github/workflows/test-release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..cb0891db --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,186 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build-and-release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Cache pip dependencies + 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 build wheel setuptools twine + + - name: Run tests + run: | + pytest tests/ --cov=src/ --cov-report=xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + fail_ci_if_error: false + + - name: Build package + run: | + python -m build + + - name: Verify package + run: | + # Check if package files were created + if [ ! -f "dist/*.whl" ] || [ ! -f "dist/*.tar.gz" ]; then + echo "❌ Package build failed - missing distribution files" + exit 1 + fi + + echo "✅ Package built successfully:" + ls -la dist/ + + - name: Extract version from tag + id: version + run: | + # Remove 'v' prefix from tag + VERSION=${GITHUB_REF#refs/tags/} + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "version_without_v=${VERSION#v}" >> $GITHUB_OUTPUT + echo "Extracted version: ${VERSION} (${VERSION#v})" + + - name: Verify version consistency + run: | + # Check if setup.py version matches tag + SETUP_VERSION=$(grep 'version=' setup.py | sed 's/.*version="\([^"]*\)".*/\1/') + INIT_VERSION=$(grep '__version__' src/story_protocol_python_sdk/__init__.py | sed "s/.*__version__ = \"\([^']*\)\".*/\1/") + TAG_VERSION="${{ steps.version.outputs.version_without_v }}" + + echo "Setup.py version: $SETUP_VERSION" + echo "Init.py version: $INIT_VERSION" + echo "Tag version: $TAG_VERSION" + + if [ "$SETUP_VERSION" != "$TAG_VERSION" ]; then + echo "❌ Setup.py version ($SETUP_VERSION) doesn't match tag version ($TAG_VERSION)" + exit 1 + fi + + if [ "$INIT_VERSION" != "$TAG_VERSION" ]; then + echo "❌ Init.py version ($INIT_VERSION) doesn't match tag version ($TAG_VERSION)" + exit 1 + fi + + echo "✅ Version consistency verified" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + ## What's Changed + This release implements enhancements to improve the functionality of the WIP Module and overall testing coverage. + + ## Features & Enhancements + + ### WIP Module + - Enhanced test coverage for WIP token approval and transferFrom functionality + - Added comprehensive negative test cases for WIP transfers + - Implemented testing with multiple wallet configurations + - Added validation for transfer to zero address and contract address scenarios + + ### Testing Improvements + - Extended integration test coverage + - Added edge case testing for token operations + - Improved error handling validation + - Enhanced test reliability across multiple wallet scenarios + + ## Breaking Changes + None + + ## Installation + ```bash + pip install story_protocol_python_sdk==${{ steps.version.outputs.version_without_v }} + ``` + + ## Development + ```bash + git clone https://github.com/${{ github.repository }}.git + cd python-sdk + git checkout ${{ steps.version.outputs.version }} + pip install -e . + ``` + + ## Changelog + - [Full Changelog](https://github.com/${{ github.repository }}/compare/v0.3.14...${{ steps.version.outputs.version }}) + + ## Assets + This release includes: + - Source distribution (.tar.gz) + - Wheel distribution (.whl) + - Full source code + draft: false + prerelease: ${{ contains(steps.version.outputs.version, 'rc') || contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'beta') }} + + - name: Upload Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/story_protocol_python_sdk-${{ steps.version.outputs.version_without_v }}-py3-none-any.whl + asset_name: story_protocol_python_sdk-${{ steps.version.outputs.version_without_v }}-py3-none-any.whl + asset_content_type: application/zip + + - name: Upload Source Distribution + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/story_protocol_python_sdk-${{ steps.version.outputs.version_without_v }}.tar.gz + asset_name: story_protocol_python_sdk-${{ steps.version.outputs.version_without_v }}.tar.gz + asset_content_type: application/gzip + + - name: Upload Source Code (ZIP) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/story_protocol_python_sdk-${{ steps.version.outputs.version_without_v }}.tar.gz + asset_name: Source code (tar.gz) + asset_content_type: application/gzip + + - name: Success Message + run: | + echo "🎉 Release ${{ steps.version.outputs.version }} created successfully!" + echo "📦 Package built and uploaded" + echo "🏷️ GitHub release created" + echo "📋 Assets uploaded" + echo "" + echo "View release at: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}" diff --git a/.github/workflows/test-publish.yml b/.github/workflows/test-publish.yml new file mode 100644 index 00000000..dc46c523 --- /dev/null +++ b/.github/workflows/test-publish.yml @@ -0,0 +1,211 @@ +name: test publish workflow + +on: + workflow_dispatch: + inputs: + version_type: + type: choice + description: version to be published + options: + - major + - minor + - patch + +jobs: + Timestamp: + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main + + lint: + needs: Timestamp + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + + - name: Run flake8 + run: | + flake8 . + + test: + needs: [Timestamp, lint] + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + pip install -r requirements.txt + python -m pip install --upgrade pip + pip install pytest pytest-cov + + - name: Run tests + run: | + pytest tests/ --cov=src/ --cov-report=xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + fail_ci_if_error: false + + build: + needs: [Timestamp, lint, test] + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + pip install -r requirements.txt + python -m pip install --upgrade pip + pip install setuptools wheel build + + - name: Build package + run: python -m build + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: dist-${{ matrix.python-version }} + path: dist/ + retention-days: 1 + + test-publish: + needs: [Timestamp, build, lint, test] + runs-on: ubuntu-latest + # This job simulates the publish process without actually publishing + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + pip install -r requirements.txt + python -m pip install --upgrade pip + pip install setuptools wheel build + + - name: Simulate version update + env: + VERSION_TYPE: ${{ github.event.inputs.version_type }} + run: | + echo "🧪 TESTING: Would run version update with type: $VERSION_TYPE" + echo "Current branch: $(git branch --show-current)" + echo "Current commit: $(git rev-parse HEAD)" + + # Show what would be changed + if [ -f "update_version.py" ]; then + echo "✅ update_version.py exists and is executable" + python update_version.py --help 2>/dev/null || echo "⚠️ No help available for update_version.py" + else + echo "❌ update_version.py not found" + fi + + - name: Simulate package building + run: | + echo "🧪 TESTING: Would build package for publishing" + python -m build + + # Validate built package + if [ -f dist/*.whl ] && [ -f dist/*.tar.gz ]; then + echo "✅ Package build successful" + ls -la dist/ + else + echo "❌ Package build failed" + exit 1 + fi + + - name: Simulate Git operations + run: | + echo "🧪 TESTING: Would perform Git operations" + echo "Current git status:" + git status --porcelain + + echo "Would commit version changes to setup.py" + echo "Would create git tag" + echo "Would push to current branch: $(git branch --show-current)" + + # Show what files would be committed + if [ -f "setup.py" ]; then + echo "setup.py contents:" + cat setup.py | grep -A 2 -B 2 "version=" || echo "No version field found" + fi + + - name: Simulate PyPI publishing + run: | + echo "🚫 PyPI publishing disabled for testing" + echo "Would publish version: $(grep 'version=' setup.py | sed 's/.*version="\([^"]*\)".*/\1/' 2>/dev/null || echo 'unknown')" + echo "Would push to branch: $(git branch --show-current)" + echo "Would create tag: v$(grep 'version=' setup.py | sed 's/.*version="\([^"]*\)".*/\1/' 2>/dev/null || echo 'unknown')" + + echo "" + echo "🎉 TEST COMPLETED SUCCESSFULLY!" + echo "This workflow simulates the publish process without making actual changes." + echo "To test the real publish workflow, use publish-package.yml on the main branch." + + - name: Cleanup test artifacts + if: always() + run: | + echo "🧹 Cleaning up test artifacts" + rm -rf dist/ build/ *.egg-info/ + echo "Cleanup completed" diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml new file mode 100644 index 00000000..6f94fb08 --- /dev/null +++ b/.github/workflows/test-release.yml @@ -0,0 +1,162 @@ +name: Test Release Workflow + +on: + workflow_dispatch: + inputs: + test_version: + description: 'Test version to simulate (e.g., 0.3.15-rc.1)' + required: true + default: '0.3.15-rc.1' + simulate_release: + description: 'Simulate creating a release?' + type: boolean + default: false + +jobs: + test-release: + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Cache pip dependencies + 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 build wheel setuptools twine + + - name: Run tests + run: | + pytest tests/ --cov=src/ --cov-report=xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + fail_ci_if_error: false + + - name: Build package + run: | + python -m build + + - name: Verify package + run: | + # Check if package files were created + if [ ! -f "dist/*.whl" ] || [ ! -f "dist/*.tar.gz" ]; then + echo "❌ Package build failed - missing distribution files" + exit 1 + fi + + echo "✅ Package built successfully:" + ls -la dist/ + + - name: Extract test version + id: version + run: | + TEST_VERSION="${{ github.event.inputs.test_version }}" + echo "test_version=${TEST_VERSION}" >> $GITHUB_OUTPUT + echo "test_version_without_v=${TEST_VERSION}" >> $GITHUB_OUTPUT + echo "Testing with version: ${TEST_VERSION}" + + - name: Verify version consistency + run: | + # Check if setup.py version matches test version + SETUP_VERSION=$(grep 'version=' setup.py | sed 's/.*version="\([^"]*\)".*/\1/') + INIT_VERSION=$(grep '__version__' src/story_protocol_python_sdk/__init__.py | sed "s/.*__version__ = \"\([^']*\)\".*/\1/") + TEST_VERSION="${{ steps.version.outputs.test_version }}" + + echo "Setup.py version: $SETUP_VERSION" + echo "Init.py version: $INIT_VERSION" + echo "Test version: $TEST_VERSION" + + if [ "$SETUP_VERSION" != "$TEST_VERSION" ]; then + echo "❌ Setup.py version ($SETUP_VERSION) doesn't match test version ($TEST_VERSION)" + echo "⚠️ This is expected if you're testing with a different version" + else + echo "✅ Setup.py version matches test version" + fi + + if [ "$INIT_VERSION" != "$TEST_VERSION" ]; then + echo "❌ Init.py version ($INIT_VERSION) doesn't match test version ($TEST_VERSION)" + echo "⚠️ This is expected if you're testing with a different version" + else + echo "✅ Init.py version matches test version" + fi + + - name: Simulate Release Creation + if: ${{ github.event.inputs.simulate_release }} + run: | + echo "🧪 SIMULATING: Would create GitHub release for version ${{ steps.version.outputs.test_version }}" + echo "🧪 SIMULATING: Would upload assets:" + echo " - story_protocol_python_sdk-${{ steps.version.outputs.test_version }}-py3-none-any.whl" + echo " - story_protocol_python_sdk-${{ steps.version.outputs.test_version }}.tar.gz" + echo "🧪 SIMULATING: Would mark as pre-release: ${{ contains(steps.version.outputs.test_version, 'rc') || contains(steps.version.outputs.test_version, 'alpha') || contains(steps.version.outputs.test_version, 'beta') }}" + + echo "" + echo "🎯 Release notes would include:" + echo "## What's Changed" + echo "This release implements enhancements to improve the functionality of the WIP Module and overall testing coverage." + echo "" + echo "## Features & Enhancements" + echo "### WIP Module" + echo "- Enhanced test coverage for WIP token approval and transferFrom functionality" + echo "- Added comprehensive negative test cases for WIP transfers" + echo "- Implemented testing with multiple wallet configurations" + echo "- Added validation for transfer to zero address and contract address scenarios" + + - name: Test Package Installation + run: | + echo "🧪 Testing package installation locally..." + + # Try to install the built package + if [ -f "dist/*.whl" ]; then + echo "✅ Wheel file exists, would install with:" + echo "pip install dist/*.whl" + else + echo "❌ Wheel file missing" + fi + + if [ -f "dist/*.tar.gz" ]; then + echo "✅ Source distribution exists, would install with:" + echo "pip install dist/*.tar.gz" + else + echo "❌ Source distribution missing" + fi + + - name: Cleanup Test Artifacts + if: always() + run: | + echo "🧹 Cleaning up test artifacts" + rm -rf dist/ build/ *.egg-info/ + echo "Cleanup completed" + + - name: Test Results Summary + run: | + echo "🎉 Test Release Workflow completed successfully!" + echo "📦 Package built and verified" + echo "🧪 Version consistency checked" + echo "✅ All tests passed" + echo "" + echo "To test the real release workflow:" + echo "1. Update version files to match test version" + echo "2. Create and push a git tag" + echo "3. Watch the real release workflow run" + echo "" + echo "Test version used: ${{ steps.version.outputs.test_version }}"