@@ -38,14 +38,30 @@ jobs:
3838 with :
3939 node-version : 22
4040
41- - name : Build wheel
42- run : pants package :OctoBot
41+ - name : Install Rust toolchain
42+ if : hashFiles('packages/*/crates/*/Cargo.toml') != ''
43+ uses : dtolnay/rust-toolchain@stable
44+ with :
45+ components : clippy
46+
47+ - name : Rust lint & tests
48+ if : hashFiles('packages/*/crates/*/Cargo.toml') != ''
49+ run : |
50+ cargo clippy --workspace -- -D warnings
51+ cargo test --workspace
52+
53+ - name : Install maturin
54+ if : hashFiles('packages/*/crates/*/pyproject.toml') != ''
55+ run : pip install maturin
4356
44- - name : Upload wheel artifact
57+ - name : Build wheels
58+ run : pants package :OctoBot $(pants list --filter-target-type=package_shell_command ::)
59+
60+ - name : Upload wheel artifacts
4561 uses : actions/upload-artifact@v7
4662 with :
4763 name : octobot-wheel
48- path : dist/octobot- *.whl
64+ path : dist/*.whl
4965 if-no-files-found : error
5066
5167 tests :
@@ -65,14 +81,28 @@ jobs:
6581 - packages/commons
6682 - packages/evaluators
6783 - packages/node
84+ - packages/flow
6885 - packages/services
86+ - packages/sync
6987 - packages/tentacles_manager
7088 - packages/trading
7189 - packages/trading_backend
7290
91+ env :
92+ USES_TENTACLES : ${{ matrix.package == 'octobot' || matrix.package == 'packages/node' || matrix.package == 'packages/flow' }}
93+
7394 steps :
7495 - uses : actions/checkout@v6
7596
97+ - name : Detect package features
98+ id : detect
99+ run : |
100+ if ls ${{ matrix.package }}/crates/*/Cargo.toml 1>/dev/null 2>&1; then
101+ echo "has_rust=true" >> $GITHUB_OUTPUT
102+ else
103+ echo "has_rust=false" >> $GITHUB_OUTPUT
104+ fi
105+
76106 - name : Set up Python ${{ matrix.version }}
77107 uses : actions/setup-python@v6
78108 with :
@@ -88,20 +118,34 @@ jobs:
88118 - name : Install OctoBot
89119 run : |
90120 pip3 install -r dev_requirements.txt
91- pip3 install dist/octobot- *.whl
121+ pip3 install dist/*.whl
92122
93123 - name : Lint package
94124 run : |
95125 if [ -f "${{ matrix.package }}/standard.rc" ]; then
96126 pylint --rcfile=${{ matrix.package }}/standard.rc ${{ matrix.package }}/
97- if [ $? -ne 1 ]; then exit 0; fi
127+ rc=$?
98128 else
99129 pylint --rcfile=standard.rc ${{ matrix.package }}/
100- if [ $? -ne 1 ]; then exit 0; fi
130+ rc=$?
101131 fi
132+ if [ $rc -eq 1 ]; then exit 1; fi
133+
134+ - name : Install Rust toolchain
135+ if : steps.detect.outputs.has_rust == 'true'
136+ uses : dtolnay/rust-toolchain@stable
137+ with :
138+ components : clippy
139+
140+ - name : Lint Rust crates
141+ if : steps.detect.outputs.has_rust == 'true'
142+ run : |
143+ for crate in ${{ matrix.package }}/crates/*/; do
144+ cargo clippy --manifest-path "$crate/Cargo.toml" -- -D warnings
145+ done
102146
103147 - name : Install tentacles
104- if : matrix.package == 'octobot '
148+ if : env.USES_TENTACLES == 'true '
105149 run : |
106150 mkdir -p output
107151 OctoBot tentacles -d packages/tentacles -p any_platform.zip
@@ -113,16 +157,27 @@ jobs:
113157 pytest tests -n auto --dist loadfile
114158 pytest --ignore=tentacles/Trading/Exchange tentacles -n auto --dist loadfile
115159 else
116- cd ${{ matrix.package }}
117- if [ "${{ matrix.package }}" = "packages/tentacles_manager" ] || [ "${{ matrix.package }}" = "packages/node" ]; then
118- pytest tests
160+ if [ " ${{ matrix.package }}" = "packages/node" ] || [ "${{ matrix.package }}" = "packages/flow" ]; then
161+ echo "Running tests from root dir to allow tentacles import"
162+ PYTHONPATH=.:$PYTHONPATH pytest ${{ matrix.package }}/ tests -n auto --dist loadfile
119163 else
120- pytest tests -n auto --dist loadfile
164+ cd ${{ matrix.package }}
165+ if [ "${{ matrix.package }}" = "packages/tentacles_manager" ]; then
166+ pytest tests
167+ else
168+ pytest tests -n auto --dist loadfile
169+ fi
121170 fi
122171 fi
123172 env :
124173 DISABLE_SENTRY : True
125174
175+ - name : Run Rust backend tests
176+ if : steps.detect.outputs.has_rust == 'true'
177+ run : |
178+ cd ${{ matrix.package }}
179+ pytest tests --backend=rust -v
180+
126181 docker :
127182 name : Build & Push Docker images
128183 needs : [ build, tests ]
@@ -618,6 +673,42 @@ jobs:
618673 asset_name : OctoBot_macos_arm64
619674 asset_content_type : application/x-binary
620675
676+ sync :
677+ name : Deploy Sync Server
678+ if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
679+ needs : [docker]
680+ environment :
681+ name : ${{ startsWith(github.ref, 'refs/tags/') && 'Production - Sync Server' || github.ref == 'refs/heads/master' && 'Staging - Sync Server' || 'Development - Sync Server' }}
682+ runs-on : ubuntu-latest
683+
684+ steps :
685+ - uses : actions/checkout@v6
686+
687+ - name : Install Ansible
688+ run : pip install ansible
689+
690+ - name : Install Galaxy requirements
691+ working-directory : infra/sync/ansible
692+ run : ansible-galaxy install -r requirements.yml
693+
694+ - name : Set up SSH key
695+ run : |
696+ mkdir -p infra/sync/ansible/inventories/${{ vars.ANSIBLE_ENV }}/.ssh
697+ echo "${{ secrets.ANSIBLE_SSH_KEY }}" > infra/sync/ansible/inventories/${{ vars.ANSIBLE_ENV }}/.ssh/id_ed25519
698+ chmod 600 infra/sync/ansible/inventories/${{ vars.ANSIBLE_ENV }}/.ssh/id_ed25519
699+
700+ - name : Deploy to ${{ vars.ANSIBLE_ENV }}
701+ working-directory : infra/sync/ansible
702+ env :
703+ ANSIBLE_VAULT_PASSWORD : ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
704+ ANSIBLE_HOST_KEY_CHECKING : " false"
705+ run : |
706+ ansible-playbook playbooks/deploy-octobot-sync.yml -i inventories/${{ vars.ANSIBLE_ENV }}
707+
708+ - name : Clean up SSH key
709+ if : always()
710+ run : rm -f infra/sync/ansible/inventories/${{ vars.ANSIBLE_ENV }}/.ssh/id_ed25519
711+
621712 notify :
622713 if : ${{ failure() }}
623714 needs :
@@ -628,6 +719,7 @@ jobs:
628719 - tentacles
629720 - release
630721 - version
722+ - sync
631723 uses : Drakkar-Software/.github/.github/workflows/failure_notify_workflow.yml@master
632724 secrets :
633725 DISCORD_GITHUB_WEBHOOK : ${{ secrets.DISCORD_GITHUB_WEBHOOK }}
0 commit comments