/ .forgejo / workflows / ci.yml.bak
ci.yml.bak
  1  # Forgejo CI/CD for ACDC Wallet
  2  name: Mobile Wallet CI
  3  
  4  on:
  5    push:
  6      branches: [main, develop]
  7    pull_request:
  8      branches: [main]
  9  
 10  jobs:
 11    lint:
 12      name: Lint
 13      runs-on: native
 14      steps:
 15        - uses: actions/checkout@v4
 16  
 17        - uses: actions/setup-node@v4
 18          with:
 19            node-version: '20'
 20  
 21        - name: Install dependencies
 22          run: yarn install --frozen-lockfile
 23  
 24        - name: Lint
 25          run: yarn lint
 26  
 27    typecheck:
 28      name: Type Check
 29      runs-on: native
 30      steps:
 31        - uses: actions/checkout@v4
 32  
 33        - uses: actions/setup-node@v4
 34          with:
 35            node-version: '20'
 36  
 37        - name: Install dependencies
 38          run: yarn install --frozen-lockfile
 39  
 40        - name: Type check
 41          run: yarn typecheck
 42  
 43    test:
 44      name: Test
 45      runs-on: native
 46      needs: [lint, typecheck]
 47      steps:
 48        - uses: actions/checkout@v4
 49  
 50        - uses: actions/setup-node@v4
 51          with:
 52            node-version: '20'
 53  
 54        - name: Install dependencies
 55          run: yarn install --frozen-lockfile
 56  
 57        - name: Run tests
 58          run: yarn test:coverage
 59  
 60        - name: Check coverage threshold
 61          run: |
 62            COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
 63            if (( $(echo "$COVERAGE < 80" | bc -l) )); then
 64              echo "Coverage $COVERAGE% below 80% threshold"
 65              exit 1
 66            fi
 67  
 68    build:
 69      name: Build
 70      runs-on: native
 71      needs: test
 72      steps:
 73        - uses: actions/checkout@v4
 74  
 75        - uses: actions/setup-node@v4
 76          with:
 77            node-version: '20'
 78  
 79        - name: Install dependencies
 80          run: yarn install --frozen-lockfile
 81  
 82        - name: Expo export (web)
 83          run: npx expo export --platform web
 84  
 85        - name: Upload build artifacts
 86          uses: actions/upload-artifact@v4
 87          with:
 88            name: web-build
 89            path: dist/
 90  
 91    radicle-sync:
 92      name: Radicle Sync
 93      runs-on: native
 94      if: github.ref == 'refs/heads/main' && github.event_name == 'push'
 95      steps:
 96        - name: Checkout from Forgejo
 97          uses: actions/checkout@v4
 98          with:
 99            fetch-depth: 0
100            path: forgejo-src
101  
102        - name: Sync to Radicle
103          run: |
104            set -e
105            export PATH=$HOME/.radicle/bin:$PATH
106            RID="rad:zBYpyrBkSbQEf6sQ8YhxwkuJr6ni"
107  
108            rm -rf radicle-repo
109            NODE_ID=$(rad self --nid 2>/dev/null || rad self | grep -oP 'Node ID \(NID\): \K[a-z0-9]+')
110            echo "Local node ID: $NODE_ID"
111  
112            if ! rad clone "$RID" radicle-repo 2>&1; then
113              echo "rad clone failed, initializing from Forgejo source"
114              rm -rf radicle-repo
115              mkdir -p radicle-repo
116              cd radicle-repo
117              git init
118              git remote add rad "rad://${RID#rad:}/$NODE_ID"
119              git remote add forgejo ../forgejo-src
120              git fetch forgejo main
121              git checkout -b main forgejo/main
122              git push rad main
123              echo "Radicle sync complete (initialized)"
124              exit 0
125            fi
126  
127            cd radicle-repo
128            git remote add forgejo ../forgejo-src 2>/dev/null || git remote set-url forgejo ../forgejo-src
129            git fetch forgejo main
130            git checkout main 2>/dev/null || git checkout -b main
131  
132            if ! git merge --ff-only forgejo/main 2>/dev/null; then
133              echo "Fast-forward failed, forcing sync to Forgejo state"
134              git reset --hard forgejo/main
135            fi
136  
137            EXPECTED_COMMIT=$(git rev-parse HEAD)
138            echo "Expected commit: $EXPECTED_COMMIT"
139  
140            git push rad main || echo "Push command returned error (may be broken pipe)"
141  
142            sleep 2
143            RADICLE_HEAD=$(git -C ~/.radicle/storage/${RID#rad:} rev-parse --short=7 HEAD 2>/dev/null)
144            if [ "${EXPECTED_COMMIT:0:7}" = "$RADICLE_HEAD" ]; then
145              echo "Radicle sync verified: $RADICLE_HEAD"
146            else
147              echo "ERROR: Radicle sync verification failed"
148              echo "Expected: ${EXPECTED_COMMIT:0:7}, Got: $RADICLE_HEAD"
149              exit 1
150            fi