|
| 1 | +name: Test AgentEx Tutorials |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | + workflow_call: |
| 7 | + |
| 8 | +jobs: |
| 9 | + detect-changes: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + changed-tutorials: ${{ steps.check.outputs.changed-tutorials }} |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 18 | + fetch-depth: 2 |
| 19 | + |
| 20 | + - name: Check for changes in tutorials directory |
| 21 | + id: check |
| 22 | + run: | |
| 23 | + # For testing: hardcode 10_agentic/00_base/000_hello_acp tutorial |
| 24 | + echo "changed-tutorials=[\"10_agentic/00_base/000_hello_acp\"]" >> $GITHUB_OUTPUT |
| 25 | +
|
| 26 | + build-and-push-tutorial-agents: |
| 27 | + needs: detect-changes |
| 28 | + runs-on: ubuntu-latest |
| 29 | + if: needs.detect-changes.outputs.changed-tutorials != '[]' |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v4 |
| 38 | + with: |
| 39 | + python-version: "3.12" |
| 40 | + |
| 41 | + - name: Install Rye |
| 42 | + run: | |
| 43 | + curl -sSf https://rye.astral.sh/get | bash |
| 44 | + echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 45 | + env: |
| 46 | + RYE_VERSION: "0.44.0" |
| 47 | + RYE_INSTALL_OPTION: "--yes" |
| 48 | + |
| 49 | + - name: Build and install agentex SDK (same as release) |
| 50 | + run: | |
| 51 | + rye build --clean |
| 52 | +
|
| 53 | + # Get the wheel filename |
| 54 | + WHEEL_FILE=$(ls dist/*.whl | head -n 1) |
| 55 | + echo "Built wheel: $WHEEL_FILE" |
| 56 | +
|
| 57 | + # Install the wheel to make the CLI available |
| 58 | + pip install "$WHEEL_FILE" |
| 59 | +
|
| 60 | + # Verify CLI is available |
| 61 | + agentex --version |
| 62 | +
|
| 63 | + # Store wheel path for later use if needed |
| 64 | + echo "AGENTEX_WHEEL=$WHEEL_FILE" >> $GITHUB_ENV |
| 65 | +
|
| 66 | + - name: Login to Docker Hub |
| 67 | + uses: docker/login-action@v3 |
| 68 | + with: |
| 69 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 70 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 71 | + |
| 72 | + # Set up Docker Buildx |
| 73 | + - name: Set up Docker Buildx |
| 74 | + uses: docker/setup-buildx-action@v3 |
| 75 | + |
| 76 | + - name: Build tutorial agent images |
| 77 | + run: | |
| 78 | + # Get list of changed tutorials from detect-changes job output |
| 79 | + CHANGED_TUTORIALS='${{ needs.detect-changes.outputs.changed-tutorials }}' |
| 80 | + echo "Changed tutorials: $CHANGED_TUTORIALS" |
| 81 | +
|
| 82 | + # Parse the JSON array and build each tutorial |
| 83 | + echo "$CHANGED_TUTORIALS" | jq -r '.[]' | while read -r tutorial; do |
| 84 | + echo "🔨 Building tutorial: $tutorial" |
| 85 | +
|
| 86 | + TUTORIAL_PATH="examples/tutorials/$tutorial" |
| 87 | +
|
| 88 | + if [ -f "$TUTORIAL_PATH/manifest.yaml" ]; then |
| 89 | + echo "📦 Building with agentex CLI..." |
| 90 | +
|
| 91 | + # Extract the last folder name from the tutorial path |
| 92 | + TAG_NAME=$(basename "$tutorial") |
| 93 | +
|
| 94 | + # Build and push with agentex agents build command |
| 95 | + agentex agents build \ |
| 96 | + --manifest "$TUTORIAL_PATH/manifest.yaml" \ |
| 97 | + --registry "docker.io" \ |
| 98 | + --repository-name "${{ vars.DOCKERHUB_USERNAME }}/agentex-tutorials" \ |
| 99 | + --tag "${TAG_NAME}-stable-release" \ |
| 100 | + --push |
| 101 | +
|
| 102 | + echo "✅ Successfully built and pushed: ${{ vars.DOCKERHUB_USERNAME }}/agentex-tutorials:${TAG_NAME}-stable-release" |
| 103 | + else |
| 104 | + echo "⚠️ No manifest.yaml found in $TUTORIAL_PATH, skipping..." |
| 105 | + fi |
| 106 | + done |
| 107 | +
|
| 108 | + run-agentex-tests: |
| 109 | + runs-on: ubuntu-latest |
| 110 | + if: needs.detect-changes.outputs.changed-tutorials != "run" |
| 111 | + steps: |
| 112 | + - name: Checkout code |
| 113 | + uses: actions/checkout@v3 |
| 114 | + with: |
| 115 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 116 | + |
| 117 | + - name: Set up Python |
| 118 | + uses: actions/setup-python@v4 |
| 119 | + with: |
| 120 | + python-version: "3.12" |
| 121 | + |
| 122 | + - name: Install Rye |
| 123 | + run: | |
| 124 | + curl -sSf https://rye.astral.sh/get | bash |
| 125 | + echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 126 | + env: |
| 127 | + RYE_VERSION: "0.44.0" |
| 128 | + RYE_INSTALL_OPTION: "--yes" |
| 129 | + |
| 130 | + - name: Build and install agentex SDK (same as release) |
| 131 | + run: | |
| 132 | + rye build --clean |
| 133 | +
|
| 134 | + # Get the wheel filename |
| 135 | + WHEEL_FILE=$(ls dist/*.whl | head -n 1) |
| 136 | + echo "Built wheel: $WHEEL_FILE" |
| 137 | +
|
| 138 | + # Install the wheel to make the CLI available |
| 139 | + pip install "$WHEEL_FILE" |
| 140 | +
|
| 141 | + # Verify CLI is available |
| 142 | + agentex --version |
| 143 | +
|
| 144 | + # Store wheel path for later use if needed |
| 145 | + echo "AGENTEX_WHEEL=$WHEEL_FILE" >> $GITHUB_ENV |
| 146 | +
|
| 147 | + # Login to Amazon ECR |
| 148 | + - name: Login to Amazon ECR |
| 149 | + id: login-ecr |
| 150 | + uses: aws-actions/amazon-ecr-login@v2 |
| 151 | + |
| 152 | + - name: Pull AgentEx Server image |
| 153 | + env: |
| 154 | + SCALE_PROD_ACCOUNT_ID: "307185671274" |
| 155 | + AWS_REGION: "us-west-2" |
| 156 | + AGENTEX_SERVER_IMAGE_NAME: "agentex" |
| 157 | + run: | |
| 158 | + # Pull the latest-stable AgentEx server image from ECR |
| 159 | + SERVER_IMAGE="${{ env.SCALE_PROD_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.AGENTEX_SERVER_IMAGE_NAME }}:latest-stable" |
| 160 | + echo "📥 Pulling AgentEx server image: $SERVER_IMAGE" |
| 161 | + docker pull "$SERVER_IMAGE" |
| 162 | +
|
| 163 | + # Tag it for local use |
| 164 | + docker tag "$SERVER_IMAGE" "agentex-server:test" |
| 165 | +
|
| 166 | + echo "✅ AgentEx server image ready: agentex-server:test" |
| 167 | +
|
| 168 | + - name: Run AgentEx tutorial tests |
| 169 | + run: | |
| 170 | + ## run a script |
0 commit comments