From 63062809f91ef5c8da622053f097e9ea1d7ace60 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 21:51:07 -0500 Subject: [PATCH 01/19] initial commit --- .github/workflows/docker.yml | 4 ++-- .github/workflows/lint.yml | 12 ++++++------ .github/workflows/static.yml | 12 ++++++------ .github/workflows/test.yml | 12 ++++++------ lib/agent0/pyproject.toml | 16 ++-------------- lib/chainsync/pyproject.toml | 13 +------------ lib/ethpy/pyproject.toml | 12 +----------- lib/hyperlogs/pyproject.toml | 8 -------- lib/hypertypes/pyproject.toml | 8 ++++---- requirements.txt | 2 +- 10 files changed, 29 insertions(+), 70 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5379dd3364..0c3009444f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,8 +3,8 @@ name: "Docker: Build and push agent0 image" on: workflow_dispatch: push: - branches: ["main"] - tags: ["*"] + branches: + - uv-installable env: REGISTRY: ghcr.io diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4084226638..047571ce43 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: lint on: push: branches: - - main + - uv-installable pull_request: jobs: @@ -22,14 +22,14 @@ jobs: cache: "pip" token: ${{github.token}} - - name: upgrade pip - run: python -m pip install --upgrade pip + - name: install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install requirements run: | - python -m pip install --upgrade -r requirements.txt - python -m pip install --upgrade -r requirements-rl.txt - python -m pip install --upgrade -r requirements-dev.txt + uv pip install --upgrade -r requirements.txt + uv pip install --upgrade -r requirements-rl.txt + uv pip install --upgrade -r requirements-dev.txt - name: run black run: python -m black --config pyproject.toml --check --diff . diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index c723e1a030..645806cc03 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -3,7 +3,7 @@ name: static on: push: branches: - - main + - uv-installable pull_request: jobs: @@ -22,14 +22,14 @@ jobs: cache: "pip" token: ${{github.token}} - - name: upgrade pip - run: python -m pip install --upgrade pip + - name: install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install requirements run: | - python -m pip install --upgrade -r requirements.txt - python -m pip install --upgrade -r requirements-rl.txt - python -m pip install --upgrade -r requirements-dev.txt + uv pip install --upgrade -r requirements.txt + uv pip install --upgrade -r requirements-rl.txt + uv pip install --upgrade -r requirements-dev.txt - name: analysing code with pyright run: python -m pyright $(git ls-files '*.py' '*.pyi') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c01032507..f9ab99df6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: test on: push: branches: - - main + - uv-installable pull_request: jobs: @@ -41,14 +41,14 @@ jobs: cache: "pip" token: ${{github.token}} - - name: upgrade pip - run: python -m pip install --upgrade pip + - name: install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install requirements run: | - python -m pip install --upgrade -r requirements.txt - python -m pip install --upgrade -r requirements-rl.txt - python -m pip install --upgrade -r requirements-dev.txt + uv pip install --upgrade -r requirements.txt + uv pip install --upgrade -r requirements-rl.txt + uv pip install --upgrade -r requirements-dev.txt - name: run pytest with coverage run: | diff --git a/lib/agent0/pyproject.toml b/lib/agent0/pyproject.toml index 97bafc005a..5064cfe693 100644 --- a/lib/agent0/pyproject.toml +++ b/lib/agent0/pyproject.toml @@ -15,29 +15,17 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ] - -[project.optional-dependencies] -# This flag installs all dependencies and should be ran when installing this subpackage in isolation -with-dependencies = ["agent0[base, lateral]"] -base = [ - "fixedpointmath", +dependencies = [ "numpy", "python-dotenv", - # will include eth- packages "web3", "hexbytes", "pandas", "nest_asyncio", "rollbar", "dill", + "fixedpointmath @ git+https://github.com/delvtech/fixedpointmath.git", ] -lateral = [ - # Lateral dependencies across subpackages are pointing to github - "hyperlogs[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/hyperlogs", - "ethpy[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/ethpy", - "chainsync[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/chainsync", -] - [build-system] requires = ["flit_core>=3.2"] diff --git a/lib/chainsync/pyproject.toml b/lib/chainsync/pyproject.toml index 31944ce5e3..1d946fcd7c 100644 --- a/lib/chainsync/pyproject.toml +++ b/lib/chainsync/pyproject.toml @@ -15,13 +15,7 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ] - -[project.optional-dependencies] -# This flag installs all dependencies and should be ran when installing this subpackage in isolation -with-dependencies = [ - "chainsync[base, lateral]" -] -base = [ +dependencies = [ "fixedpointmath", "matplotlib", "numpy", @@ -37,11 +31,6 @@ base = [ "pandas-stubs", "requests", ] -lateral = [ - # Lateral dependencies across subpackages are pointing to github - "hyperlogs[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/hyperlogs", - "ethpy[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/ethpy", -] [build-system] requires = ["flit_core>=3.2"] diff --git a/lib/ethpy/pyproject.toml b/lib/ethpy/pyproject.toml index fc769801af..17c6c5b0e4 100644 --- a/lib/ethpy/pyproject.toml +++ b/lib/ethpy/pyproject.toml @@ -15,22 +15,12 @@ classifiers = [ "License :: OSI Approved :: Apache License 2.0", "Operating System :: OS Independent", ] - -[project.optional-dependencies] -# This flag installs all dependencies and should be run when installing this subpackage in isolation -with-dependencies = [ - "ethpy[base, lateral]" -] -base = [ +dependencies = [ "fixedpointmath", "numpy", "python-dotenv", "web3", ] -lateral = [ - # Lateral dependencies across subpackages are pointing to github - "hypertypes[with-dependencies] @ git+https://github.com/delvtech/agent0.git/#subdirectory=lib/hypertypes", -] [project.urls] "Homepage" = "https://github.com/delvtech/agent0" diff --git a/lib/hyperlogs/pyproject.toml b/lib/hyperlogs/pyproject.toml index fcc42639fb..d207cf0d16 100644 --- a/lib/hyperlogs/pyproject.toml +++ b/lib/hyperlogs/pyproject.toml @@ -16,14 +16,6 @@ classifiers = [ "Operating System :: OS Independent", ] -[project.optional-dependencies] -# This flag installs all dependencies and should be ran when installing this subpackage in isolation -with-dependencies = [ - "hyperlogs[base, lateral]" -] -base = [] -lateral = [] - [build-system] requires = ["flit_core>=3.2"] build-backend = "flit_core.buildapi" diff --git a/lib/hypertypes/pyproject.toml b/lib/hypertypes/pyproject.toml index ce4e373fcf..1807304f22 100644 --- a/lib/hypertypes/pyproject.toml +++ b/lib/hypertypes/pyproject.toml @@ -10,10 +10,10 @@ classifiers = [ "License :: OSI Approved :: Apache License 2.0", "Operating System :: OS Independent", ] - -[project.optional-dependencies] -with-dependencies = ["hypertypes[base]"] -base = ["web3", "pypechain"] +dependencies = [ + "web3", + "pypechain", +] [build-system] requires = ["flit_core>=3.2"] diff --git a/requirements.txt b/requirements.txt index 8a615288f6..e4f3ce16d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,6 @@ -e lib/chainsync[base] -e lib/ethpy[base] -e lib/hypertypes[base] ---find-links="packages/hyperdrivepy" +--find-links=packages/hyperdrivepy hyperdrivepy rollbar From d7be8becb9be92fcaa9511573ccd474b076c79e9 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 21:52:37 -0500 Subject: [PATCH 02/19] make venv --- .github/workflows/static.yml | 2 ++ .github/workflows/test.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 645806cc03..aa29b835cf 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -27,6 +27,8 @@ jobs: - name: install requirements run: | + uv venv .venv -p 3.10 + source .venv/bin/activate uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt uv pip install --upgrade -r requirements-dev.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9ab99df6e..755f950b6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,6 +46,8 @@ jobs: - name: install requirements run: | + uv venv .venv -p 3.10 + source .venv/bin/activate uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt uv pip install --upgrade -r requirements-dev.txt From 7ea0b80eab19d363323ed3635a3362a2cfc023ed Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 21:53:35 -0500 Subject: [PATCH 03/19] don't run it twice --- .github/workflows/docker.yml | 2 +- .github/workflows/lint.yml | 4 +++- .github/workflows/static.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0c3009444f..60eccc13a7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: branches: - - uv-installable + - main env: REGISTRY: ghcr.io diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 047571ce43..68d40a5ee4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: lint on: push: branches: - - uv-installable + - main pull_request: jobs: @@ -27,6 +27,8 @@ jobs: - name: install requirements run: | + uv venv .venv -p 3.10 + source .venv/bin/activate uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt uv pip install --upgrade -r requirements-dev.txt diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index aa29b835cf..db56999807 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -3,7 +3,7 @@ name: static on: push: branches: - - uv-installable + - main pull_request: jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 755f950b6a..6127c26cc7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: test on: push: branches: - - uv-installable + - main pull_request: jobs: From fac56f39c8335e2db591587ccbefc3a3462bf6d0 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 22:00:30 -0500 Subject: [PATCH 04/19] activate venv at very step in CI --- .github/workflows/lint.yml | 5 ++++- .github/workflows/static.yml | 4 +++- .github/workflows/test.yml | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 68d40a5ee4..c544110741 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,7 +34,9 @@ jobs: uv pip install --upgrade -r requirements-dev.txt - name: run black - run: python -m black --config pyproject.toml --check --diff . + run: | + source .venv/bin/activate + python -m black --config pyproject.toml --check --diff . - name: get all Python files id: list_files @@ -43,6 +45,7 @@ jobs: - name: run Pylint on files run: | + source .venv/bin/activate files="${{ steps.list_files.outputs.files }}" if [ -n "$files" ]; then pylint --rcfile=.pylintrc $files diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index db56999807..fb0744ef9b 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -34,4 +34,6 @@ jobs: uv pip install --upgrade -r requirements-dev.txt - name: analysing code with pyright - run: python -m pyright $(git ls-files '*.py' '*.pyi') + run: | + source .venv/bin/activate + python -m pyright $(git ls-files '*.py' '*.pyi') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6127c26cc7..04ae341324 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,10 +54,12 @@ jobs: - name: run pytest with coverage run: | + source .venv/bin/activate IN_CI=true coverage run -m pytest - name: generate coverage report run: | + source .venv/bin/activate coverage xml -i coverage html -i From 75ab1611a3be425b4cd50a3ffe36501bd67c93de Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 22:35:55 -0500 Subject: [PATCH 05/19] initial commit --- .github/workflows/docker.yml | 52 ----------- .github/workflows/jobs.yml | 172 +++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 54 ----------- .github/workflows/static.yml | 39 -------- .github/workflows/test.yml | 73 --------------- 5 files changed, 172 insertions(+), 218 deletions(-) delete mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/jobs.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/static.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 60eccc13a7..0000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Docker: Build and push agent0 image" - -on: - workflow_dispatch: - push: - branches: - - main - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}/agent0 - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Check out code - uses: actions/checkout@v3 - with: - submodules: recursive - token: ${{secrets.GITHUB_TOKEN}} - - - name: Log in to the Container registry - uses: docker/login-action@v2.2.0 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4.5.0 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - # Add a version tag when a valid semver tag is pushed. - type=semver,pattern={{version}} - # Add the edge tag to every image to represent the latest commit to main - type=edge,branch=main - - - name: Build and push Docker image - uses: docker/build-push-action@v4.1.0 - with: - context: . - push: true - file: ./Dockerfile - tags: | - ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml new file mode 100644 index 0000000000..32d80c0919 --- /dev/null +++ b/.github/workflows/jobs.yml @@ -0,0 +1,172 @@ +name: setup + +on: + push: + branches: + - main + pull_request: + +jobs: + setup-and-upload: + name: Set up virtual environment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: install venv + run: uv venv .venv -p 3.10 + - name: install requirements + run: | + source .venv/bin/activate + uv pip install --upgrade -r requirements.txt + uv pip install --upgrade -r requirements-rl.txt + uv pip install --upgrade -r requirements-dev.txt + - name: Upload virtual environment + uses: actions/upload-artifact@v3 + with: + name: venv + path: .venv + + lint: + name: Lint + runs-on: ubuntu-latest + needs: setup-and-upload + steps: + - uses: actions/checkout@v3 + with: + token: ${{github.token}} + - name: Download virtual environment + uses: actions/download-artifact@v3 + with: + name: venv + path: .venv + - name: run black + run: | + source .venv/bin/activate + python -m black --config pyproject.toml --check --diff . + - name: get all Python files + id: list_files + run: | + echo "files=$(git ls-files '*.py' '*.pyi' | xargs)" >> $GITHUB_OUTPUT + - name: run Pylint on files + run: | + source .venv/bin/activate + files="${{ steps.list_files.outputs.files }}" + if [ -n "$files" ]; then + pylint --rcfile=.pylintrc $files + else + echo "No Python files found." + fi + + static: + name: Static + runs-on: ubuntu-latest + needs: setup-and-upload + steps: + - uses: actions/checkout@v3 + with: + token: ${{github.token}} + - name: Download virtual environment + uses: actions/download-artifact@v3 + with: + name: venv + path: .venv + - name: Analyse code with pyright + run: | + source .venv/bin/activate + python -m pyright $(git ls-files '*.py' '*.pyi') + + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{github.token}} + - name: install node + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: install packages + uses: borales/actions-yarn@v4 + with: + cmd: install # will run `yarn install` command + env: + # A warning is thrown here unnecessarily. tracking issue here: + # https://github.com/github/vscode-github-actions/issues/222 + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed + - name: install foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + token: ${{github.token}} + - name: Download virtual environment + uses: actions/download-artifact@v3 + with: + name: venv + path: .venv + - name: run pytest with coverage + run: | + source .venv/bin/activate + IN_CI=true coverage run -m pytest + - name: generate coverage report + run: | + source .venv/bin/activate + coverage xml -i + coverage html -i + - name: upload coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + flags: unittests + fail_ci_if_error: true + # A warning is thrown here unnecessarily. tracking issue here: + # https://github.com/github/vscode-github-actions/issues/222 + token: ${{ secrets.CODECOV_TOKEN }} + + docker: + name: Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{secrets.GITHUB_TOKEN}} + - name: Log in to the Container registry + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.5.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # Add a version tag when a valid semver tag is pushed. + type=semver,pattern={{version}} + # Add the edge tag to every image to represent the latest commit to main + type=edge,branch=main + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.0 + with: + context: . + push: true + file: ./Dockerfile + tags: | + ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c544110741..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: lint - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "pip" - token: ${{github.token}} - - - name: install uv - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - - name: install requirements - run: | - uv venv .venv -p 3.10 - source .venv/bin/activate - uv pip install --upgrade -r requirements.txt - uv pip install --upgrade -r requirements-rl.txt - uv pip install --upgrade -r requirements-dev.txt - - - name: run black - run: | - source .venv/bin/activate - python -m black --config pyproject.toml --check --diff . - - - name: get all Python files - id: list_files - run: | - echo "files=$(git ls-files '*.py' '*.pyi' | xargs)" >> $GITHUB_OUTPUT - - - name: run Pylint on files - run: | - source .venv/bin/activate - files="${{ steps.list_files.outputs.files }}" - if [ -n "$files" ]; then - pylint --rcfile=.pylintrc $files - else - echo "No Python files found." - fi diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml deleted file mode 100644 index fb0744ef9b..0000000000 --- a/.github/workflows/static.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: static - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - name: static - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "pip" - token: ${{github.token}} - - - name: install uv - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - - name: install requirements - run: | - uv venv .venv -p 3.10 - source .venv/bin/activate - uv pip install --upgrade -r requirements.txt - uv pip install --upgrade -r requirements-rl.txt - uv pip install --upgrade -r requirements-dev.txt - - - name: analysing code with pyright - run: | - source .venv/bin/activate - python -m pyright $(git ls-files '*.py' '*.pyi') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 04ae341324..0000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: test - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - name: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - - name: install node - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: install packages - uses: borales/actions-yarn@v4 - with: - cmd: install # will run `yarn install` command - env: - # A warning is thrown here unnecessarily. tracking issue here: - # https://github.com/github/vscode-github-actions/issues/222 - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed - - - name: install foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "pip" - token: ${{github.token}} - - - name: install uv - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - - name: install requirements - run: | - uv venv .venv -p 3.10 - source .venv/bin/activate - uv pip install --upgrade -r requirements.txt - uv pip install --upgrade -r requirements-rl.txt - uv pip install --upgrade -r requirements-dev.txt - - - name: run pytest with coverage - run: | - source .venv/bin/activate - IN_CI=true coverage run -m pytest - - - name: generate coverage report - run: | - source .venv/bin/activate - coverage xml -i - coverage html -i - - - name: upload coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - flags: unittests - fail_ci_if_error: true - # A warning is thrown here unnecessarily. tracking issue here: - # https://github.com/github/vscode-github-actions/issues/222 - token: ${{ secrets.CODECOV_TOKEN }} From 9c42c3ed6a0cc94ad0ca2c47247f1f33d7e00149 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 22:36:55 -0500 Subject: [PATCH 06/19] all depend on venv --- .github/workflows/jobs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 32d80c0919..9358cac855 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -84,6 +84,7 @@ jobs: test: name: Test runs-on: ubuntu-latest + needs: setup-and-upload steps: - uses: actions/checkout@v3 with: @@ -136,6 +137,7 @@ jobs: docker: name: Docker image runs-on: ubuntu-latest + needs: setup-and-upload permissions: contents: read packages: write From 82f9f03f5d1db18c172614eb8b98dad73f90b898 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 22:43:22 -0500 Subject: [PATCH 07/19] archive artifact --- .github/workflows/jobs.yml | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 9358cac855..54240268df 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -26,11 +26,12 @@ jobs: uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt uv pip install --upgrade -r requirements-dev.txt - - name: Upload virtual environment - uses: actions/upload-artifact@v3 + - name: Archive virtual environment + run: tar -czf venv.tar.gz .venv + - uses: actions/upload-artifact@v3 with: - name: venv - path: .venv + name: venv-archive + path: venv.tar.gz lint: name: Lint @@ -40,11 +41,16 @@ jobs: - uses: actions/checkout@v3 with: token: ${{github.token}} - - name: Download virtual environment - uses: actions/download-artifact@v3 + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + token: ${{github.token}} + - uses: actions/download-artifact@v3 with: - name: venv - path: .venv + name: venv-archive + - name: Extract virtual environment + run: tar -xzf venv.tar.gz - name: run black run: | source .venv/bin/activate @@ -71,11 +77,16 @@ jobs: - uses: actions/checkout@v3 with: token: ${{github.token}} - - name: Download virtual environment - uses: actions/download-artifact@v3 + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + token: ${{github.token}} + - uses: actions/download-artifact@v3 with: - name: venv - path: .venv + name: venv-archive + - name: Extract virtual environment + run: tar -xzf venv.tar.gz - name: Analyse code with pyright run: | source .venv/bin/activate @@ -109,13 +120,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" - cache: "pip" token: ${{github.token}} - - name: Download virtual environment - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v3 with: - name: venv - path: .venv + name: venv-archive + - name: Extract virtual environment + run: tar -xzf venv.tar.gz - name: run pytest with coverage run: | source .venv/bin/activate From 3beb469e8fb5f36bbdfbf2c5ce81a37e1c447f90 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:07:12 -0500 Subject: [PATCH 08/19] combine CI jobs --- .github/workflows/jobs.yml | 175 ++++++++++++------------------------- 1 file changed, 56 insertions(+), 119 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 54240268df..5c654f1bad 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -7,9 +7,9 @@ on: pull_request: jobs: - setup-and-upload: - name: Set up virtual environment - runs-on: ubuntu-latest + test-code: + name: Lint and test + runs-on: python-3.10-alpine steps: - uses: actions/checkout@v3 - name: Setup Python @@ -26,123 +26,60 @@ jobs: uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt uv pip install --upgrade -r requirements-dev.txt - - name: Archive virtual environment - run: tar -czf venv.tar.gz .venv - - uses: actions/upload-artifact@v3 + - name: run black + run: | + source .venv/bin/activate + python -m black --config pyproject.toml --check --diff . + - name: get all Python files + id: list_files + run: | + echo "files=$(git ls-files '*.py' '*.pyi' | xargs)" >> $GITHUB_OUTPUT + - name: run Pylint on files + run: | + source .venv/bin/activate + files="${{ steps.list_files.outputs.files }}" + if [ -n "$files" ]; then + pylint --rcfile=.pylintrc $files + else + echo "No Python files found." + fi + - name: Analyse code with pyright + run: | + source .venv/bin/activate + python -m pyright $(git ls-files '*.py' '*.pyi') + - name: install node + uses: actions/setup-node@v3 with: - name: venv-archive - path: venv.tar.gz - - lint: - name: Lint - runs-on: ubuntu-latest - needs: setup-and-upload - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - token: ${{github.token}} - - uses: actions/download-artifact@v3 - with: - name: venv-archive - - name: Extract virtual environment - run: tar -xzf venv.tar.gz - - name: run black - run: | - source .venv/bin/activate - python -m black --config pyproject.toml --check --diff . - - name: get all Python files - id: list_files - run: | - echo "files=$(git ls-files '*.py' '*.pyi' | xargs)" >> $GITHUB_OUTPUT - - name: run Pylint on files - run: | - source .venv/bin/activate - files="${{ steps.list_files.outputs.files }}" - if [ -n "$files" ]; then - pylint --rcfile=.pylintrc $files - else - echo "No Python files found." - fi - - static: - name: Static - runs-on: ubuntu-latest - needs: setup-and-upload - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - token: ${{github.token}} - - uses: actions/download-artifact@v3 - with: - name: venv-archive - - name: Extract virtual environment - run: tar -xzf venv.tar.gz - - name: Analyse code with pyright - run: | - source .venv/bin/activate - python -m pyright $(git ls-files '*.py' '*.pyi') - - test: - name: Test - runs-on: ubuntu-latest - needs: setup-and-upload - steps: - - uses: actions/checkout@v3 - with: - token: ${{github.token}} - - name: install node - uses: actions/setup-node@v3 - with: - node-version: 16.x - - name: install packages - uses: borales/actions-yarn@v4 - with: - cmd: install # will run `yarn install` command - env: - # A warning is thrown here unnecessarily. tracking issue here: - # https://github.com/github/vscode-github-actions/issues/222 - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed - - name: install foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - token: ${{github.token}} - - uses: actions/download-artifact@v3 - with: - name: venv-archive - - name: Extract virtual environment - run: tar -xzf venv.tar.gz - - name: run pytest with coverage - run: | - source .venv/bin/activate - IN_CI=true coverage run -m pytest - - name: generate coverage report - run: | - source .venv/bin/activate - coverage xml -i - coverage html -i - - name: upload coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - flags: unittests - fail_ci_if_error: true - # A warning is thrown here unnecessarily. tracking issue here: - # https://github.com/github/vscode-github-actions/issues/222 - token: ${{ secrets.CODECOV_TOKEN }} + node-version: 16.x + - name: install packages + uses: borales/actions-yarn@v4 + with: + cmd: install # will run `yarn install` command + env: + # A warning is thrown here unnecessarily. tracking issue here: + # https://github.com/github/vscode-github-actions/issues/222 + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed + - name: install foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: run pytest with coverage + run: | + source .venv/bin/activate + IN_CI=true coverage run -m pytest + - name: generate coverage report + run: | + source .venv/bin/activate + coverage xml -i + coverage html -i + - name: upload coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + flags: unittests + fail_ci_if_error: true + # A warning is thrown here unnecessarily. tracking issue here: + # https://github.com/github/vscode-github-actions/issues/222 + token: ${{ secrets.CODECOV_TOKEN }} docker: name: Docker image From 2e59d147958db7488ae85599bd7030ed11500283 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:09:50 -0500 Subject: [PATCH 09/19] use container --- .github/workflows/jobs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 5c654f1bad..00545f2962 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -9,7 +9,9 @@ on: jobs: test-code: name: Lint and test - runs-on: python-3.10-alpine + runs-on: ubuntu-latest + container: + image: python:3.10-alpine steps: - uses: actions/checkout@v3 - name: Setup Python From 56aa8318e375f121be1f156d35a9dcdf19209015 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:11:54 -0500 Subject: [PATCH 10/19] remove dependency --- .github/workflows/jobs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 00545f2962..4a5b2ff8bf 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -86,7 +86,6 @@ jobs: docker: name: Docker image runs-on: ubuntu-latest - needs: setup-and-upload permissions: contents: read packages: write From 8938b2aa66a01ad9f377b26e3a6575531b2b31ea Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:14:14 -0500 Subject: [PATCH 11/19] add curl --- .github/workflows/jobs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 4a5b2ff8bf..0def383ab5 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -21,7 +21,9 @@ jobs: - name: install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install venv - run: uv venv .venv -p 3.10 + run: | + apk add --no-cache curl + uv venv .venv -p 3.10 - name: install requirements run: | source .venv/bin/activate From c224e264b33f3a319395ea0833db680f09043aae Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:15:09 -0500 Subject: [PATCH 12/19] add curl properly --- .github/workflows/jobs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 0def383ab5..352fe20730 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -19,10 +19,11 @@ jobs: with: python-version: '3.10' - name: install uv - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - name: install venv run: | apk add --no-cache curl + curl -LsSf https://astral.sh/uv/install.sh | sh + - name: install venv + run: | uv venv .venv -p 3.10 - name: install requirements run: | From 06631d1a2dd53062b440c7568abcb36f6a147a45 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:16:29 -0500 Subject: [PATCH 13/19] source cargo --- .github/workflows/jobs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 352fe20730..490ca966ff 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -24,9 +24,11 @@ jobs: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install venv run: | + source $HOME/.cargo/env uv venv .venv -p 3.10 - name: install requirements run: | + source $HOME/.cargo/env source .venv/bin/activate uv pip install --upgrade -r requirements.txt uv pip install --upgrade -r requirements-rl.txt From 2ba270bd15219ea40f3f377082797cf1945b5adc Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:20:04 -0500 Subject: [PATCH 14/19] verify python version --- .github/workflows/jobs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 490ca966ff..26f2f38425 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -14,10 +14,10 @@ jobs: image: python:3.10-alpine steps: - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' + - name: Verify Python installation + run: | + ls -la /__t/Python/ + python --version - name: install uv run: | apk add --no-cache curl From 36176673ae30e8a629e73842a3f23ab672b5715b Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:24:53 -0500 Subject: [PATCH 15/19] install git --- .github/workflows/jobs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 26f2f38425..2c5d65b5c0 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -18,9 +18,11 @@ jobs: run: | ls -la /__t/Python/ python --version + - name: install curl and git + run: | + apk add --no-cache curl git - name: install uv run: | - apk add --no-cache curl curl -LsSf https://astral.sh/uv/install.sh | sh - name: install venv run: | From a219022f06e7732ac394eaecb69a42eb13a677b6 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:29:10 -0500 Subject: [PATCH 16/19] add build-base package --- .github/workflows/docker.yml | 46 ++++++++++++++++++++++++++++++++++++ .github/workflows/jobs.yml | 43 ++++----------------------------- 2 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..303951d324 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,46 @@ +name: Build and push Docker image + +on: + push: + branches: + - main + pull_request: + +jobs: + docker: + name: Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{secrets.GITHUB_TOKEN}} + - name: Log in to the Container registry + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.5.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # Add a version tag when a valid semver tag is pushed. + type=semver,pattern={{version}} + # Add the edge tag to every image to represent the latest commit to main + type=edge,branch=main + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.0 + with: + context: . + push: true + file: ./Dockerfile + tags: | + ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 2c5d65b5c0..d9081e4699 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -1,4 +1,4 @@ -name: setup +name: lint and test on: push: @@ -21,6 +21,9 @@ jobs: - name: install curl and git run: | apk add --no-cache curl git + - name: install build-base package + run: | + apk add --no-cache build-base - name: install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh @@ -89,41 +92,3 @@ jobs: # A warning is thrown here unnecessarily. tracking issue here: # https://github.com/github/vscode-github-actions/issues/222 token: ${{ secrets.CODECOV_TOKEN }} - - docker: - name: Docker image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Check out code - uses: actions/checkout@v3 - with: - submodules: recursive - token: ${{secrets.GITHUB_TOKEN}} - - name: Log in to the Container registry - uses: docker/login-action@v2.2.0 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4.5.0 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - # Add a version tag when a valid semver tag is pushed. - type=semver,pattern={{version}} - # Add the edge tag to every image to represent the latest commit to main - type=edge,branch=main - - name: Build and push Docker image - uses: docker/build-push-action@v4.1.0 - with: - context: . - push: true - file: ./Dockerfile - tags: | - ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} From cc89495e68db7c7f6a06f5d84c9431466d8a469f Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:29:53 -0500 Subject: [PATCH 17/19] Reset docker workflow settings --- .github/workflows/docker.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 303951d324..61b8a420a2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,10 +1,14 @@ -name: Build and push Docker image +name: "Docker: Build and push agent0 image" on: + workflow_dispatch: push: - branches: - - main - pull_request: + branches: ["main"] + tags: ["*"] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/agent0 jobs: docker: From 9b36a206249e4acf4fcc13817d0bf7d437e89cc2 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:34:23 -0500 Subject: [PATCH 18/19] switch to ubuntu --- .github/workflows/jobs.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index d9081e4699..b3ba752689 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -10,20 +10,13 @@ jobs: test-code: name: Lint and test runs-on: ubuntu-latest - container: - image: python:3.10-alpine steps: - uses: actions/checkout@v3 - - name: Verify Python installation - run: | - ls -la /__t/Python/ - python --version - - name: install curl and git - run: | - apk add --no-cache curl git - - name: install build-base package - run: | - apk add --no-cache build-base + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: 3.10 + token: ${{github.token}} - name: install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh From c0058d05de2badd8dbf4cb000d80c9306eb26220 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 23:35:10 -0500 Subject: [PATCH 19/19] set version properly --- .github/workflows/jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index b3ba752689..e506077343 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -15,7 +15,7 @@ jobs: - name: set up python uses: actions/setup-python@v4 with: - python-version: 3.10 + python-version: "3.10" token: ${{github.token}} - name: install uv run: |