run_all_demo_examples #221
This file contains hidden or 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: run_all_demo_examples | |
on: | |
push: | |
branches: [ main ] | |
schedule: | |
- cron: '0 0 */1 * *' # Runs at midnight every 1 days | |
workflow_dispatch: | |
env: | |
LICENSE_KEY: ${{ secrets.LICENSE_KEY }} | |
FAILURE_WEBHOOK: ${{secrets.FAILURE_WEBHOOK}} | |
ETHEREUM_RPC_URL: ${{secrets.ETHEREUM_RPC_URL}} | |
ARBITRUM_RPC_URL: ${{secrets.ARBITRUM_RPC_URL}} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
generate-matrix-of-demo-files: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# Step 1: Dynamically generate the list of Python files (run.py) in demo directory | |
- name: Find Python Files | |
id: set-matrix | |
run: | | |
brew install jq || sudo apt install jq | |
# Find all run.py files in the demo/ directory | |
files=$(find . -name run.py) | |
# Debug step: Print the files found (for troubleshooting) | |
echo "Files found: $files" | |
# Ensure the files are converted into a JSON array, skipping any empty results | |
if [ -z "$files" ]; then | |
echo "No files found!" | |
exit 1 | |
fi | |
# Convert the list of files into JSON format | |
files_json=$(echo "$files" | jq -R -s -c 'split("\n")[:-1]') | |
echo "Matrix JSON: $files_json" | |
new_file="example_backtest.py" | |
files_json=$(echo "$files_json" | jq -c --arg new_file "$new_file" '. + [$new_file]') | |
echo "Matrix JSON: $files_json" | |
# Set the matrix output for the next job | |
echo "matrix=$files_json" >> $GITHUB_OUTPUT | |
run-demo-files-macos: | |
needs: generate-matrix-of-demo-files | |
runs-on: macos-14 | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
file: ${{ fromJson(needs.generate-matrix-of-demo-files.outputs.matrix) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# - name: Authenticate to Google Cloud | |
# id: auth | |
# uses: google-github-actions/auth@v2 | |
# with: | |
# project_id: "dojo-405216" | |
# workload_identity_provider: "projects/557429359617/locations/global/workloadIdentityPools/github/providers/dojo-ci" | |
# service_account: "[email protected]" | |
# - name: Retrieve secrets from GCP Secrets Manager | |
# id: get-secrets | |
# uses: google-github-actions/get-secretmanager-secrets@v2 | |
# with: | |
# secrets: | | |
# NODE_API_KEY:557429359617/node_api_key_secret | |
# NODE_RPC_URL:557429359617/node_rpc_url_secret | |
# ARBITRUM_NODE_RPC_URL:557429359617/arbitrum_node_rpc_url_secret | |
# CODECOV_TOKEN:557429359617/codecov_token | |
# - name: Set up environment variable | |
# run: | | |
# echo "ETHEREUM_RPC_URL=https://${{ steps.get-secrets.outputs.NODE_RPC_URL}}?key=${{ steps.get-secrets.outputs.NODE_API_KEY }}" >> $GITHUB_ENV | |
# echo "ARBITRUM_RPC_URL=${{ steps.get-secrets.outputs.ARBITRUM_NODE_RPC_URL}}" >> $GITHUB_ENV | |
- name: Install dojo from pypi | |
uses: CompassLabs/workflows/.github/actions/setup_dojo_pypi@main | |
with: | |
python-version: 3.11 | |
#TODO use matrix of python versions | |
- name: Run Python Script | |
run: | | |
pip install mypy_extensions | |
pip install pytimeparse | |
echo ${{ matrix.file }} | |
# echo ${{ matrix.file }} | sed 's|./||' | sed 's|.py||' | sed 's|/|.|g' | xargs -n1 -I{} python cli_runner.py --module={} --no-dashboard | |
python ${{ matrix.file }} | |
- name: Send failure notification to AllQuiet | |
if: ${{ failure() }} | |
run: | | |
curl ${{ secrets.ALLQUIET_URL }} \ | |
-H "Content-Type: application/json" \ | |
--data '{"alertName":"${{ github.repository }} workflow ${{ github.workflow }} failed!","alertStatus":"Warning"}' | |
run-demo-files-ubuntu: | |
needs: generate-matrix-of-demo-files | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
file: ${{ fromJson(needs.generate-matrix-of-demo-files.outputs.matrix) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# - name: Authenticate to Google Cloud | |
# id: auth | |
# uses: google-github-actions/auth@v2 | |
# with: | |
# project_id: "dojo-405216" | |
# workload_identity_provider: "projects/557429359617/locations/global/workloadIdentityPools/github/providers/dojo-ci" | |
# service_account: "[email protected]" | |
# - name: Retrieve secrets from GCP Secrets Manager | |
# id: get-secrets | |
# uses: google-github-actions/get-secretmanager-secrets@v2 | |
# with: | |
# secrets: | | |
# NODE_API_KEY:557429359617/node_api_key_secret | |
# NODE_RPC_URL:557429359617/node_rpc_url_secret | |
# ARBITRUM_NODE_RPC_URL:557429359617/arbitrum_node_rpc_url_secret | |
# CODECOV_TOKEN:557429359617/codecov_token | |
# - name: Set up environment variable | |
# run: | | |
# echo "ETHEREUM_RPC_URL=https://${{ steps.get-secrets.outputs.NODE_RPC_URL}}?key=${{ steps.get-secrets.outputs.NODE_API_KEY }}" >> $GITHUB_ENV | |
# echo "ARBITRUM_RPC_URL=${{ steps.get-secrets.outputs.ARBITRUM_NODE_RPC_URL}}" >> $GITHUB_ENV | |
- name: Install dojo from pypi | |
uses: CompassLabs/workflows/.github/actions/setup_dojo_pypi@main | |
with: | |
python-version: 3.11 | |
#TODO use matrix of python versions | |
- name: Run Python Script | |
run: | | |
pip install mypy_extensions | |
pip install pytimeparse | |
echo ${{ matrix.file }} | |
# echo ${{ matrix.file }} | sed 's|./||' | sed 's|.py||' | sed 's|/|.|g' | xargs -n1 -I{} python cli_runner.py --module={} --no-dashboard | |
python ${{ matrix.file }} | |
# continue-on-error: true | |
# poetry run python ${{ matrix.file }} --run-length=10m --auto-close=True --dashboard_server_port=None --simulation-status-bar True | |
- name: Send failure notification to AllQuiet | |
if: ${{ failure() }} | |
run: | | |
curl ${{ secrets.ALLQUIET_URL }} \ | |
-H "Content-Type: application/json" \ | |
--data '{"alertName":"${{ github.repository }} workflow ${{ github.workflow }} failed!","alertStatus":"Warning"}' |