forked from MeshInspector/MeshLib
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (134 loc) · 5.33 KB
/
build-test-emscripten.yml
File metadata and controls
151 lines (134 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build and test Emscripten
on:
workflow_call:
inputs:
docker_image_tag:
required: true
type: string
internal_build:
required: false
type: boolean
upload_artifacts:
required: true
type: boolean
jobs:
emscripten-build:
timeout-minutes: 40
runs-on: [ self-hosted, linux-arm64, spot, meshinspector ]
container:
image: meshlib/meshlib-emscripten-arm64:${{ inputs.docker_image_tag }}
strategy:
fail-fast: false
matrix:
config: [Singlethreaded, Multithreaded, Multithreaded-64Bit]
include:
- config: Singlethreaded
target_name: emscripten-singlethreaded
package_name: emscripten-singlethreaded
thirdparty-dir: emscripten-single
aws-dir: RMISingle
- config: Multithreaded
target_name: emscripten
package_name: emscripten-multithreaded
thirdparty-dir: emscripten
aws-dir: RMI
- config: Multithreaded-64Bit
target_name: emscripten-wasm64
package_name: emscripten-multithreaded-64bit
thirdparty-dir: emscripten-wasm64
aws-dir: RMI64
steps:
- name: Work-around possible permission issues
shell: bash
run: |
# NOTE: {GITHUB_WORKSPACE} != {{ github.workspace }}
# Related issue: https://github.com/actions/runner/issues/2058
if test -d $GITHUB_WORKSPACE && test -n "$(find ${GITHUB_WORKSPACE} -user root)" ; then
mv ${GITHUB_WORKSPACE} ${GITHUB_WORKSPACE}_${RANDOM}
mkdir ${GITHUB_WORKSPACE}
fi
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
- name: Get AWS instance type
run: |
TOKEN=$(curl -fsS --max-time 2 \
-X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 10" || true)
AWS_INSTANCE_TYPE=$(curl -fsS --max-time 2 \
-H "X-aws-ec2-metadata-token: $TOKEN" \
"http://169.254.169.254/latest/meta-data/instance-type" || true)
# if not an EC2 instance
if test -z "$AWS_INSTANCE_TYPE" ; then
AWS_INSTANCE_TYPE="self-hosted"
fi
echo "AWS_INSTANCE_TYPE=$AWS_INSTANCE_TYPE" >> $GITHUB_ENV
echo $AWS_INSTANCE_TYPE
- name: Checkout
uses: actions/checkout@v5
- name: Collect runner's system stats
if: ${{ inputs.internal_build }}
continue-on-error: true
uses: ./.github/actions/collect-runner-stats
with:
target_os: ${{ matrix.target_name }}
target_arch: wasm
cxx_compiler: emcc
build_config: Release
aws_instance_type: ${{ env.AWS_INSTANCE_TYPE }}
- name: Checkout third-party submodules
run: |
# have to checkout selective submodules by our own
# related issue: https://github.com/actions/checkout/issues/1779
export HOME=${RUNNER_TEMP}
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git submodule update --init --recursive --depth 1 thirdparty/imgui thirdparty/parallel-hashmap thirdparty/mrbind-pybind11 thirdparty/mrbind
- name: Install thirdparty libs
run: |
ln -s /usr/local/lib/${{ matrix.thirdparty-dir }}/lib ./lib
ln -s /usr/local/lib/${{ matrix.thirdparty-dir }}/include ./include
- name: Build
env:
MR_EMSCRIPTEN: "ON"
MESHLIB_BUILD_RELEASE: "ON"
MESHLIB_BUILD_DEBUG: "OFF"
MR_EMSCRIPTEN_SINGLE: ${{ fromJSON('["OFF", "ON"]')[matrix.config == 'Singlethreaded'] }}
MR_EMSCRIPTEN_WASM64: ${{ fromJSON('["OFF", "ON"]')[matrix.config == 'Multithreaded-64Bit'] }}
# options to be passed to cmake
MR_CMAKE_OPTIONS: >
-DMR_CXX_STANDARD=23
-DMR_PCH_USE_EXTRA_HEADERS=ON
run: ./scripts/build_source.sh
- name: Unit Tests
timeout-minutes: 5
run: |
echo "check the \$HOME dir permissions in case of timeout issues"
echo ls -al \$HOME
ls -al $HOME
echo
emrun \
--browser=/usr/bin/firefox \
--browser-args="--headless" \
--safe-firefox-profile \
--kill-exit \
./build/Release/bin/MRTest.html
- name: Create Package
run: |
cp -a /usr/local/lib/${{ matrix.thirdparty-dir }} ./meshlib_install
./scripts/cmake_install.sh ./meshlib_install
( cd ./meshlib_install ; zip -r ../meshlib_${{ matrix.package_name }} * )
- name: Build C++ examples
run: |
emcmake cmake \
-S examples/cpp-examples \
-B cpp-examples-build \
-D CMAKE_FIND_ROOT_PATH=$(pwd)/meshlib_install/ \
${{ matrix.target_name == 'emscripten-wasm64' && '-D CMAKE_C_FLAGS="-sMEMORY64=1" -D CMAKE_CXX_FLAGS="-sMEMORY64=1"' || '' }}
cmake \
--build cpp-examples-build \
--parallel $(nproc)
- name: Upload Package
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: Distributives_${{ matrix.package_name }}
path: meshlib_${{ matrix.package_name }}.zip
retention-days: 1