name: Nutshell integration

on:
  push:
    branches: [main]
  pull_request:
    branches:
      - main
      - 'v[0-9]*.[0-9]*.x'  # Match version branches like v0.13.x, v1.0.x, etc.
  release:
    types: [created]

# Cancel previous runs on same PR
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  nutshell-integration-tests:
    name: Nutshell Mint Integration Tests
    runs-on: self-hosted
    timeout-minutes: 30
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - uses: cachix/cachix-action@v16
        with:
          name: cashudevkit
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          useDaemon: false
        continue-on-error: true
      - name: Test Nutshell
        run: nix develop -i -L .#integration --command just test-nutshell
      - name: Show logs if tests fail
        if: failure()
        run: docker logs nutshell

  nutshell-wallet-integration-tests:
    name: Nutshell Wallet Integration Tests
    runs-on: self-hosted
    timeout-minutes: 30
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - uses: cachix/cachix-action@v16
        with:
          name: cashudevkit
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          useDaemon: false
        continue-on-error: true
      - name: Test Nutshell Wallet
        run: nix develop -i -L .#integration --command just nutshell-wallet-itest
      - name: Show Docker logs if tests fail
        if: failure()
        run: docker logs nutshell-wallet || true
