diff --git a/.github/workflows/check-toolkits.yml b/.github/workflows/check-toolkits.yml new file mode 100644 index 00000000..128adf4a --- /dev/null +++ b/.github/workflows/check-toolkits.yml @@ -0,0 +1,38 @@ +name: Check Toolkits + +on: + push: + branches: + - main + +jobs: + check-toolkits: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v45 + with: + files: | + toolkits/** + + - name: List all added files + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + GITHUB_TOKEN: ${{ secrets.PAT }} + run: | + dirs=$(echo "${CHANGED_FILES}" | tr ' ' '\n' | grep "toolkits/" | cut -d'/' -f2 | sort -u) + echo "$dirs" | while read -r dir; do + echo "$dir" + gh workflow -R ArcadeAI/Team run "Publish Toolkit" -f toolkit=${dir} + done diff --git a/.github/workflows/publish-toolkit.yml b/.github/workflows/publish-toolkit.yml new file mode 100644 index 00000000..acbd7024 --- /dev/null +++ b/.github/workflows/publish-toolkit.yml @@ -0,0 +1,74 @@ +name: Publish Toolkit + +on: + workflow_dispatch: + inputs: + toolkit: + description: 'The directory of the toolkit to publish' + required: true + +jobs: + release-and-publish: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Set toolkit input + id: set-toolkit + run: | + if [ "${{ github.event_name }}" = "push" ]; then + # Extract toolkit name from changed files + TOOLKIT=this_is_for_testing + echo "toolkit=$TOOLKIT" >> $GITHUB_OUTPUT + else + echo "toolkit=${{ inputs.toolkit }}" >> $GITHUB_OUTPUT + fi + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Poetry + uses: snok/install-poetry@v1 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install Python Dependencies + run: pip install ./arcade + + - name: Test Toolkit + id: Test_Toolkit + working-directory: toolkits/${{ steps.set-toolkit.outputs.toolkit }} + run: | + make check + make install + make test + + - name: Publish Toolkit + id: Publish_Toolkit + working-directory: toolkits/${{ steps.set-toolkit.outputs.toolkit }} + run: | + poetry build + # Extract version from pyproject.toml using poetry and save it + VERSION=$(poetry version -s) + echo "version=$VERSION" >> $GITHUB_OUTPUT + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish + + - name: Send status to Slack + if: always() + uses: slackapi/slack-github-action@v2.0.0 + with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: webhook-trigger + payload: | + status: "${{ (steps.Test_Toolkit.outcome == 'failure' || steps.Publish_Toolkit.outcome == 'failure') && 'Failed' || 'Success' }}" + toolkit: ${{ steps.set-toolkit.outputs.toolkit }} + version: ${{ steps.Publish_Toolkit.outputs.version }} + url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" diff --git a/Makefile b/Makefile index 3f4cb0c1..3cd50b90 100644 --- a/Makefile +++ b/Makefile @@ -108,8 +108,8 @@ full-dist: clean-dist ## Build all projects and copy wheels to ./dist @echo "Setting version to $(VERSION)" @make set-version - @echo "🛠️ Building all projects and copying wheels to ./dist" - @mkdir -p dist/toolkits + # @echo "🛠️ Building all projects and copying wheels to ./dist" + @mkdir -p dist # Build the main arcade project @echo "🛠️ Building arcade project wheel..." @@ -123,19 +123,15 @@ full-dist: clean-dist ## Build all projects and copy wheels to ./dist @echo "🛠️ Building all projects and copying wheels to ./dist" # Build and copy wheels for each toolkit - @for toolkit_dir in toolkits/*; do \ - if [ -d "$$toolkit_dir" ]; then \ - toolkit_name=$$(basename "$$toolkit_dir"); \ - echo "Building $$toolkit_name project..."; \ - cd "$$toolkit_dir" && poetry version $(VERSION); \ - awk '{gsub(/arcade-ai = "0.1.\*"/, "arcade-ai = \"$(VERSION)\"")}1' pyproject.toml > temp_file && mv temp_file pyproject.toml; \ - poetry build; \ - cp dist/*.whl ../../dist/toolkits; \ - poetry version 0.1.0; \ - awk '{gsub(/arcade-ai = "$(VERSION)"/, "arcade-ai = \"0.1.\*\"")}1' pyproject.toml > temp_file && mv temp_file pyproject.toml; \ - cd -; \ - fi; \ - done + # @for toolkit_dir in toolkits/*; do \ + # if [ -d "$$toolkit_dir" ]; then \ + # toolkit_name=$$(basename "$$toolkit_dir"); \ + # echo "Building $$toolkit_name project..."; \ + # poetry build; \ + # cp dist/*.whl ../../dist/toolkits; \ + # cd -; \ + # fi; \ + # done @echo "✅ All toolkits built and wheels copied to ./dist" diff --git a/docker/Dockerfile b/docker/Dockerfile index 913ee76d..00241304 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,6 +12,7 @@ ENV HOST=${HOST} ENV VERSION=${VERSION} ENV OTEL_ENABLE=false ENV ARCADE_WORK_DIR=/app +ENV TOOLKITS="arcade-code-sandbox,arcade-github,arcade-google,arcade-linkedin,arcade-math,arcade-search,arcade-slack,arcade-spotify,arcade-web,arcade-x,arcade-zoom" # Install system dependencies RUN apt-get update && apt-get install -y \ @@ -34,19 +35,14 @@ RUN ls -lah /app/arcade/ # Install the wheel with extras (not evals for now) -RUN python -m pip install ./arcade_ai-${VERSION}-py3-none-any.whl +RUN python -m pip install ./arcade_ai-${VERSION}-py3-none-any.whl fastapi RUN python -m pip install -r ./requirements.txt -# Install toolkits from the toolkits directory -RUN set -e; \ - for toolkit in ./toolkits/*; do \ - echo "Installing toolkit $toolkit"; \ - python -m pip install $toolkit; \ - done - # Expose the port EXPOSE $PORT # Run the arcade actorup (hidden cli command) -CMD arcade actorup --host $HOST --port $PORT $([ "$OTEL_ENABLE" = "true" ] && echo "--otel-enable") +COPY docker/start.sh /app/start.sh +RUN chmod +x /app/start.sh +CMD ["/app/start.sh"] diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 00000000..04b09df7 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Installing toolkits..." +for toolkit in $(echo $TOOLKITS | tr "," " "); do + echo "Installing $toolkit..." + pip install $toolkit +done + +echo "Starting arcade..." +arcade actorup --host $HOST --port $PORT $([ "$OTEL_ENABLE" = "true" ] && echo "--otel-enable")