Skip to content

Commit

Permalink
make v8-version-build job concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
LanderlYoung committed Sep 23, 2024
1 parent 07620f1 commit e518c95
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
matrix:
backends: [ V8, JavaScriptCore, QuickJs, Lua ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_to_tencent_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: mirror-repository
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
# mac runner seems to be slow and rear
# - Release
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
- Debug
- Release
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -112,8 +112,8 @@ jobs:
- Debug
- Release
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -143,16 +143,20 @@ jobs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
# format index{0 .. index-1}/concurrency
job_split: [ 0/8, 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8 ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
- name: Test build v8 on supported versions
env:
SCRIPTX_TEST_FORCE_UPDATE_DEPS: ON
SCRIPTX_TEST_V8_JOB_SPLIT_CONFIG: ${{ matrix.job_split }}
run: |
mkdir -p build && cd build
../test/cmake/test_v8_compiles.sh continue
Expand All @@ -172,8 +176,8 @@ jobs:
- Debug
- Release
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -204,7 +208,7 @@ jobs:
matrix:
node-version: [ 14.x, 15.x, 16.x, 18.x ] # 19.x
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.1.7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -228,8 +232,8 @@ jobs:
matrix:
emscripten-version: [ '3.0.0', '3.1.33' ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down
55 changes: 37 additions & 18 deletions test/cmake/test_v8_compiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
# <script> continure # ignore errors and go on
# <script> version # test for given version

ABORT_ON_FAILURE=True
function log() {
#echo -e "\e[1;32m${1}\e[0m"
echo -e "\033[1;31m${*}\033[0m"
}

if [[ $1 == "continue" ]]; then
echo "continure on failure"
log "continure on failure"
else
set -e
fi

if echo $1 | egrep -q -e '^\d+\.\d+.*$'; then
echo "test for version $1"
if echo "$1" | grep -q -w -E '[0-9]+\.[0-9]+.*'; then
log "test for version $1"
TARGET_VERSION=$1
fi

Expand All @@ -23,34 +26,34 @@ V8_INCLUDES_DIR=${BUILD_DIR}/ScriptXTestLibs/v8/includes
V8_SUPPORTED_VERSIONS=${BUILD_DIR}/ScriptXTestLibs/v8/supported_versions.txt
CMAKE="cmake --log-level=ERROR -Wno-dev -Wno-deprecated .. -DSCRIPTX_BACKEND=V8 -DSCRIPTX_TEST_BUILD_ONLY=ON"

echo STEP 1. initial configure to download depedencies
mkdir -p $BUILD_DIR
cd $BUILD_DIR
log "STEP 1. initial configure to download depedencies"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
rm -rf CMakeCache.txt
$CMAKE

echo STEP 2. test compile for each version
log "STEP 2. test compile for each version"

SUPPORTED_VERSIONS=($(< ${V8_SUPPORTED_VERSIONS}))
SUPPORTED_VERSIONS=($(< "$V8_SUPPORTED_VERSIONS"))
PASSED_VERSIONS=()
FAILED_VERSIONS=()

echo "supported v8 version: ${SUPPORTED_VERSIONS[@]}"
log "supported v8 version:" "${SUPPORTED_VERSIONS[@]}"

if [[ $(uname) == "Darwin" ]]; then
NPROC=$(sysctl -n hw.ncpu)
else
NPROC=$(nproc)
fi

echo "CPU cores $NPROC"
log "CPU cores $NPROC"

function compile() {
version=$1
FILE="${V8_INCLUDES_DIR}/$version"
echo v8 version ${version}
log "v8 version ${version}"
rm -rf CMakeCache.txt
$CMAKE -DSCRIPTX_V8_INCLUDES=${FILE}
$CMAKE -DSCRIPTX_V8_INCLUDES="${FILE}"
make -j${NPROC} clean ScriptX UnitTests
if [[ $? -eq 0 ]]; then
PASSED_VERSIONS+=($version)
Expand All @@ -62,14 +65,30 @@ function compile() {
if [[ -n $TARGET_VERSION ]] ; then
compile $TARGET_VERSION
else
for version in "${SUPPORTED_VERSIONS[@]}"; do
compile $version
done
if echo "$SCRIPTX_TEST_V8_JOB_SPLIT_CONFIG" | grep -q -w -E '[0-9]+\/[0-9]+'; then
TOTAL=$(echo ${SCRIPTX_TEST_V8_JOB_SPLIT_CONFIG} | cut -d/ -f 2)
INDEX=$(echo ${SCRIPTX_TEST_V8_JOB_SPLIT_CONFIG} | cut -d/ -f 1)
COUNT=${#SUPPORTED_VERSIONS[@]}

START=$(((COUNT * INDEX + TOTAL - 1) / TOTAL)) # upper(COUNT * INDEX / TOTAL)
END=$((COUNT * (INDEX + 1) / TOTAL)) # lower(COUNT * (INDEX+1) / TOTAL)

log "split job=[$START, $END] total=$COUNT"

for ((i = START; i <= END; i++)); do
compile ${SUPPORTED_VERSIONS[$i]}
done
else
for version in "${SUPPORTED_VERSIONS[@]}"; do
compile $version
done
fi
fi

echo "passed versions: [${PASSED_VERSIONS[@]}]"
echo "failed versions: [${FAILED_VERSIONS[@]}]"
log "passed versions: [" "${PASSED_VERSIONS[@]}" "]"
log "failed versions: [" "${FAILED_VERSIONS[@]}" "]"

if [[ ${#FAILED_VERSIONS[@]} -gt 0 ]]; then
exit 1
fi

0 comments on commit e518c95

Please sign in to comment.