Skip to content

Commit 5af66c2

Browse files
committed
build agent runner
1 parent 3e3cc2a commit 5af66c2

File tree

3 files changed

+246
-189
lines changed

3 files changed

+246
-189
lines changed

.github/workflows/release.yaml

+48-186
Original file line numberDiff line numberDiff line change
@@ -6,216 +6,78 @@ on:
66
- 'v*.*.*'
77

88
jobs:
9-
publish-packages:
10-
name: Push Packages
11-
runs-on: ubuntu-20.04
12-
strategy:
13-
matrix:
14-
os: [ubuntu-latest]
15-
python-version: ["3.10"]
16-
steps:
17-
- uses: actions/checkout@v4
18-
- uses: actions/setup-python@v4
19-
with:
20-
python-version: ${{ matrix.python-versions }}
21-
- uses: addnab/docker-run-action@v3
22-
with:
23-
image: valory/open-autonomy-user:latest
24-
options: -v ${{ github.workspace }}:/work
25-
run: |
26-
echo "Pushing Packages"
27-
cd /work
28-
export AUTHOR=$(grep 'service' packages/packages.json | awk -F/ '{print $2}' | head -1)
29-
autonomy init --reset --author $AUTHOR --ipfs --remote
30-
autonomy push-all
31-
publish-images:
32-
name: Publish Docker Images
33-
runs-on: ${{ matrix.os }}
34-
needs:
35-
- "publish-packages"
36-
strategy:
37-
matrix:
38-
os: [ubuntu-latest]
39-
python-version: ["3.10"]
40-
env:
41-
DOCKER_USER: ${{secrets.DOCKER_USER}}
42-
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
43-
steps:
44-
- uses: actions/checkout@v4
45-
with:
46-
fetch-depth: 0
47-
- name: Set up tag and vars
48-
uses: addnab/docker-run-action@v3
49-
with:
50-
image: valory/open-autonomy-user:latest
51-
options: -v ${{ github.workspace }}:/work
52-
run: |
53-
echo "Setting Tag Images"
54-
cd /work
55-
apt-get update && apt-get install git -y || exit 1
56-
git config --global --add safe.directory /work
57-
export TAG=$(git describe --exact-match --tags $(git rev-parse HEAD)) || exit 1
58-
if [ $? -eq 0 ]; then
59-
export TAG=`echo $TAG | sed 's/^v//'`
60-
else
61-
echo "You are not on a tagged branch"
62-
exit 1
63-
fi
64-
echo VERSION=$TAG> env.sh
65-
echo AUTHOR=$(grep 'service/' packages/packages.json | awk -F/ '{print $2}' | head -1) >> env.sh
66-
echo SERVICE=$(grep 'service/' packages/packages.json | awk -F/ '{print $3}' | head -1) >> env.sh
67-
echo AGENT=$(grep 'agent/' packages/packages.json | awk -F/ '{print $3}' | head -1) >> env.sh
68-
echo DEFAULT_IMAGE_TAG=$(cat packages/packages.json | grep agent/ | awk -F: '{print $2}' | tr -d '", ' | head -n 1) >> env.sh
69-
cat env.sh
70-
71-
- uses: addnab/docker-run-action@v3
72-
name: Build Images
73-
with:
74-
image: valory/open-autonomy-user:latest
75-
options: -v ${{ github.workspace }}:/work
76-
shell: bash
77-
run: |
78-
echo "Building Docker Images"
79-
cd /work
80-
pip install --upgrade poetry
81-
poetry install
82-
source env.sh || exit 1
83-
echo "Building images for $AUTHOR for service $SERVICE"
84-
autonomy init --reset --author $AUTHOR --ipfs --remote
85-
autonomy fetch $AUTHOR/$SERVICE --service --local || exit 1
86-
cd $SERVICE || exit 1
87-
autonomy build-image || exit 1
88-
autonomy build-image --version $VERSION || exit 1
89-
90-
- name: Docker login
91-
run: |
92-
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin
93-
- name: Docker Push
94-
run: |
95-
source env.sh
96-
echo "Pushing $DOCKER_USER/oar-$AGENT:$VERSION"
97-
echo "Pushing $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG"
98-
docker push $DOCKER_USER/oar-$AGENT:$VERSION
99-
docker push $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG
100-
101-
deploy-service-on-propel:
102-
name: Deploy service on propel
103-
environment: production
104-
needs:
105-
- "publish-packages"
106-
- "publish-images"
9+
build-agent-runner:
10710
runs-on: ${{ matrix.os }}
10811
strategy:
10912
matrix:
110-
os: [ubuntu-latest]
111-
python-version: ["3.10"]
112-
env:
113-
CMD: "propel -U ${{ vars.PROPEL_BASE_URL }}"
13+
os: [windows-latest, macos-14, macos-14-large ]
14+
defaults:
15+
run:
16+
shell: bash
11417
steps:
115-
- uses: actions/checkout@master
116-
- uses: actions/setup-python@v3
18+
- uses: actions/checkout@v3
19+
# Set up Python with setup-python action and add it to PATH
20+
- uses: actions/setup-python@v5
21+
id: setup-python
11722
with:
118-
python-version: ${{ matrix.python-versions }}
119-
- name: Install dependencies
120-
run: |
121-
sudo apt-get update --fix-missing
122-
sudo apt-get autoremove
123-
sudo apt-get autoclean
124-
python -m pip install --upgrade pip
125-
pip install propel-client open-autonomy
126-
127-
- name: Make use proxy instead of actual nlb by dns override
128-
run: |
129-
# for staging
130-
export IP_ADDR=$(dig +short balancer.tcp.propel.staging.autonolas.tech)
131-
echo -e "\n$IP_ADDR\tapp.propel.staging.valory.xyz\n" | sudo tee -a /etc/hosts
132-
133-
# for prod
134-
export IP_ADDR=$(dig +short balancer.tcp.propel.autonolas.tech)
135-
echo -e "\n$IP_ADDR\tapp.propel.valory.xyz\n" | sudo tee -a /etc/hosts
23+
python-version: "3.10"
13624

137-
- name: Login to propel
25+
- name: Add Python to PATH
13826
run: |
139-
$CMD login -u '${{ vars.PROPEL_USERNAME }}' -p '${{ secrets.PROPEL_PASSWORD }}'
140-
141-
- name: Do a deployment
142-
run: |
143-
# determine ipfs hash id
144-
export IPFS_HASH=$(jq '.dev | to_entries[] | select(.key | startswith("service"))| .value' -r ./packages/packages.json | head -n1)
145-
export SERVICE_PATH=service_for_propel
146-
147-
# fetch service file and check it published
148-
autonomy init --reset --author ci --ipfs --remote
149-
autonomy fetch $IPFS_HASH --service --alias $SERVICE_PATH
150-
151-
# get env vars from github actions
152-
echo '${{ toJSON(secrets) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' > github.vars
153-
echo >> github.vars
154-
echo '${{ toJSON(vars) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' >> github.vars
155-
source github.vars
156-
$CMD service deploy --name '${{ vars.SERVICE_NAME }}' --service-dir $SERVICE_PATH --service-ipfs-hash $IPFS_HASH --ingress-enabled true --keys '${{ vars.SERVICE_KEYS }}' --timeout 320
157-
158-
build-macos-pyinstaller:
159-
runs-on: ${{ matrix.os }}
160-
strategy:
161-
matrix:
162-
os: [ macos-14, macos-14-large ]
163-
164-
steps:
165-
- uses: actions/checkout@v3
166-
- uses: actions/setup-python@v4
167-
with:
168-
python-version: '3.10'
27+
echo "${{ steps.setup-python.outputs.python-path }}" >> $GITHUB_PATH
16928
17029
- name: Install and configure Poetry
171-
uses: snok/install-poetry@v1
172-
with:
173-
version: '1.4.0'
174-
virtualenvs-create: true
175-
virtualenvs-in-project: false
176-
virtualenvs-path: ~/my-custom-path
177-
installer-parallel: true
178-
179-
- name: Install dependencies
180-
run: poetry install
30+
run: pip install poetry
18131

182-
- name: Set arch environment variable for macos-latest-large
183-
if: contains(matrix.os, 'large')
184-
run: echo "OS_ARCH=x64" >> $GITHUB_ENV
185-
186-
- name: Set arch environment variable for other macOS versions
187-
if: ${{ !contains(matrix.os, 'large') }}
188-
run: echo "OS_ARCH=arm64" >> $GITHUB_ENV
189-
190-
- name: Build with PyInstaller
32+
- name: Build Agent Runner
19133
run: |
192-
poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots --hidden-import grpc --hidden-import openapi_core --collect-all google.protobuf --collect-all openapi_core --collect-all openapi_spec_validator --collect-all asn1crypto --hidden-import py_ecc --hidden-import pytz --onefile pyinstaller/trader_bin.py --name trader_bin_${{env.OS_ARCH}}
193-
- name: Upload Release Assets
194-
uses: actions/upload-artifact@v2
34+
make build-agent-runner
35+
36+
- name: rename the file
37+
if: runner.os != 'Windows'
38+
run: |
39+
export FILENAME=`echo -n agent_runner_${{runner.os}}_${{runner.arch}}|tr '[:upper:]' '[:lower:]'`
40+
echo "FILENAME=$FILENAME" >> $GITHUB_ENV;
41+
mv dist/agent_runner_bin dist/${FILENAME}
42+
43+
- name: rename the file
44+
if: runner.os == 'Windows'
45+
run: |
46+
export FILENAME=`echo -n agent_runner_${{runner.os}}_${{runner.arch}}.exe|tr '[:upper:]' '[:lower:]'`
47+
echo "FILENAME=$FILENAME" >> $GITHUB_ENV;
48+
mv dist/agent_runner_bin.exe dist/${FILENAME}
49+
50+
- name: Upload Release Assets Windows
51+
uses: actions/upload-artifact@v4
19552
with:
196-
name: trader_bin_${{env.OS_ARCH}}
197-
path: dist/trader_bin_${{env.OS_ARCH}}
53+
name: ${{env.FILENAME}}
54+
path: dist/${{env.FILENAME}}
19855

19956
upload-assets:
200-
needs: build-macos-pyinstaller
57+
needs: build-agent-runner
20158
runs-on: ubuntu-latest
202-
20359
steps:
20460
- name: Download artifacts
205-
uses: actions/download-artifact@v2
61+
uses: actions/download-artifact@v4
20662
with:
207-
name: trader_bin_x64
63+
name: agent_runner_macos_x64
20864
path: ./dist/
65+
20966
- name: Download artifacts
210-
uses: actions/download-artifact@v2
67+
uses: actions/download-artifact@v4
21168
with:
212-
name: trader_bin_arm64
69+
name: agent_runner_macos_arm64
21370
path: ./dist/
214-
71+
- name: Download artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: agent_runner_windows_x64.exe
75+
path: ./dist/
76+
- name: List files
77+
run: ls ./dist/
21578
- name: Publish Release
21679
uses: softprops/action-gh-release@v2
21780
if: startsWith(github.ref, 'refs/tags/')
21881
with:
21982
files: |
220-
./dist/trader_bin_x64
221-
./dist/trader_bin_arm64
83+
./dist/agent_runner*

Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,34 @@ fix-abci-app-specs:
105105

106106
protolint_install:
107107
GO111MODULE=on GOPATH=~/go go get -u -v github.com/yoheimuta/protolint/cmd/[email protected]
108+
109+
110+
111+
112+
.PHONY: build-agent-runner
113+
build-agent-runner:
114+
poetry lock
115+
poetry install
116+
poetry run pyinstaller \
117+
--collect-data eth_account \
118+
--collect-all aea \
119+
--collect-all aea_ledger_ethereum \
120+
--collect-all aea_ledger_cosmos \
121+
--collect-all aea_ledger_ethereum_flashbots \
122+
--collect-all asn1crypto \
123+
--collect-all autonomy \
124+
--collect-all backports.tarfile \
125+
--collect-all google.protobuf \
126+
--collect-all openapi_core \
127+
--collect-all openapi_spec_validator \
128+
--hidden-import aea_ledger_ethereum \
129+
--hidden-import aea_ledger_cosmos \
130+
--hidden-import aea_ledger_ethereum_flashbots \
131+
--hidden-import grpc \
132+
--hidden-import openapi_core \
133+
--hidden-import py_ecc \
134+
--hidden-import pytz \
135+
--onefile pyinstaller/trader_bin.py \
136+
--name agent_runner_bin
137+
138+
./dist/agent_runner_bin 1>/dev/null

0 commit comments

Comments
 (0)