Skip to content

verify-new-go-lib-version #24

verify-new-go-lib-version

verify-new-go-lib-version #24

name: Python Integration Tests
on:
pull_request:
branches: [ main ]
types: [review_requested, ready_for_review]
push:
branches: [ main ]
repository_dispatch:
types: [verify-new-go-lib-version]
permissions:
contents: write
jobs:
# ====================================================
# 1. BUILD FAKE
# ====================================================
build-fake:
name: Build fake client
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: "./go/go.mod"
cache-dependency-path: "./go/go.sum"
check-latest: true
- run: go version
- name: Update Go Dependency (If triggered by Go Repo)
if: github.event_name == 'repository_dispatch'
run: |
echo "Triggered by Go Core commit: ${{ github.event.client_payload.go_ref }}"
cd go
go get github.com/pzsp-teams/lib@${{ github.event.client_payload.go_ref }}
go mod tidy
- name: Compile Fake Binary
run: |
chmod +x ./go/bridge/compileBridges.sh
./go/bridge/compileBridges.sh fake
- name: Upload Fake Binary
uses: actions/upload-artifact@v4
with:
name: fake-binary
path: python/teams_lib_pzsp2_z1/bin/
retention-days: 1
# ====================================================
# 2. RUN TESTS
# ====================================================
test-integration:
name: Run Integration Tests
runs-on: ubuntu-latest
needs: build-fake
if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Fake Binary
uses: actions/download-artifact@v4
with:
name: fake-binary
path: python/teams_lib_pzsp2_z1/bin/
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "python/uv.lock"
- name: Setup Python
run: uv python install 3.12
- name: Install dependencies
run: |
cd python
uv sync --dev
- name: Run Integration Tests
run: |
chmod +x python/teams_lib_pzsp2_z1/bin/*
cd python
uv pip install -e .
uv run pytest -v tests/
# ====================================================
# 3. BUILD REAL BINARIES
# ====================================================
build-real:
name: Build real client
runs-on: ubuntu-latest
needs: test-integration
if: |
always() &&
(github.event_name == 'push' || needs.test-integration.result == 'success')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: "./go/go.mod"
cache-dependency-path: "./go/go.sum"
check-latest: true
- run: go version
- name: Update Go Dependency (If triggered by Go Repo)
if: github.event_name == 'repository_dispatch'
run: |
echo "Triggered by Go Core commit: ${{ github.event.client_payload.go_ref }}"
cd go
go get github.com/pzsp-teams/lib@${{ github.event.client_payload.go_ref }}
go mod tidy
- name: Compile Real Binaries
run: |
chmod +x ./go/bridge/compileBridges.sh
./go/bridge/compileBridges.sh real
- name: Upload Real Binaries
uses: actions/upload-artifact@v4
with:
name: real-binary
path: python/teams_lib_pzsp2_z1/bin/
retention-days: 1
# ====================================================
# 4. BUMP VERSION (COMMIT TO MAIN)
# ====================================================
bump-version:
name: Bump Version on Main
runs-on: ubuntu-latest
needs: build-real
if: |
always() &&
needs.build-real.result == 'success' &&
github.ref == 'refs/heads/main' && (
github.event_name == 'push' ||
github.event_name == 'repository_dispatch'
)
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_PAT }}
fetch-depth: 0
- name: Bump Patch Version
run: |
cd python
python3 -c "
import re
file_path = 'pyproject.toml'
with open(file_path, 'r') as f:
content = f.read()
match = re.search(r'version = \"(\d+\.\d+)\.(\d+)\"', content)
if match:
prefix = match.group(1)
patch = int(match.group(2))
new_version = f'{prefix}.{patch + 1}'
new_content = re.sub(r'version = \"\d+\.\d+\.\d+\"', f'version = \"{new_version}\"', content)
with open(file_path, 'w') as f:
f.write(new_content)
print(f'Bumped version to {new_version}')
else:
print('Version not found or invalid format')
exit(1)
"
- name: Commit and Push to Main
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git add python/pyproject.toml
git commit -m "Bump version [skip ci]"
git push origin main
# ====================================================
# 5. PREPARE RELEASE BRANCH
# ====================================================
update-release-branch:
name: Update Release Branch
runs-on: ubuntu-latest
needs: [bump-version, build-real]
if: |
always() &&
needs.bump-version.result == 'success' &&
needs.build-real.result == 'success' &&
github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ secrets.ADMIN_PAT }}
- name: Ensure latest main (with bump)
run: git pull origin main
- name: Download Real Binary
uses: actions/download-artifact@v4
with:
name: real-binary
path: /tmp/real-binary
- name: Prepare Client Directory
run: |
mkdir python_release
cp -r python/* python_release/
# binaries
TARGET_BIN_DIR="python_release/teams_lib_pzsp2_z1/bin/"
mkdir -p $TARGET_BIN_DIR
find /tmp/real-binary -type f -exec cp {} $TARGET_BIN_DIR \;
chmod +x $TARGET_BIN_DIR/*
# publish workflow
mkdir -p python_release/.github/workflows
cp .github/workflows/publish.yml python_release/.github/workflows/
# license file
if [ -f "LICENSE" ]; then
cp LICENSE python_release/
fi
# clean up unneeded files
rm -rf python_release/tests
find python_release -type d -name "__pycache__" -exec rm -rf {} +
rm -rf python_release/.venv
ls -R python_release
- name: Commit and Push to Release Branch
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git checkout --orphan python-release
git rm -rf .
cp -a python_release/. .
rm -rf python_release
git add .
git commit -m "Release build: ${{ github.sha }}"
git push -f origin python-release