diff --git a/.github/workflows/agentex-tutorials-test.yml b/.github/workflows/agentex-tutorials-test.yml index 36fe76f9..42c9f365 100644 --- a/.github/workflows/agentex-tutorials-test.yml +++ b/.github/workflows/agentex-tutorials-test.yml @@ -2,9 +2,9 @@ name: Test Tutorial Agents on: pull_request: - branches: [ main ] + branches: [main] push: - branches: [ main ] + branches: [main] workflow_dispatch: jobs: @@ -23,11 +23,8 @@ jobs: # Find all tutorials with a manifest.yaml all_tutorials=$(find . -name "manifest.yaml" -exec dirname {} \; | sort | sed 's|^\./||') - # Include all tutorials (temporal tutorials are now included) - filtered_tutorials="$all_tutorials" - # Convert to JSON array - tutorials=$(echo "$filtered_tutorials" | jq -R -s -c 'split("\n") | map(select(length > 0))') + tutorials=$(echo "$all_tutorials" | jq -R -s -c 'split("\n") | map(select(length > 0))') echo "tutorials=$tutorials" >> $GITHUB_OUTPUT echo "All tutorials found: $(echo "$all_tutorials" | wc -l)" diff --git a/.github/workflows/build-and-push-tutorial-agent.yml b/.github/workflows/build-and-push-tutorial-agent.yml index b977e449..1b2f21e8 100644 --- a/.github/workflows/build-and-push-tutorial-agent.yml +++ b/.github/workflows/build-and-push-tutorial-agent.yml @@ -56,6 +56,7 @@ jobs: needs: [check-permissions] outputs: agents: ${{ steps.get-agents.outputs.agents }} + all_agents: ${{ steps.get-agents.outputs.all_agents }} has_agents: ${{ steps.get-agents.outputs.has_agents }} steps: - name: Checkout repository @@ -72,6 +73,10 @@ jobs: all_agents=$(find examples/tutorials -name "manifest.yaml" -exec dirname {} \; | sort) agents_to_build=() + # Output all agents for deprecation check + all_agents_json=$(printf '%s\n' $all_agents | jq -R -s -c 'split("\n") | map(select(length > 0))') + echo "all_agents=$all_agents_json" >> $GITHUB_OUTPUT + if [ "$REBUILD_ALL" = "true" ]; then echo "Rebuild all agents requested" agents_to_build=($(echo "$all_agents")) @@ -275,3 +280,73 @@ jobs: docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true echo "✅ All validations passed for: $FULL_IMAGE" + + deprecate-agents: + name: "Deprecate Removed Agents" + runs-on: ubuntu-latest + needs: [find-agents] + steps: + - name: Find and delete deprecated agent packages + env: + GITHUB_TOKEN: ${{ secrets.PACKAGE_TOKEN }} + run: | + set -e + + echo "🔍 Agents in repo (from find-agents):" + # Convert JSON array of paths to package names + # e.g., "examples/tutorials/00_sync/000_hello_acp" -> "00_sync-000_hello_acp" + REPO_AGENTS=$(echo '${{ needs.find-agents.outputs.all_agents }}' | jq -r '.[]' | \ + sed 's|examples/tutorials/||' | \ + sed 's|/|-|g') + echo "$REPO_AGENTS" + + echo "" + echo "🔍 Fetching packages from GitHub Container Registry..." + PACKAGES=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/orgs/scaleapi/packages?package_type=container&per_page=100") + + # Check for API errors + if echo "$PACKAGES" | jq -e '.message' > /dev/null 2>&1; then + echo "❌ GitHub API error:" + echo "$PACKAGES" | jq '.' + exit 1 + fi + + # Filter for tutorial-agents from this repo + TUTORIAL_PACKAGES=$(echo "$PACKAGES" | \ + jq -r '.[] | select(.repository != null and .repository.name == "scale-agentex-python" and (.name | contains("tutorial-agents"))) | .name') + + echo "Tutorial packages in registry:" + echo "$TUTORIAL_PACKAGES" + + echo "" + echo "🔍 Checking for deprecated packages..." + while IFS= read -r package_name; do + [ -z "$package_name" ] && continue + + # Extract agent name: scale-agentex-python/tutorial-agents/00_sync-000_hello_acp -> 00_sync-000_hello_acp + agent_name=$(echo "$package_name" | sed 's|.*/tutorial-agents/||') + + if ! echo "$REPO_AGENTS" | grep -q "^${agent_name}$"; then + echo "🗑️ $agent_name - NOT in repo, deleting..." + # URL encode the package name (replace / with %2F) + encoded_package=$(echo "$package_name" | sed 's|/|%2F|g') + response=$(curl -s -w "\n%{http_code}" -X DELETE \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/orgs/scaleapi/packages/container/${encoded_package}") + + http_code=$(echo "$response" | tail -n1) + body=$(echo "$response" | sed '$d') + + if [ "$http_code" = "204" ] || [ "$http_code" = "200" ]; then + echo " ✅ Deleted: $package_name" + else + echo " ⚠️ Failed to delete $package_name (HTTP $http_code): $body" + fi + fi + done <<< "$TUTORIAL_PACKAGES" + + echo "" + echo "✅ Deprecation check complete"