This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
forked from browsermt/bergamot-translator
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from mozilla/main
Merge histories across bergamot-translator forks
- Loading branch information
Showing
5 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: 2.1 | ||
jobs: | ||
build: | ||
docker: | ||
- image: 'emscripten/emsdk:2.0.9' | ||
resource_class: medium | ||
|
||
working_directory: ~/checkout | ||
|
||
steps: | ||
- checkout | ||
|
||
- run: | ||
name: Build WASM | ||
command: bash build-wasm.sh | ||
|
||
- run: | ||
name: Check artifacts | ||
working_directory: build-wasm | ||
command: | | ||
ls -all bergamot* | ||
if ls bergamot*.wasm &>/dev/null && ls bergamot*.js &>/dev/null | ||
then | ||
echo "Artifacts Successfully Generated" | ||
else | ||
echo "Failure: Artifacts Not Present" | ||
exit 1 | ||
fi | ||
- store_artifacts: | ||
path: "build-wasm" | ||
destination: "build-wasm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ _deps | |
|
||
|
||
wasm/test_page/node_modules | ||
build-* | ||
build-wasm | ||
models | ||
wasm/test_page/bergamot-translator-worker.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Usage: ./build-wasm.sh | ||
|
||
set -e | ||
set -x | ||
|
||
# Run script from the context of the script-containing directory | ||
cd "$(dirname $0)" | ||
|
||
# This file replicates the instructions found in ./README.md under "Build WASM" | ||
# with slight adjustments to be able to run the build script multiple times without having to clone all dependencies | ||
# as per "As long as you don't update any submodule, just follow steps in `4.ii` to recompile." | ||
|
||
# 1. Download and Install Emscripten using following instructions (unless the EMSDK env var is already set) | ||
if [ "$EMSDK" == "" ]; then | ||
EMSDK_UPDATE_REQUIRED=0 | ||
if [ ! -d "emsdk" ]; then | ||
git clone https://github.com/emscripten-core/emsdk.git | ||
EMSDK_UPDATE_REQUIRED=1 | ||
else | ||
cd emsdk | ||
git fetch | ||
# Only pull if necessary | ||
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]; then | ||
git pull --ff-only | ||
EMSDK_UPDATE_REQUIRED=1 | ||
fi | ||
cd - | ||
fi | ||
if [ "$EMSDK_UPDATE_REQUIRED" == "1" ]; then | ||
cd emsdk | ||
./emsdk install latest | ||
./emsdk activate latest | ||
cd - | ||
fi | ||
source ./emsdk/emsdk_env.sh | ||
fi | ||
|
||
# 4. Compile | ||
# 1. Create a folder where you want to build all the artifacts (`build-wasm` in this case) | ||
if [ ! -d "build-wasm" ]; then | ||
mkdir build-wasm | ||
fi | ||
cd build-wasm | ||
|
||
# 2. Compile the artifacts | ||
emcmake cmake -DCOMPILE_WASM=on ../ | ||
emmake make -j3 | ||
|
||
# 3. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts | ||
bash ../wasm/patch-artifacts-enable-wormhole.sh | ||
|
||
# The artifacts (.js and .wasm files) will be available in the build directory ("build-wasm" in this case). | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Continuous Integration | ||
|
||
[Circle CI](https://circleci.com/) is used for continuous integration. Configured via `./.circleci/config.yml`. | ||
|
||
## Run Circle CI locally (requires Docker) | ||
|
||
1. [Install the CircleCI local cli](https://circleci.com/docs/2.0/local-cli/#installation) | ||
2. Validate Circle CI configuration (useful exercise before pushing any changes to the configuration) | ||
|
||
```shell | ||
circleci config validate -c .circleci/config.yml | ||
``` | ||
|
||
3. To better mimic the starting point for CI, commit your changes and clone your repository into a clean directory then run CircleCI inside that directory: | ||
|
||
```shell | ||
git clone . /tmp/$(basename $PWD) | ||
cd /tmp/$(basename $PWD) | ||
circleci build | ||
``` | ||
|
||
Note: Steps related to caching and uploading/storing artifacts will report as failed locally. This is not necessarily a problem, they are designed to fail since the operations are not supported locally by the CircleCI build agent. |