diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index b286852..7c89ec0 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -30,26 +30,6 @@ jobs: - name: Run black run: black --check app tests scripts - test: - runs-on: [linux, docker] - container: - image: catthehacker/ubuntu:act-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - set -x - python -m pip install --upgrade pip - pip install pytest pytest-asyncio httpx - pip install nicegui fastapi uvicorn yfinance polars pandas pydantic pyyaml - pip list - - name: Run tests - run: pytest -v --tb=short - type-check: runs-on: [linux, docker] container: @@ -70,5 +50,25 @@ jobs: - name: Run mypy run: | echo "Running mypy on core modules..." - mypy app/core app/models app/strategies app/services app/domain --ignore-missing-imports --show-error-codes --show-traceback - echo "Type check completed successfully" \ No newline at end of file + mypy app/core app/models app/strategies app/services app/domain --show-error-codes --show-traceback + echo "Type check completed successfully" + + test: + runs-on: [linux, docker] + container: + image: catthehacker/ubuntu:act-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: | + set -x + python -m pip install --upgrade pip + pip install pytest pytest-asyncio httpx + pip install nicegui fastapi uvicorn yfinance polars pandas pydantic pyyaml + pip list + - name: Run tests + run: pytest -v --tb=short diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index ef01deb..4101823 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -1,98 +1,31 @@ name: Build and Deploy on: - push: + workflow_run: + workflows: [CI] + types: [completed] branches: [main] workflow_dispatch: env: REGISTRY: ${{ vars.REGISTRY || '10.100.0.2:3000' }} IMAGE_NAME: ${{ github.repository }} + RESOLVED_SHA: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} + RESOLVED_REF: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }} jobs: - lint: - runs-on: [linux, docker] - container: - image: catthehacker/ubuntu:act-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install ruff black - - name: Run ruff - run: ruff check app tests scripts - - name: Run black - run: black --check app tests scripts - - test: - runs-on: [linux, docker] - container: - image: catthehacker/ubuntu:act-latest - env: - APP_ENV: test - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - set -x - python -m pip install --upgrade pip - pip install pytest pytest-asyncio httpx - pip install nicegui fastapi uvicorn yfinance polars pandas pydantic pyyaml databento - pip list - - name: Run tests - run: | - pytest \ - tests/test_pricing.py \ - tests/test_strategies.py \ - tests/test_portfolio.py \ - tests/test_turnstile.py \ - tests/test_workspace.py \ - tests/test_hedge_contract_count.py \ - tests/test_backtest_settings.py \ - -v --tb=short - - type-check: - runs-on: [linux, docker] - container: - image: catthehacker/ubuntu:act-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - set -x - python -m pip install --upgrade pip - pip install mypy types-requests - pip install nicegui fastapi uvicorn yfinance polars pandas pydantic pyyaml databento - pip list - - name: Show working directory - run: pwd && ls -la - - name: Run mypy - run: | - echo "Running mypy on core modules..." - mypy app/core app/models app/strategies app/services app/domain --ignore-missing-imports --show-error-codes --show-traceback - echo "Type check completed successfully" - build: + if: | + github.event_name == 'workflow_dispatch' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') runs-on: [linux, docker] - needs: [lint, test] container: image: catthehacker/ubuntu:act-latest steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ env.RESOLVED_SHA }} - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -115,14 +48,16 @@ jobs: context: . push: true tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RESOLVED_SHA }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest provenance: false deploy: runs-on: [linux, docker] needs: build - if: github.ref == 'refs/heads/main' + if: | + github.event_name == 'workflow_dispatch' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') container: image: catthehacker/ubuntu:act-latest env: @@ -131,7 +66,7 @@ jobs: DEPLOY_PORT: ${{ vars.DEPLOY_PORT || '22' }} DEPLOY_PATH: ${{ vars.DEPLOY_PATH || '/opt/vault-dash' }} DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} - APP_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + APP_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RESOLVED_SHA }} APP_ENV: production APP_NAME: Vault Dashboard APP_PORT: "8000" @@ -140,6 +75,8 @@ jobs: DATABENTO_API_KEY: ${{ secrets.DATABENTO_API_KEY }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ env.RESOLVED_SHA }} - name: Install dependencies run: |