Integration #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Multi allocations | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
multi-allocations: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- restart: false | |
one_account: true | |
interval: 1m | |
id: 0 | |
number_of_providers: 1 | |
- restart: true | |
one_account: false | |
interval: 2m | |
id: 1 | |
number_of_providers: 1 | |
- restart: false | |
one_account: true | |
interval: 5m | |
id: 2 | |
number_of_providers: 1 | |
- restart: false | |
one_account: true | |
interval: 10m | |
id: 3 | |
number_of_providers: 1 | |
- restart: false | |
one_account: true | |
interval: 1m | |
id: 4 | |
number_of_providers: 2 | |
- restart: false | |
one_account: true | |
interval: 10m | |
id: 5 | |
number_of_providers: 2 | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download and install binaries | |
run: | | |
/bin/bash download_binaries.sh | |
- name: Install binaries | |
run: | | |
sudo mkdir -p /usr/lib/yagna | |
sudo mv golem/downloaded/plugins /usr/lib/yagna/plugins | |
sudo mv golem/downloaded/* /usr/bin/ | |
- name: Run central-net router | |
run: | | |
ya-sb-router -l tcp://127.0.0.1:5555& | |
echo CENTRAL_NET_HOST=127.0.0.1:5555 >> $GITHUB_ENV | |
- name: Prepare runtime | |
run: | | |
python advanced/prepare_runtime.py --mode central --payments full --num-providers ${{ matrix.number_of_providers }} | |
- name: Download private key 0 | |
run: | | |
set -x | |
curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" https://polygongas.org/keys/get/unused_accounts > downloaded_private_key_0.key | |
echo "Keys left $(curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" https://polygongas.org/keys/count/unused_accounts)" | |
# Check if the downloaded key is a valid private key | |
grep -qE '^[a-fA-F0-9]{64}$' downloaded_private_key_0.key || { echo "Error: File contents do not match expected format: $(cat downloaded_private_key_0.key)"; exit 1; } | |
- name: Download private key 1 | |
run: | | |
set -x | |
curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" https://polygongas.org/keys/get/unused_accounts > downloaded_private_key_1.key | |
echo "Keys left $(curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" https://polygongas.org/keys/count/unused_accounts)" | |
# Check if the downloaded key is a valid private key | |
grep -qE '^[a-fA-F0-9]{64}$' downloaded_private_key_1.key || { echo "Error: File contents do not match expected format: $(cat downloaded_private_key_1.key)"; exit 1; } | |
- name: Run requestor second account | |
if: matrix.one_account != true | |
run: | | |
cd golem/requestor | |
yagna service run& | |
sleep 4 | |
yagna id create --password= --from-private-key=$(cat ../../downloaded_private_key_0.key) identity0 | |
yagna app-key create --id identity0 dev_req | sed 's/^/\YAGNA_REQUESTOR_APPKEY=/' >> $GITHUB_ENV | |
echo YAGNA_ACCOUNT_0=$(yagna id show identity0 | grep -oP '(?<=nodeId: )[^\s]+') >> $GITHUB_ENV | |
- name: Run requestor one account | |
if: matrix.one_account | |
run: | | |
cd golem/requestor | |
echo "YAGNA_AUTOCONF_ID_SECRET=$(cat ../../downloaded_private_key_0.key)" >> .env | |
yagna service run& | |
sleep 4 | |
yagna app-key create dev_req | sed 's/^/\YAGNA_REQUESTOR_APPKEY=/' >> $GITHUB_ENV | |
echo YAGNA_ACCOUNT_0=$(yagna id show | grep -oP '(?<=nodeId: )[^\s]+') >> $GITHUB_ENV | |
- name: Restart requestor if needed | |
if: matrix.restart | |
run: | | |
cd golem/requestor | |
yagna service shutdown | |
sleep 4 | |
yagna service run& | |
sleep 4 | |
- name: Set payment interval | |
run: | | |
cd golem/requestor | |
yagna payment process set --account $YAGNA_ACCOUNT_0 --interval ${{ matrix.interval }} | |
yagna payment process info --account $YAGNA_ACCOUNT_0 | |
- name: Run providers | |
run: | | |
sudo chown $USER /dev/kvm | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
cd golem/provider_$i | |
cat .env | |
golemsp setup --no-interactive | |
yagna service run& | |
sleep 6 | |
ya-provider run& | |
sleep 4 | |
env > yagnadir/env.log | |
cd ../.. | |
done | |
env: | |
YA_CONSENT_EXTERNAL: "allow" | |
- name: Run allocation double activity sample | |
run: | | |
cd examples/multi-allocation-double-activity | |
echo "FUNDER_PRIVATE_KEY=0x$(cat ../../downloaded_private_key_1.key)" >> .env | |
echo "SPENDER_ADDRESS=$YAGNA_ACCOUNT_0" >> .env | |
npm install --silent | |
node index.mjs | |
- name: Wait for payments | |
run: | | |
cd reports | |
npm install --silent | |
node wait_for_payments.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Stop requestor | |
if: always() | |
run: | | |
cd golem/requestor | |
yagna service shutdown | |
- name: Stop providers | |
if: always() | |
run: | | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
cd golem/provider_$i | |
yagna service shutdown | |
cd ../.. | |
done | |
sleep 5 | |
- name: Requestor order items | |
run: | | |
cd reports | |
node list_order_items.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Requestor activities and agreements | |
run: | | |
cd reports | |
node list_activities.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Providers activities and agreements | |
run: | | |
cd reports | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
YAGNA_DATADIR=../golem/provider_$i/yagnadir node list_activities.js | |
done | |
- name: Requestor payments | |
run: | | |
cd reports | |
node list_payments.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Providers payments | |
run: | | |
cd reports | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
YAGNA_DATADIR=../golem/provider_$i/yagnadir node list_payments.js | |
done | |
- name: Requestor debit notes | |
run: | | |
cd reports | |
node list_debit_notes.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Providers debit notes | |
run: | | |
cd reports | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
YAGNA_DATADIR=../golem/provider_$i/yagnadir node list_debit_notes.js | |
done | |
- name: Requestor allocation expenditures | |
run: | | |
cd reports | |
node list_expenditures.js | |
env: | |
YAGNA_DATADIR: ../golem/requestor/yagnadir | |
- name: Prepare logs | |
if: always() | |
run: | | |
# remove image cache from upload | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
rm -r golem/provider_$i/providerdir/exe-unit/cache | |
done | |
tar -cf data_${{ matrix.id }}.tar golem/requestor/yagnadir | |
# append provider files | |
for i in $(seq 0 $((${{ matrix.number_of_providers }} - 1))); do | |
tar -rf data_${{ matrix.id }}.tar golem/provider_$i/providerdir | |
done | |
xz data_${{ matrix.id }}.tar | |
- name: Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: data_${{ matrix.id }}.tar.xz | |
path: data_${{ matrix.id }}.tar.xz | |
- name: Upload used private key back to the server | |
if: always() | |
run: | | |
grep -qE '^[a-fA-F0-9]{64}$' downloaded_private_key_0.key || { echo "Error: File contents do not match expected format: $(cat downloaded_private_key_0.key)"; exit 1; } | |
curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" -d $(cat downloaded_private_key_0.key) https://polygongas.org/keys/add/used_accounts | |
grep -qE '^[a-fA-F0-9]{64}$' downloaded_private_key_1.key || { echo "Error: File contents do not match expected format: $(cat downloaded_private_key_0.key)"; exit 1; } | |
curl -sSL -H "Authorization: Bearer ${{ secrets.PRIVATE_KEY_SERVER_KEY }}" -d $(cat downloaded_private_key_1.key) https://polygongas.org/keys/add/used_accounts |