Skip to content

Commit

Permalink
Merge pull request #30 from mbsantiago/refactor/improve_build
Browse files Browse the repository at this point in the history
Refactor/improve build
  • Loading branch information
mbsantiago authored Sep 26, 2024
2 parents a96b703 + ee5aeff commit 37c3779
Show file tree
Hide file tree
Showing 33 changed files with 182 additions and 669 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_user_guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.12
run: uv python install 3.12

- name: Restore uv cache
Expand Down
43 changes: 26 additions & 17 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Bundle App
on:
release:
types: [published]
workflow_dispatch:

jobs:
build-user-guide:
Expand All @@ -22,19 +23,26 @@ jobs:
python-version:
- "3.12"
os:
- ubuntu-latest
- ubuntu-20.04
- windows-latest
- macos-11
- macos-12

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up uv
if: ${{ matrix.os == 'windows-latest' }}
run: irm https://astral.sh/uv/install.ps1 | iex
shell: powershell

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Retrieve built frontend
uses: actions/download-artifact@v4
Expand All @@ -56,21 +64,22 @@ jobs:
mkdir dist/
mv "back/dist/whombat.zip" "dist/whombat-${{ matrix.os }}-${{ github.ref_name }}.zip"
- name: Bundle app (Linux)
if: ${{ matrix.os == 'linux-latest' }}
- name: Bundle app (Linux/macOS)
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == "macos-12" }}
run: |
bash scripts/bundle_linux.sh
mkdir dist/
mv back/dist/whombat.zip "dist/whombat-${{ matrix.os }}-${{ github.ref_name }}.zip"
mv dist/whombat.zip "dist/whombat-${{ matrix.os }}-${{ github.ref_name }}.zip"
- name: Bundle app (macOS)
if: ${{ matrix.os == 'macos-11' }}
run: |
bash scripts/bundle_macos.sh
mkdir dist/
mv back/dist/whombat.zip "dist/whombat-${{ matrix.os }}-${{ github.ref_name }}.zip"
# Only run if triggered by user
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
name: "${{ matrix.os }}-${{ github.ref_name }}" # Include ref_name for better organization
path: "dist/whombat-${{ matrix.os }}-${{ github.ref_name }}.zip"

# Only run if release
- name: Upload release
if: ${{ github.event_name == 'release' }}
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
- name: Set up Python
run: uv python install 3.12

- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Create cache key
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- name: Restore mkdocs cache
uses: actions/cache@v3
Expand All @@ -47,7 +48,7 @@ jobs:
- name: Install the project dependencies
run: |
cd back
uv sync --all-extras --dev
uv sync --dev
- name: Build and Deploy Docs
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ front/tests-examples
front/playwright-report
front/test-results
.backups
build/whombat
dist
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
SHELL := /bin/bash

FRONT_DIR := front
BACK_DIR := back

.PHONY: dev-front dev-back dev-docs storybook install-dev build-frontend build-guide bundle publish clean

dev-front:
cd front && npm run dev
cd $(FRONT_DIR) && npm run dev

storybook:
cd $(FRONT_DIR) && npm run storybook

dev-back:
cd back && make serve-dev
cd $(BACK_DIR) && make serve-dev

dev-docs:
cd back && make serve-docs
cd $(BACK_DIR) && make serve-docs

install-dev:
bash scripts/install_dev.sh
Expand All @@ -18,11 +26,11 @@ build-frontend:
build-guide:
bash scripts/update_guide.sh

bundle-pyinstaller:
bundle:
bash scripts/bundle_linux.sh

publish:
bash scripts/publish_pypi.sh

storybook:
cd front && npm run storybook
clean:
rm -rf dist/ build/
Binary file removed assets/splash.png
Binary file not shown.
2 changes: 1 addition & 1 deletion back/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import dynamic from "next/dynamic";
import { useState } from "react";

import Pagination from "@/app/components/Pagination";
Expand All @@ -12,7 +13,6 @@ import Error from "@/app/error";

import ExplorationLayout from "@/lib/components/layouts/Exploration";
import ListCounts from "@/lib/components/lists/ListCounts";
import SoundEventAnnotationsScatterPlot from "@/lib/components/sound_event_annotations/SoundEventAnnotationsScatterPlot";
import Empty from "@/lib/components/ui/Empty";
import Loading from "@/lib/components/ui/Loading";

Expand All @@ -21,6 +21,14 @@ import usePagedQuery from "@/lib/hooks/utils/usePagedQuery";

import type { ScatterPlotData, SoundEventAnnotationFilter } from "@/lib/types";

const SoundEventAnnotationsScatterPlot = dynamic(
() =>
import(
"@/lib/components/sound_event_annotations/SoundEventAnnotationsScatterPlot"
),
{ ssr: false },
);

export default function Page() {
const [selectedSoundEvent, setSelectedSoundEvent] =
useState<ScatterPlotData | null>(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useCallback } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";

import { UploadIcon } from "@/lib/components/icons";
import { Input, Group, Submit } from "@/lib/components/inputs/index";
import { Group, Input, Submit } from "@/lib/components/inputs/index";
import { AnnotationProjectImportSchema } from "@/lib/schemas";
import type { AnnotationProjectImport } from "@/lib/types";

export default function AnnotationProjectImport({
onImportAnnotationProject,
Expand Down Expand Up @@ -33,7 +34,7 @@ export default function AnnotationProjectImport({
name="annotation_project"
label="Select a project file to import"
help="The file must be in AOEF format"
error={errors.annotation_project?.message}
error={errors.annotation_project?.message?.toString()}
>
<Input type="file" {...register("annotation_project")} required />
</Group>
Expand All @@ -44,11 +45,3 @@ export default function AnnotationProjectImport({
</form>
);
}

export const AnnotationProjectImportSchema = z.object({
annotation_project: z.instanceof(FileList),
});

export type AnnotationProjectImport = z.infer<
typeof AnnotationProjectImportSchema
>;

This file was deleted.

Loading

0 comments on commit 37c3779

Please sign in to comment.