Skip to content

Commit f3449db

Browse files
authored
Merge pull request #1254 from Mentra-Community/dev
Dev
2 parents 31bbfcc + 7f0d1a4 commit f3449db

File tree

5,522 files changed

+546327
-2981623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,522 files changed

+546327
-2981623
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Mentra-Community/core

.github/scripts/clean-runner.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Script to clean up self-hosted runner environment
3+
4+
echo "Cleaning up self-hosted runner environment..."
5+
6+
# Clean up pnpm caches and stores
7+
echo "Cleaning pnpm caches..."
8+
rm -rf ~/.pnpm-store
9+
rm -rf ~/.cache/pnpm
10+
rm -rf ~/.local/share/pnpm
11+
rm -rf ~/.pnpm
12+
13+
# Clean up work directories
14+
echo "Cleaning work directories..."
15+
for dir in /home/*/actions-runner*/_work/*/; do
16+
if [ -d "$dir" ]; then
17+
echo "Cleaning $dir"
18+
find "$dir" -name "node_modules" -type d -prune -exec rm -rf {} +
19+
find "$dir" -name ".pnpm-store" -type d -prune -exec rm -rf {} +
20+
find "$dir" -name ".pnpm" -type d -prune -exec rm -rf {} +
21+
fi
22+
done
23+
24+
# Clean up npm/yarn caches (in case they're used)
25+
echo "Cleaning npm/yarn caches..."
26+
npm cache clean --force 2>/dev/null || true
27+
yarn cache clean 2>/dev/null || true
28+
29+
# Clean up gradle caches
30+
echo "Cleaning gradle caches..."
31+
rm -rf ~/.gradle/caches/*
32+
33+
echo "Cleanup complete!"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Self-Hosted Runner Guide for MentraOS
2+
3+
## Overview
4+
5+
This guide helps you set up and maintain self-hosted GitHub Actions runners for MentraOS builds.
6+
7+
## Key Issues and Solutions
8+
9+
### 1. PNPM Store Permission Issues
10+
11+
**Problem**: `ERR_PNPM_ENOENT` errors when pnpm tries to use global store paths.
12+
13+
**Solution**: Configure pnpm to use project-local stores:
14+
15+
```yaml
16+
- name: Configure pnpm store
17+
working-directory: ./mobile
18+
run: |
19+
pnpm config set store-dir .pnpm-store
20+
21+
- name: Install dependencies
22+
working-directory: ./mobile
23+
run: pnpm install --no-frozen-lockfile
24+
env:
25+
PNPM_HOME: ${{ github.workspace }}/mobile/.pnpm
26+
PNPM_STORE_PATH: ${{ github.workspace }}/mobile/.pnpm-store
27+
```
28+
29+
### 2. Runner Cleanup
30+
31+
Self-hosted runners persist state between runs. Clean workspaces regularly:
32+
33+
```bash
34+
# Run on the self-hosted runner VM
35+
chmod +x .github/scripts/clean-runner.sh
36+
.github/scripts/clean-runner.sh
37+
```
38+
39+
### 3. Concurrent Jobs
40+
41+
By default, one runner = one job at a time. For parallel builds:
42+
43+
```bash
44+
# Install multiple runners on same VM
45+
cd ~
46+
for i in {1..3}; do
47+
mkdir actions-runner-$i && cd actions-runner-$i
48+
curl -o actions-runner-linux-x64-2.326.0.tar.gz -L [runner-url]
49+
tar xzf actions-runner-linux-x64-2.326.0.tar.gz
50+
./config.sh --url https://github.com/Mentra-Community/MentraOS --token [TOKEN] --name "runner-$i"
51+
sudo ./svc.sh install
52+
sudo ./svc.sh start
53+
cd ..
54+
done
55+
```
56+
57+
### 4. Best Practices
58+
59+
1. **Use local stores**: Avoid global pnpm/npm stores
60+
2. **Clean workspaces**: Remove build artifacts between runs
61+
3. **Monitor disk space**: Android builds use lots of space
62+
4. **Label runners**: Use labels like `android`, `heavy-build`
63+
5. **Fallback strategy**: Keep some jobs on GitHub-hosted runners
64+
65+
### 5. Recommended VM Specs
66+
67+
- **For Android builds**: 8+ vCPUs, 32GB RAM (D8as_v5 on Azure)
68+
- **Concurrent builds**: 16 vCPUs, 64GB RAM (D16as_v5)
69+
- **Disk**: 256GB+ SSD
70+
71+
### 6. Monitoring
72+
73+
```bash
74+
# Check runner status
75+
sudo systemctl status 'actions.runner.*.service'
76+
77+
# View logs
78+
journalctl -u actions.runner.Mentra-Community-MentraOS.* -f
79+
80+
# Check disk usage
81+
df -h
82+
83+
# Monitor CPU/RAM
84+
htop
85+
```
86+
87+
### 7. Emergency Fixes
88+
89+
If builds are failing:
90+
91+
1. SSH into runner VM
92+
2. Run cleanup script: `.github/scripts/clean-runner.sh`
93+
3. Restart runner services: `sudo systemctl restart 'actions.runner.*.service'`
94+
4. Check GitHub Actions runner page for connection status
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Mobile App Jest Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "mobile/**"
7+
- ".github/workflows/augmentos-manager-jest.yml"
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: self-hosted
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "18"
22+
23+
- name: Install pnpm
24+
run: |
25+
npm install -g pnpm@8
26+
pnpm --version
27+
28+
- name: Configure pnpm store
29+
working-directory: ./mobile
30+
run: |
31+
# Use local store to avoid permission issues
32+
pnpm config set store-dir .pnpm-store
33+
34+
- name: Install dependencies
35+
working-directory: ./mobile
36+
run: pnpm install --no-frozen-lockfile
37+
env:
38+
PNPM_HOME: ${{ github.workspace }}/mobile/.pnpm
39+
PNPM_STORE_PATH: ${{ github.workspace }}/mobile/.pnpm-store
40+
41+
- name: Run Jest tests
42+
working-directory: ./mobile
43+
run: pnpm test
44+
env:
45+
CI: true
Lines changed: 25 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Name of the workflow
2-
name: Deploy AugmentOS Cloud ☁️ Dev environment
2+
name: Test AugmentOS Cloud ☁️
33

4-
# Trigger on pushes to isaiah/cloud branch
4+
# trigger
55
on:
66
push:
7-
branches: [ "isaiah/cloud" ]
8-
# Optionally, filter paths if you only want to deploy on changes to augmentos_cloud
9-
# paths:
10-
# - 'augmentos_cloud/**'
7+
paths:
8+
- "cloud/**"
9+
- ".github/workflows/cloud.yml"
1110

12-
# We use two jobs: build and deploy, for modularity and future scalability
1311
jobs:
1412
build_and_test:
1513
name: Build & Test
@@ -18,7 +16,7 @@ jobs:
1816
# (Optional) Specify Node environment, could also set BUN_ENV if needed.
1917
NODE_ENV: development
2018
# If Bun version is to be pinned, we can specify it here.
21-
BUN_VERSION: # e.g. "1.2.0" or leave blank for latest
19+
BUN_VERSION: # e.g. "1.2.0" or leave blank for latest
2220
steps:
2321
# 1. Checkout the repository
2422
- name: Checkout code
@@ -32,7 +30,7 @@ jobs:
3230
uses: oven-sh/setup-bun@v2
3331
with:
3432
bun-version: ${{ env.BUN_VERSION || 'latest' }}
35-
# ^ This installs Bun on the runner, allowing us to use the `bun` command​:contentReference[oaicite:15]{index=15}.
33+
# ^ This installs Bun on the runner, allowing us to use the `bun` command
3634

3735
# 3. Restore cached dependencies to speed up build if possible
3836
- name: Cache Bun dependencies
@@ -41,37 +39,41 @@ jobs:
4139
# Path to Bun's global package cache on the runner
4240
path: ~/.bun/install/cache
4341
# Key includes OS and lockfile hash. If bun.lockb (lockfile) hasn't changed, cache hits.
44-
key: ${{ runner.os }}-bun-${{ hashFiles('augmentos_cloud/bun.lockb') }}
42+
key: ${{ runner.os }}-bun-${{ hashFiles('cloud/bun.lockb') }}
4543
# In case of partial match, allow restore with just OS identifier (fallback).
4644
restore-keys: |
4745
${{ runner.os }}-bun-
48-
# ^ Uses GitHub cache to store Bun's package cache for faster installs​:contentReference[oaicite:16]{index=16}.
49-
50-
# 4. Install project dependencies using Bun
46+
# ^ Uses GitHub cache to store Bun's package cache for faster installs
5147
- name: Install Dependencies
52-
working-directory: augmentos_cloud
53-
run: bun install
48+
working-directory: cloud
49+
run: bun run setup-deps
50+
51+
# 3. build other projects
52+
- name: Build all projects
53+
working-directory: cloud
54+
run: bun run build
55+
5456
# ^ Installs NPM packages. Bun uses its lockfile to ensure deterministic installs.
5557
# If cache was restored, this will be fast as packages are already downloaded.
5658

5759
# 5. Run linter to ensure code quality
58-
- name: Lint code
59-
working-directory: augmentos_cloud
60-
run: bun run lint
60+
#- name: Lint code
61+
# working-directory: cloud
62+
# run: bun run lint
6163
# ^ Runs the lint script (assumes package.json has a "lint" script or use bunx directly for ESLint).
6264
# Linting is done before tests to fail fast on syntax/style issues​:contentReference[oaicite:17]{index=17}.
6365

6466
# 6. Run tests to verify functionality
6567
- name: Run tests
66-
working-directory: augmentos_cloud
68+
working-directory: cloud/packages/cloud
6769
run: bun run test
6870
# ^ Executes the test suite (e.g., via Jest, Bun's built-in test runner, or another framework).
6971
# If any tests fail, the job (and workflow) will fail, preventing deployment.
7072

7173
# 7. (Optional) Build step for production
72-
- name: Build project
73-
working-directory: augmentos_cloud
74-
run: bun run build
74+
#- name: Build project
75+
# working-directory: cloud
76+
# run: bun run build
7577
# ^ If the server requires a build (e.g., TypeScript compilation or bundling), do it here.
7678
# If not needed, this step can be removed or left as a no-op.
7779

@@ -80,72 +82,4 @@ jobs:
8082
# uses: actions/upload-artifact@v3
8183
# with:
8284
# name: augmentos_build
83-
# path: augmentos_cloud/**
84-
85-
deploy:
86-
name: Deploy to Azure VM
87-
needs: build_and_test # Only run if build_and_test job succeeded
88-
runs-on: ubuntu-latest
89-
# We don't set env here to avoid exposing secrets via env. We'll pass secrets directly.
90-
steps:
91-
# 1. (Optional) Checkout code again, if we need the files in this job
92-
- name: Checkout code
93-
uses: actions/checkout@v4
94-
with:
95-
fetch-depth: 1
96-
# We could also use the artifact from previous job instead of checking out again.
97-
# In a monorepo, checkout ensures we have the latest from main for this job.
98-
99-
# 2. Copy files to Azure VM via SCP (Secure Copy over SSH)
100-
- name: Copy files to VM
101-
uses: appleboy/[email protected]
102-
with:
103-
host: ${{ secrets.AZURE_HOST }} # Azure VM IP or hostname
104-
username: ${{ secrets.AZURE_USERNAME }} # SSH username on Azure VM
105-
key: ${{ secrets.AZURE_DEV_RSA_KEY}} # Private SSH key for the VM (from secrets)
106-
port: 22 # SSH port (default 22)
107-
source: "augmentos_cloud/*" # What to copy (all files in server folder)
108-
target: "~/augmentos_cloud/" # Where to copy on the VM (adjust path as needed)
109-
rm: "true"
110-
# ^ This uses a community action to securely copy the latest build files to the VM​:contentReference[oaicite:18]{index=18}.
111-
# It removes existing files in target (rm: true) to ensure old files are cleaned up.
112-
# Ensure the target directory exists on the VM. You might want to exclude certain files (like .env).
113-
114-
# 3. Run remote commands on the VM via SSH
115-
- name: Install and Restart Server on VM
116-
uses: appleboy/[email protected]
117-
with:
118-
host: ${{ secrets.AZURE_HOST }}
119-
username: ${{ secrets.AZURE_USERNAME }}
120-
key: ${{ secrets.AZURE_DEV_RSA_KEY }}
121-
script: |
122-
set -e # stop on error
123-
cd ~/augmentos_cloud/
124-
# Install production dependencies on VM (if needed, e.g., in case node_modules was not copied)
125-
bun install --production
126-
# (If using a package manager other than bun for install on VM, adjust accordingly, e.g., npm ci --only=production)
127-
# Restart the Bun server process
128-
# If managed by PM2:
129-
pm2 restart augmentos-cloud || pm2 start index.js --name augmentos-cloud
130-
# If managed by systemd:
131-
# sudo systemctl restart augmentos.service
132-
# If no manager (not recommended for prod), run in background:
133-
# pkill -f \"bun run start\" || true # ignore if not running
134-
# nohup bun run start &>/dev/null &
135-
# ^ Logs into the VM via SSH and runs the commands​:contentReference[oaicite:19]{index=19}:
136-
# - Navigates to the app directory on the VM.
137-
# - Installs dependencies (using bun) in production mode.
138-
# - Restarts the application. (The example shows placeholders for PM2 or systemd; adapt to your setup.)
139-
# Ensure your VM user has permission to restart the service (if using sudo, the user must be in sudoers).
140-
# The bun server will be back up and running with the new code after this step.
141-
142-
# 4. (Optional) Post-deployment verification or notifications
143-
# - name: Health check
144-
# run: curl -f http://your-app-url/health || exit 1
145-
# - name: Notify Slack
146-
# uses: slackapi/[email protected]
147-
# with:
148-
# channel-id: C12345678
149-
# slack-message: "Deployed Bun server to Azure VM successfully."
150-
# slack-bot-token: ${{ secrets.SLACK_TOKEN }}
151-
85+
# path: cloud/**

0 commit comments

Comments
 (0)