Skip to content

fix deployment

fix deployment #23

Workflow file for this run

name: CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-native:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Essential for SonarCloud to see history/blame
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++ libopencv-dev
pip install gcovr==8.6
# Use a dedicated directory for build wrapper output
# This replaces the old 'build-wrapper-action'
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9
- name: Run Build Wrapper
run: |
build-wrapper-linux-x86-64 --out-dir bw-output make coverage
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.cfamily.compile-commands=bw-output/compile_commands.json
-Dsonar.coverageReportPaths=coverage.xml
test-js:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install JS dependencies
run: npm ci
- name: Install Playwright Chromium
run: npx playwright install chromium --with-deps
- name: Run unit tests
run: npm run test
- name: Run browser integration tests
run: npm run test:browser
build-web:
runs-on: ubuntu-latest
needs: [build-native, test-js] # Ensure core logic and JS tests pass first
steps:
- uses: actions/checkout@v4
- name: Cache Emscripten
id: cache-emsdk
uses: actions/cache@v4
with:
path: |
~/emsdk
~/.emscripten_cache
key: ${{ runner.os }}-emsdk-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-emsdk-
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@ab889da2abbcbb280f91ec4c215d3bb4f3a8f775
with:
version: 'latest'
- name: Build WASM
# We use 'emmake' to ensure the Makefile sees the Emscripten environment
run: emmake make web
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install JS dependencies
working-directory: web
run: npm ci
- name: Build web app (Vite)
working-directory: web
run: npm run build
- name: Upload WASM Artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-build
path: web/public/
if-no-files-found: error
deploy:
runs-on: ubuntu-latest
needs: build-web
# Only deploy on pushes to main, not PRs
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
deployments: write
contents: read
environment:
name: production
url: ${{ steps.deploy.outputs.deployment_url }}
steps:
- uses: actions/checkout@v4
- name: Download WASM Artifacts
uses: actions/download-artifact@v4
with:
name: wasm-build
path: web/public
- name: Debug - List public files
run: ls -R web/public
- name: Install Vercel CLI
run: npm install --global vercel
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=$VERCEL_TOKEN
- name: Build Project Artifacts
run: vercel build --prod --token=$VERCEL_TOKEN
- name: Deploy Project Artifacts to Vercel
id: deploy
run: |
DEPLOY_URL=$(vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN --yes)
echo "deployment_url=$DEPLOY_URL" >> $GITHUB_OUTPUT
env:
VERCEL_ORG_ID: ${{ secrets.ORGID }}
VERCEL_PROJECT_ID: ${{ secrets.PROJECTID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}