name: '🔎 Lynx Testnet Example'

on:
  schedule:
    - cron: "0 * * * *"  # Every hour
  pull_request:
    branches:
      - main
      - v*.*.*
      - epic-*
  workflow_dispatch:

env: # TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
  DEMO_L1_PROVIDER_URI: "https://sepolia.infura.io/v3/3747007a284045d483c342fb39889a30"
  DEMO_L2_PROVIDER_URI: "https://polygon-amoy.infura.io/v3/3747007a284045d483c342fb39889a30"
  COLLECT_PROFILER_STATS: ""  # any value is fine

jobs:
  lynx-test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ "3.10" ]

    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Install latest Rust stable
        uses: dtolnay/rust-toolchain@stable

      - id: setup_python
        name: Set up Python ${{ matrix.python-version }} Environment
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - id: python_cache
        name: Retrieve Cached Python Dependencies
        uses: actions/cache@v3
        with:
          path: ${{ env.pythonLocation }}
          key: ${{ runner.os }}-pip-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('dev-requirements.txt', 'requirements.txt') }}

      - name: Upgrade pip
        if: steps.python_cache.outputs.cache-hit != 'true'
        run: python -m pip install --upgrade pip

      - name: Install packages (incl. updated code)
        run: pip install .[dev]

      - name: Check CLI Entrypoint
        run: nucypher --help

      - name: Check Python Entrypoint
        run: python -c "import nucypher; print(nucypher.__version__)"

      - name: Lynx testnet script
        run: python examples/testnet_simple_taco.py
