Skip to content

demo

demo #502

Workflow file for this run

name: demo
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
env:
DEPLOY_DIRNAME: gh-pages-repo
DEPLOY_BRANCH: gh-pages
DEMO_SRC_DIRNAME: ./demo
DEMO_BUILD_DIRNAME: ./demo/public
DEPLOY_LOCAL_SCRIPT: ./demo/scripts/deploy-local
permissions:
contents: write
jobs:
build-wasm:
runs-on: ubuntu-latest
container:
image: juniorrojas/llvm-enzyme:latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Build WASM
run: |
export LLVM_BIN_DIR=/usr/lib/llvm-11/bin
export ENZYME=/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-11.so
./build.sh
- name: Upload WASM
uses: actions/upload-artifact@v4
with:
name: algovivo.wasm
path: build/algovivo.wasm
build-js:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Build lib
run: |
npm ci
npm run build
- name: Upload lib build
uses: actions/upload-artifact@v4
with:
name: build
path: ./build
build-demo:
runs-on: ubuntu-latest
needs: [build-wasm, build-js]
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Download WASM build
uses: actions/download-artifact@v4
with:
name: algovivo.wasm
path: build/
- name: Download JS build
uses: actions/download-artifact@v4
with:
name: build
path: ./build
- name: Build demo
run: |
cd ${{ env.DEMO_SRC_DIRNAME }}
npm ci
npm run build
- name: Upload demo build
uses: actions/upload-artifact@v4
with:
name: demo-build
path: ${{ env.DEMO_BUILD_DIRNAME }}
test-demo:
runs-on: ubuntu-22.04
needs: [build-demo]
steps:
- name: Clone repo
uses: actions/checkout@v4
- run: ls -l ${{ env.DEMO_BUILD_DIRNAME }}
- name: Download WASM build
uses: actions/download-artifact@v4
with:
name: algovivo.wasm
path: build/
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: ${{ env.DEMO_BUILD_DIRNAME }}
- run: ls -l ${{ env.DEMO_BUILD_DIRNAME }}
- name: Test demo
run: |
cd ${{ env.DEMO_SRC_DIRNAME }}
npm ci
npm test
- name: Upload demo screenshot
uses: actions/upload-artifact@v4
with:
name: screenshot
path: ./demo/test/screenshot.out.png
init-deploy-branch:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Create branch if it does not exist
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if ! git ls-remote --exit-code --heads origin ${{ env.DEPLOY_BRANCH }}; then
echo "Branch does not exist, creating and pushing..."
git checkout --orphan ${{ env.DEPLOY_BRANCH }}
git rm -rf .
git commit --allow-empty -m "First commit"
git push origin ${{ env.DEPLOY_BRANCH }}
else
echo "Branch already exists, skipping push."
fi
deploy-demo:
runs-on: ubuntu-latest
needs: [init-deploy-branch, build-demo]
steps:
- name: Clone repo
uses: actions/checkout@v4
- run: ls -l ${{ env.DEMO_BUILD_DIRNAME }}
- name: Download WASM build
uses: actions/download-artifact@v4
with:
name: algovivo.wasm
path: build/
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: ${{ env.DEMO_BUILD_DIRNAME }}
- run: ls -l ${{ env.DEMO_BUILD_DIRNAME }}
- name: Clone deploy branch
uses: actions/checkout@v4
with:
ref: ${{ env.DEPLOY_BRANCH }}
path: ${{ env.DEPLOY_DIRNAME }}
- name: Deploy to local directory
run: |
${{ env.DEPLOY_LOCAL_SCRIPT }} --deploy-dirname ${{ env.DEPLOY_DIRNAME }}
- name: Upload deployment
uses: actions/upload-artifact@v4
with:
name: deployment
path: ${{ env.DEPLOY_DIRNAME }}
- name: Push deployment
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
cd ${{ env.DEPLOY_DIRNAME }}
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Deploy"
git push origin ${{ env.DEPLOY_BRANCH }}