Skip to content

Commit

Permalink
Merge branch 'main' into 24.03
Browse files Browse the repository at this point in the history
  • Loading branch information
lizable committed Jul 17, 2024
2 parents 5d14bc1 + 4599295 commit 4f3d247
Show file tree
Hide file tree
Showing 22 changed files with 38,094 additions and 55,111 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,38 @@ jobs:
- uses: actions/checkout@v4
- uses: jwalton/gh-find-current-pr@v1
id: findPr
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: npm install
run: pnpm install
- name: Run ESLint on React
run: npx eslint ./src --ignore-pattern '*.test.*' --max-warnings=0
run: pnpm eslint ./src --ignore-pattern '*.test.*' --max-warnings=0
- name: run relay-compiler
run: npm run relay
run: pnpm run relay
- name: Jest report
uses: ArtiomTr/jest-coverage-report-action@v2
with:
skip-step: install
working-directory: ./react
package-manager: npm
test-script: npm run test
package-manager: pnpm
test-script: pnpm run test
prnumber: ${{ steps.findPr.outputs.number }}
annotations: failed-tests
23 changes: 20 additions & 3 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,29 @@ jobs:
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Node.js and NPM
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version-file: '.nvmrc'
# cache: 'pnpm'
# - name: Get pnpm store directory
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
# - uses: actions/cache@v4
# name: Setup pnpm cache
# with:
# path: ${{ env.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: npm install
run: pnpm install
- name: Package Desktop Applications
run: make all
env:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
pnpm-error.log*

# Runtime data
pids
Expand Down Expand Up @@ -128,3 +130,8 @@ src/plugins/*

#
!.vscode/i18n-ally-*


# Ignore all other lock files
package-lock.json
yarn.lock
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node-linker=hoisted
public-hoist-pattern = *
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ BYELLOW := \033[1;93m
NC := \033[0m

test_web:
@npm run server:d
@pnpm run server:d
test_electron:
@npx electron . --dev
@pnpm dlx electron . --dev
proxy:
@node ./src/wsproxy/local_proxy.js
run_tests:
@npx testcafe chrome tests
@pnpm dlx testcafe chrome tests
versiontag:
@printf "$(GREEN)Tagging version number / index...$(NC)\n"
@echo '{ "package": "${BUILD_VERSION}", "buildNumber": "${BUILD_NUMBER}", "buildDate": "${BUILD_DATE}.${BUILD_TIME}", "revision": "${REVISION_INDEX}" }' > version.json
Expand All @@ -44,11 +44,11 @@ versiontag:
@sed -i -E 's/\<small class="sidebar-footer" style="font-size:9px;"\>\([^"]*\)\<\/small\>/\<small class="sidebar-footer" style="font-size:9px;"\>${BUILD_VERSION}.${BUILD_NUMBER}\<\/small\>/g' ./src/components/backend-ai-webui.ts
@printf "$(YELLOW)Finished$(NC)\n"
compile_keepversion:
@npm run build
@pnpm run build
compile: versiontag
@npm run build
@pnpm run build
compile_wsproxy:
@cd ./src/wsproxy; npx webpack --config webpack.config.js
@cd ./src/wsproxy; pnpm dlx webpack-cli --config webpack.config.js
#cd ./src/wsproxy; rollup -c rollup.config.ts
all: dep
@make mac_x64
Expand All @@ -72,14 +72,13 @@ dep:
cp -Rp build/rollup build/electron-app/app; \
cp -Rp build/rollup/resources build/electron-app; \
cp -Rp build/rollup/manifest build/electron-app; \
BUILD_TARGET=electron npm run build:react-only; \
BUILD_TARGET=electron pnpm run build:react-only; \
cp -Rp react/build/* build/electron-app/app/; \
sed -i -E 's/\.\/dist\/components\/backend-ai-webui.js/es6:\/\/dist\/components\/backend-ai-webui.js/g' build/electron-app/app/index.html; \
mkdir -p ./build/electron-app/app/wsproxy; \
cp ./src/wsproxy/dist/wsproxy.js ./build/electron-app/app/wsproxy/wsproxy.js; \
mkdir -p ./build/electron-app/node_modules/markty; \
mkdir -p ./build/electron-app/node_modules/markty-toml; \
mkdir -p ./build/electron-app/node_modules/@vanillawc/wc-codemirror/theme; \
mkdir -p ./build/electron-app/node_modules/mime-types; \
mkdir -p ./build/electron-app/node_modules/mime-db; \
mkdir -p ./build/electron-app/node_modules/@vanillawc/wc-codemirror/theme; \
Expand Down Expand Up @@ -121,7 +120,7 @@ endif # BAI_APP_SIGN_KEYCHAIN_B64
endif # BAI_APP_SIGN_KEYCHAIN
compile_localproxy:
@rm -rf ./app/backend.ai-local-proxy-$(BUILD_VERSION)-$(os)-$(arch)$(local_proxy_postfix)
@npx pkg ./src/wsproxy/local_proxy.js --targets node18-$(os)-$(arch) --output ./app/backend.ai-local-proxy-$(BUILD_VERSION)-$(os)-$(arch)$(local_proxy_postfix) --compress Brotli
@pnpm dlx pkg ./src/wsproxy/local_proxy.js --targets node18-$(os)-$(arch) --output ./app/backend.ai-local-proxy-$(BUILD_VERSION)-$(os)-$(arch)$(local_proxy_postfix) --compress Brotli
@rm -rf ./app/backend.ai-local-proxy$(local_proxy_postfix); cp ./app/backend.ai-local-proxy-$(BUILD_VERSION)-$(os)-$(arch)$(local_proxy_postfix) ./app/backend.ai-local-proxy$(local_proxy_postfix)
@cd app; zip -r -9 ./backend.ai-local-proxy-$(BUILD_VERSION)-$(os)-$(arch).zip "./backend.ai-local-proxy$(local_proxy_postfix)"
@rm -rf ./app/backend.ai-local-proxy$(local_proxy_postfix)
Expand All @@ -145,7 +144,7 @@ ifdef BAI_APP_SIGN_KEYCHAIN
endif
@rm -rf ./app/backend.ai-desktop-$(os)-$(arch)
@cd app; mv "Backend.AI Desktop-darwin-$(arch)" backend.ai-desktop-$(os)-$(arch);
@npx electron-installer-dmg './app/backend.ai-desktop-$(os)-$(arch)/Backend.AI Desktop.app' ./app/backend.ai-desktop-$(arch)-$(BUILD_DATE) --overwrite --icon=manifest/backend-ai.icns --title=Backend.AI
@pnpm dlx electron-installer-dmg './app/backend.ai-desktop-$(os)-$(arch)/Backend.AI Desktop.app' ./app/backend.ai-desktop-$(arch)-$(BUILD_DATE) --overwrite --icon=manifest/backend-ai.icns --title=Backend.AI
ifeq ($(site),main)
@mv ./app/backend.ai-desktop-$(arch)-$(BUILD_DATE).dmg ./app/backend.ai-desktop-$(BUILD_VERSION)-$(os)-$(arch).dmg
else
Expand Down Expand Up @@ -203,7 +202,7 @@ linux_arm64: dep compile_localproxy package_zip
build_docker: compile
docker build -t backend.ai-webui:$(BUILD_DATE) .
i18n:
@npx i18next-scanner --config ./i18n.config.js
@pnpm dlx i18next-scanner --config ./i18n.config.js
clean:
@cd app; rm -rf ./backend*; rm -rf ./Backend*
@cd build;rm -rf ./unbundle ./bundle ./rollup ./electron-app
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ You can debug the app.
Backend.AI Web UI is built with
* `lit-element` as webcomponent framework
* `react` as library for web UI
* `npm` as package manager
* `pnpm` as package manager
* `rollup` as bundler
* `electron` as app shell
* `watchman` as file change watcher for development
Expand All @@ -147,7 +147,7 @@ View [Code of conduct](https://github.com/lablup/backend.ai-webui/blob/main/CODE
### Initializing

```console
$ npm i
$ pnpm i
```

If this is not your first-time compilation, please clean the temporary directories with this command:
Expand All @@ -162,21 +162,21 @@ You must perform first-time compilation for testing. Some additional mandatory p
$ make compile_wsproxy
```

To run `relay-compiler` with the watch option(`npm run relay -- --watch`) on a React project, you need to install `watchman`. If you use Homebrew on Linux, it's a great way to get a recent Watchman build. Please refer to [the official installation guide](https://facebook.github.io/watchman/docs/install).
To run `relay-compiler` with the watch option(`pnpm run relay -- --watch`) on a React project, you need to install `watchman`. If you use Homebrew on Linux, it's a great way to get a recent Watchman build. Please refer to [the official installation guide](https://facebook.github.io/watchman/docs/install).

### Developing / testing without bundling

On a terminal:
```console
$ npm run build:d # To watch source changes
$ pnpm run build:d # To watch source changes
```
On another terminal:
```console
$ npm run server:d # To run dev. web server
$ pnpm run server:d # To run dev. web server
```
On yet another terminal:
```console
$ npm run wsproxy # To run websocket proxy
$ pnpm run wsproxy # To run websocket proxy
```

If you want to change port for your development environment, Add your configuration to `/react/.env.development` file in the project:
Expand All @@ -188,7 +188,7 @@ Defaultly, `PORT` is `9081`

### Lint Checking
```console
$ npm run lint # To check lints
$ pnpm run lint # To check lints
```

### Unit Testing
Expand All @@ -198,11 +198,11 @@ To perform functional tests, you must run complete Backend.AI cluster before sta

On a terminal:
```console
$ npm run server:d # To run dev. web server
$ pnpm run server:d # To run dev. web server
```
On another terminal:
```console
$ npm run test # Run tests (tests are located in `tests` directory)
$ pnpm run test # Run tests (tests are located in `tests` directory)
```

### Electron (app mode) development / testing
Expand All @@ -211,16 +211,16 @@ $ npm run test # Run tests (tests are located in `tests` directory)

On a terminal:
```console
$ npm run server:d # To run test server
$ pnpm run server:d # To run test server
```
OR
```console
$ npm run server:p # To run compiled source
$ pnpm run server:p # To run compiled source
```

On another terminal:
```console
$ npm run electron:d # Run Electron as dev mode.
$ pnpm run electron:d # Run Electron as dev mode.
```

## Serving Guide
Expand Down Expand Up @@ -345,7 +345,7 @@ $ git submodule update --init --checkout --recursive
This is only needed with pure ES6 dev. environment / browser. Websocket proxy is embedded in Electron and automatically starts.

```console
$ npm run wsproxy
$ pnpm run wsproxy
```

If webui app is behind an external http proxy, and you have to pass through
Expand Down Expand Up @@ -457,13 +457,13 @@ Note: There are two Electron configuration files, `main.js` and `main.electron-p

```console
$ make dep # Compile with app dependencies
$ npm run electron:d # OR, ./node_modules/electron/cli.js .
$ pnpm run electron:d # OR, ./node_modules/electron/cli.js .
```

The electron app reads the configuration from `./build/electron-app/app/config.toml`, which is copied from the root `config.toml` file during `make clean && make dep`.

If you configure `[server].webServerURL`, the electron app will load the web contents (including `config.toml`) from the designated server.
The server may be either a `npm run server:d` instance or a `./py -m ai.backend.web.server` daemon from the mono-repo.
The server may be either a `pnpm run server:d` instance or a `./py -m ai.backend.web.server` daemon from the mono-repo.
This is known as the "web shell" mode and allows live edits of the web UI while running it inside the electron app.

### Localization
Expand Down
Loading

0 comments on commit 4f3d247

Please sign in to comment.