Compare commits

...

5 Commits

Author SHA1 Message Date
Yeicor
d3fbe254cb improve release asset 2 2024-03-03 20:47:29 +01:00
Yeicor
2475a00622 improve release asset 2024-03-03 20:45:12 +01:00
Yeicor
4bd025e7d5 fix launching backend without a built frontend 2024-03-03 20:41:44 +01:00
Yeicor
94e316472a fix selection 2024-03-03 20:38:56 +01:00
Yeicor
258256912b optimize CI times 2024-03-03 20:34:52 +01:00
5 changed files with 20 additions and 17 deletions

View File

@@ -37,8 +37,8 @@ jobs:
with: with:
python-version: "3.11" python-version: "3.11"
cache: "poetry" cache: "poetry"
- run: "poetry install" - run: "SKIP_BUILD_FRONTEND=true poetry install"
- run: "poetry build" - run: "SKIP_BUILD_FRONTEND=true poetry build"
build-logo: build-logo:
name: "Build logo" name: "Build logo"
@@ -53,7 +53,7 @@ jobs:
with: with:
python-version: "3.11" python-version: "3.11"
cache: "poetry" cache: "poetry"
- run: "poetry install" - run: "SKIP_BUILD_FRONTEND=true poetry install"
- run: "poetry run python yacv_server/logo.py" - run: "poetry run python yacv_server/logo.py"
- run: "cp assets/fox.glb assets/logo_build/fox.glb" - run: "cp assets/fox.glb assets/logo_build/fox.glb"
- uses: "actions/upload-artifact@v4" - uses: "actions/upload-artifact@v4"

View File

@@ -17,7 +17,7 @@ concurrency:
cancel-in-progress: false cancel-in-progress: false
jobs: jobs:
deploy: deploy-frontend:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
environment: environment:
name: "github-pages" name: "github-pages"
@@ -35,18 +35,18 @@ jobs:
name: "logo" name: "logo"
path: "./public" path: "./public"
allow_forks: false allow_forks: false
- uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
file: "./public/*"
asset_name: "frontend"
tag: "${{ github.ref }}"
overwrite: true
file_glob: true
- uses: "actions/configure-pages@v4" - uses: "actions/configure-pages@v4"
- uses: "actions/upload-pages-artifact@v3" - uses: "actions/upload-pages-artifact@v3"
with: with:
path: 'public' path: 'public'
- id: "deployment" - id: "deployment"
uses: "actions/deploy-pages@v4" uses: "actions/deploy-pages@v4"
- run: 'zip -r frontend.zip public'
- uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
file: "frontend.zip"
tag: "${{ github.ref }}"
overwrite: true
# TODO: deploy-backend

View File

@@ -2,6 +2,7 @@ import os
import subprocess import subprocess
if __name__ == "__main__": if __name__ == "__main__":
if os.getenv('SKIP_BUILD_FRONTEND') is None:
# When building the backend, make sure the frontend is built first # When building the backend, make sure the frontend is built first
subprocess.run(['yarn', 'install'], check=True) subprocess.run(['yarn', 'install'], check=True)
subprocess.run(['yarn', 'build', '--outDir', 'yacv_server/frontend'], check=True) subprocess.run(['yarn', 'build', '--outDir', 'yacv_server/frontend'], check=True)

View File

@@ -88,7 +88,7 @@ let selectionListener = (event: MouseEvent) => {
// Find all hit objects and select the wanted one based on the filter // Find all hit objects and select the wanted one based on the filter
const hits = raycaster.intersectObject(scene, true); const hits = raycaster.intersectObject(scene, true);
let hit = hits.find((hit: Intersection<Object3D>) => { let hit = hits.find((hit: Intersection<Object3D>) => {
if (!hit.object || !(hit.object as any).isMesh) return false; if (!hit.object) return false;
const kind = hit.object.type const kind = hit.object.type
let isFace = kind === 'Mesh' || kind === 'SkinnedMesh'; let isFace = kind === 'Mesh' || kind === 'SkinnedMesh';
let isEdge = kind === 'Line' || kind === 'LineSegments'; let isEdge = kind === 'Line' || kind === 'LineSegments';

View File

@@ -28,6 +28,7 @@ if not os.path.exists(FRONTEND_BASE_PATH):
FRONTEND_BASE_PATH = os.path.join(FILE_DIR, '..', 'dist') FRONTEND_BASE_PATH = os.path.join(FILE_DIR, '..', 'dist')
else: else:
logger.warning('Frontend not found at %s', FRONTEND_BASE_PATH) logger.warning('Frontend not found at %s', FRONTEND_BASE_PATH)
FRONTEND_BASE_PATH = None
# Define the API paths (also available at the root path for simplicity) # Define the API paths (also available at the root path for simplicity)
UPDATES_API_PATH = '/api/updates' UPDATES_API_PATH = '/api/updates'
@@ -84,6 +85,7 @@ class Server:
self.app.router.add_get('/', self._entrypoint) self.app.router.add_get('/', self._entrypoint)
# - Static files from the frontend # - Static files from the frontend
self.app.router.add_get('/{path:(.*/|)}', _index_handler) # Any folder -> index.html self.app.router.add_get('/{path:(.*/|)}', _index_handler) # Any folder -> index.html
if FRONTEND_BASE_PATH is not None:
self.app.router.add_static('/', path=FRONTEND_BASE_PATH, name='static_frontend') self.app.router.add_static('/', path=FRONTEND_BASE_PATH, name='static_frontend')
# --- CORS --- # --- CORS ---
cors = aiohttp_cors.setup(self.app, defaults={ cors = aiohttp_cors.setup(self.app, defaults={