|
1 | | -name: Build |
| 1 | +name: CI |
2 | 2 |
|
3 | | -on: push |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + - 'release/**' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - dev |
| 13 | + - 'release/**' |
4 | 14 |
|
5 | 15 | jobs: |
6 | 16 | build: |
7 | | - name: Build |
| 17 | + name: Lint, Build & Unit, E2E Tests |
8 | 18 | runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: read |
| 22 | + env: |
| 23 | + INTERNAL_EVENT: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} |
9 | 24 |
|
10 | 25 | steps: |
11 | 26 | - name: Checkout code |
12 | | - uses: actions/checkout@v3 |
| 27 | + uses: actions/checkout@v5 |
13 | 28 |
|
14 | 29 | - name: Install Node.js |
15 | 30 | uses: actions/setup-node@v3 |
|
34 | 49 | run: pnpm run build |
35 | 50 |
|
36 | 51 | - name: Release a nightly build |
| 52 | + if: env.INTERNAL_EVENT == 'true' |
37 | 53 | run: pnpx pkg-pr-new publish |
| 54 | + |
| 55 | + - name: Checkout lattice-simulator |
| 56 | + if: env.INTERNAL_EVENT == 'true' |
| 57 | + uses: actions/checkout@v5 |
| 58 | + with: |
| 59 | + repository: GridPlus/lattice-simulator |
| 60 | + path: lattice-simulator |
| 61 | + token: ${{ secrets.GRIDPLUS_SIM_PAT }} |
| 62 | + |
| 63 | + - name: Install simulator dependencies |
| 64 | + if: env.INTERNAL_EVENT == 'true' |
| 65 | + working-directory: lattice-simulator |
| 66 | + run: pnpm install |
| 67 | + |
| 68 | + - name: Start simulator in background |
| 69 | + if: env.INTERNAL_EVENT == 'true' |
| 70 | + working-directory: lattice-simulator |
| 71 | + env: |
| 72 | + CI: '1' |
| 73 | + DEBUG_SIGNING: '1' |
| 74 | + DEBUG: 'lattice*' |
| 75 | + LATTICE_MNEMONIC: 'test test test test test test test test test test test junk' |
| 76 | + PORT: '3000' |
| 77 | + DEVICE_ID: 'SD0001' |
| 78 | + PASSWORD: '12345678' |
| 79 | + PAIRING_SECRET: '12345678' |
| 80 | + ENC_PW: '12345678' |
| 81 | + run: | |
| 82 | + pnpm run dev > simulator.log 2>&1 & |
| 83 | + echo $! > simulator.pid |
| 84 | + echo "Simulator PID: $(cat simulator.pid)" |
| 85 | +
|
| 86 | + # Wait for simulator to be ready |
| 87 | + echo "Waiting for simulator to start..." |
| 88 | + for i in {1..30}; do |
| 89 | + if curl -s http://localhost:3000 > /dev/null 2>&1; then |
| 90 | + echo "Simulator is ready!" |
| 91 | + break |
| 92 | + fi |
| 93 | + if [ $i -eq 30 ]; then |
| 94 | + echo "Simulator failed to start within 30 seconds" |
| 95 | + cat simulator.log |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | + sleep 1 |
| 99 | + done |
| 100 | +
|
| 101 | + - name: Run SDK e2e tests with simulator |
| 102 | + if: env.INTERNAL_EVENT == 'true' |
| 103 | + working-directory: ${{ github.workspace }} |
| 104 | + env: |
| 105 | + CI: '1' |
| 106 | + DEBUG_SIGNING: '1' |
| 107 | + baseUrl: 'http://127.0.0.1:3000' |
| 108 | + DEVICE_ID: 'SD0001' |
| 109 | + PASSWORD: '12345678' |
| 110 | + PAIRING_SECRET: '12345678' |
| 111 | + ENC_PW: '12345678' |
| 112 | + APP_NAME: 'lattice-manager' |
| 113 | + run: pnpm run e2e --reporter=basic |
| 114 | + |
| 115 | + - name: Show simulator logs on failure |
| 116 | + if: failure() && env.INTERNAL_EVENT == 'true' |
| 117 | + working-directory: lattice-simulator |
| 118 | + run: | |
| 119 | + echo "=== Simulator logs ===" |
| 120 | + cat simulator.log || echo "No simulator logs found" |
| 121 | +
|
| 122 | + - name: Stop simulator |
| 123 | + if: always() && env.INTERNAL_EVENT == 'true' |
| 124 | + working-directory: lattice-simulator |
| 125 | + run: | |
| 126 | + if [ -f simulator.pid ]; then |
| 127 | + kill $(cat simulator.pid) || true |
| 128 | + fi |
0 commit comments