Tidy ci scripts

This commit is contained in:
halx99 2021-12-30 19:40:30 +08:00
parent cc43b60bea
commit d43e9458ae
16 changed files with 53 additions and 548 deletions

View File

@ -1,42 +0,0 @@
version: 1.0.{build}
skip_tags: true
skip_branch_with_pr: true
image:
- Visual Studio 2019
environment:
PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.13"
PYTHON_ARCH: "32"
matrix:
- build_type: windows32_cmake_test
# - build_type: android_cpp_tests
# - build_type: android_lua_tests
# - build_type: android_cocos_new_test
# - build_type: android_cpp_empty_test
# - build_type: android_gen_libs
platform:
- x86
configuration:
- Release
before_build:
- ps: ./tools/appveyor-scripts/before-build.ps1
build_script:
- ps: ./tools/appveyor-scripts/build.ps1
branches:
except:
- v1
- v2
- v4-develop
- v3-doc
- v3.11_backup
- v35-for-tizen
clone_depth: 50
test: off

View File

@ -48,8 +48,8 @@ jobs:
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all
run: tools/travis-scripts/before-install.sh
run: tools/unix-ci/before-install.sh
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: tools/travis-scripts/run-script.sh
run: tools/unix-ci/run-script.sh

36
.github/workflows/genbindings-ci.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: genbindings
on:
push:
branches:
- dev
- main
paths:
- cocos/**/*
- extensions/**/*
- .github/workflows/genbindings-ci.yml
jobs:
build:
if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }}
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
lfs: 'true'
- name: Setup Python
uses: actions/setup-python@v2
- uses: ilammy/msvc-dev-cmd@v1.9.0
with:
arch: ${{ env.BUILD_ARCH }}
- name: Build
run: tools\windows-ci\genbindings.ps1

View File

@ -38,8 +38,8 @@ jobs:
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all
run: tools/travis-scripts/before-install.sh
run: tools/unix-ci/before-install.sh
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: tools/travis-scripts/run-script.sh
run: tools/unix-ci/run-script.sh

View File

@ -19,7 +19,6 @@ env:
GH_OS_NAME: linux
BUILD_TARGET: linux
BUILD_TYPE: Release
PYENV_VERSION: 2.7.18
jobs:
build:
@ -39,8 +38,8 @@ jobs:
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: tools/travis-scripts/before-install.sh
run: tools/unix-ci/before-install.sh
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: tools/travis-scripts/run-script.sh
run: tools/unix-ci/run-script.sh

View File

@ -38,8 +38,8 @@ jobs:
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all
run: tools/travis-scripts/before-install.sh
run: tools/unix-ci/before-install.sh
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: tools/travis-scripts/run-script.sh
run: tools/unix-ci/run-script.sh

View File

@ -8,7 +8,6 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
PYENV_VERSION: 2.7.18
jobs:
build-windows:
@ -44,8 +43,8 @@ jobs:
lfs: 'true'
- name: Build
run: |
tools/travis-scripts/before-install.sh
tools/travis-scripts/run-script.sh
tools/unix-ci/before-install.sh
tools/unix-ci/run-script.sh
build-android:
name: build-android
@ -59,6 +58,7 @@ jobs:
env:
GH_OS_NAME: linux
BUILD_TARGET: android
PYENV_VERSION: 2.7.18
BUILD_ARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v2
@ -67,8 +67,8 @@ jobs:
lfs: 'true'
- name: Build
run: |
tools/travis-scripts/before-install.sh
tools/travis-scripts/run-script.sh
tools/unix-ci/before-install.sh
tools/unix-ci/run-script.sh
build-osx:
name: build-osx
@ -83,8 +83,8 @@ jobs:
lfs: 'true'
- name: Build
run: |
tools/travis-scripts/before-install.sh
tools/travis-scripts/run-script.sh
tools/unix-ci/before-install.sh
tools/unix-ci/run-script.sh
build-ios:
name: build-ios
@ -99,5 +99,5 @@ jobs:
lfs: 'true'
- name: Build
run: |
tools/travis-scripts/before-install.sh
tools/travis-scripts/run-script.sh
tools/unix-ci/before-install.sh
tools/unix-ci/run-script.sh

View File

@ -1,51 +0,0 @@
Set-PSDebug -Trace 1
$python = "C:\\Python27\\python.exe"
$git_retry = "$pyhon $env:APPVEYOR_BUILD_FOLDER\tools\appveyor-scripts\git_retry.py"
function Download-Deps
{
Write-Host "Download-Deps"
& $python $env:APPVEYOR_BUILD_FOLDER\download-deps.py --remove-download=False
}
function Generate-Binding-Codes
{
$env:NDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
# install python module
& pip install PyYAML Cheetah
Write-Host "generating binding codes"
Push-Location $env:APPVEYOR_BUILD_FOLDER\tools\tolua
& $python $env:APPVEYOR_BUILD_FOLDER\tools\tolua\genbindings.py
Pop-Location
}
function Update-SubModule
{
Push-Location $env:APPVEYOR_BUILD_FOLDER
& $git_retry submodule init
& $git_retry submodule update --recursive --depth=1
Pop-Location
}
Update-SubModule
Download-Deps
& python -m pip install retry
If ($env:build_type -eq "windows32_cmake_test" ) {
& $python -u .\tools\appveyor-scripts\setup_android.py --ndk_only
Generate-Binding-Codes
}
elseif ($env:build_type -like "android*") {
& choco install ninja
& ninja --version
& $python -u .\tools\appveyor-scripts\setup_android.py
If ($env:build_type -eq "android_lua_tests") {
Generate-Binding-Codes
}
if ($lastexitcode -ne 0) {throw}
}

View File

@ -1,124 +0,0 @@
Set-PSDebug -Trace 1
$python = "D:\\Python27\\python.exe"
Write-Host "Set environment"
# gradlew
$env:ANDROID_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
$env:ANDROID_NDK_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
# gen-libs
$env:ANDROID_SDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
$env:NDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
function Retry-Command {
[CmdletBinding()]
Param(
[Parameter(Position=0, Mandatory=$true)]
[scriptblock]$ScriptBlock,
[Parameter(Position=1, Mandatory=$false)]
[int]$Maximum = 5
)
Begin {
$cnt = 0
}
Process {
do {
$cnt++
try {
$ScriptBlock.Invoke()
return
} catch {
Write-Error $_.Exception.InnerException.Message -ErrorAction Continue
}
} while ($cnt -lt $Maximum)
# Throw an error after $Maximum unsuccessful invocations. Doesn't need
# a condition, since the function returns upon successful invocation.
throw 'Execution failed.'
}
}
function PushAndroidArtifacts
{
# https://www.appveyor.com/docs/packaging-artifacts/
$root = Resolve-Path app\build\outputs\apk; [IO.Directory]::GetFiles($root.Path, '*.*', 'AllDirectories') | % { Push-AppveyorArtifact $_ -FileName $_.Substring($root.Path.Length + 1) -DeploymentName to-publish }
}
If ($env:build_type -eq "android_cpp_tests") {
Write-Host "Build tests\cpp-tests"
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-tests\proj.android\
Retry-Command -ScriptBlock {
& ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
} -Maximum 5
if ($lastexitcode -ne 0) {throw}
PushAndroidArtifacts
Pop-Location
} elseif ($env:build_type -eq "android_lua_tests") {
Write-Host "Build tests\lua-test"
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\lua-tests\project\proj.android\
# tocheck, release mode failed on "LuaTests:mergeReleaseAssets"
Retry-Command -ScriptBlock {
& ./gradlew assembleDebug -PPROP_BUILD_TYPE=cmake --parallel --info
} -Maximum 5
if ($lastexitcode -ne 0) {throw}
PushAndroidArtifacts
Pop-Location
} elseif ($env:build_type -eq "android_cpp_empty_test") {
Write-Host "Build tests\cpp-empty-test"
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-empty-test\proj.android\
Retry-Command -ScriptBlock {
& ./gradlew assembleRelease
} -Maximum 5
if ($lastexitcode -ne 0) {throw}
PushAndroidArtifacts
Pop-Location
} elseif ($env:build_type -eq "android_cocos_new_test") {
Write-Host "Create new project cocos_new_test"
& $python -u tools\console\bin\adxe.py --agreement n new -l cpp -p my.pack.qqqq cocos_new_test
if ($lastexitcode -ne 0) {throw}
Write-Host "Build cocos_new_test"
Push-Location $env:APPVEYOR_BUILD_FOLDER\cocos_new_test\proj.android\
Retry-Command -ScriptBlock {
& ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
} -Maximum 5
if ($lastexitcode -ne 0) {throw}
PushAndroidArtifacts
Pop-Location
# TODO: uncomment when fixed
# } elseif ($env:build_type -eq "android_gen_libs") {
# Write-Host "Build cocos gen-libs"
# & $python -u tools\console\bin\adxe.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n
# if ($lastexitcode -ne 0) {throw}
} elseif ($env:build_type -eq "windows32_cmake_test") {
Write-Host "Build tests project by cmake"
$ENV:PATH="$env:APPVEYOR_BUILD_FOLDER\tools\console\bin;$ENV:PATH"
& mkdir $env:APPVEYOR_BUILD_FOLDER\win32-build
# if ($lastexitcode -ne 0) {throw} # mkdir return no-zero
Push-Location $env:APPVEYOR_BUILD_FOLDER\win32-build
& cmake -A Win32 -DCMAKE_BUILD_TYPE=Release .. -DBUILD_EXTENSION_IMGUIEXT=ON
if ($lastexitcode -ne 0) {throw}
& cmake --build . --config Release --target cpp-tests
if ($lastexitcode -ne 0) {throw}
# & 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\win32-build\bin\
# if ($lastexitcode -ne 0) {throw}
# Push-AppveyorArtifact release_win32.7z
Pop-Location
}
Else {
}

View File

@ -1,165 +0,0 @@
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import optparse
import subprocess
import sys
import threading
import time
import re
GIT_EXE="git"
GIT_TRANSIENT_ERRORS = (
# crbug.com/285832
r'!.*\[remote rejected\].*\(error in hook\)',
# crbug.com/289932
r'!.*\[remote rejected\].*\(failed to lock\)',
# crbug.com/307156
r'!.*\[remote rejected\].*\(error in Gerrit backend\)',
# crbug.com/285832
r'remote error: Internal Server Error',
# crbug.com/294449
r'fatal: Couldn\'t find remote ref ',
# crbug.com/220543
r'git fetch_pack: expected ACK/NAK, got',
# crbug.com/189455
r'protocol error: bad pack header',
# crbug.com/202807
r'The remote end hung up unexpectedly',
# crbug.com/298189
r'TLS packet with unexpected length was received',
# crbug.com/187444
r'RPC failed; result=\d+, HTTP code = \d+',
# crbug.com/388876
r'Connection timed out',
# crbug.com/430343
# TODO(dnj): Resync with Chromite.
r'The requested URL returned error: 5\d+',
)
GIT_TRANSIENT_ERRORS_RE = re.compile('|'.join(GIT_TRANSIENT_ERRORS),
re.IGNORECASE)
class TeeThread(threading.Thread):
def __init__(self, fd, out_fd, name):
super(TeeThread, self).__init__(name='git-retry.tee.%s' % (name,))
self.data = None
self.fd = fd
self.out_fd = out_fd
def run(self):
chunks = []
for line in self.fd:
chunks.append(line)
self.out_fd.write(line)
self.data = ''.join(chunks)
class GitRetry(object):
logger = logging.getLogger('git-retry')
DEFAULT_DELAY_SECS = 3.0
DEFAULT_RETRY_COUNT = 5
def __init__(self, retry_count=None, delay=None, delay_factor=None):
self.retry_count = retry_count or self.DEFAULT_RETRY_COUNT
self.delay = max(delay, 0) if delay else 0
self.delay_factor = max(delay_factor, 0) if delay_factor else 0
def shouldRetry(self, stderr):
m = GIT_TRANSIENT_ERRORS_RE.search(stderr)
if not m:
return False
self.logger.info("Encountered known transient error: [%s]",
stderr[m.start(): m.end()])
return True
@staticmethod
def execute(*args):
args = (GIT_EXE,) + args
proc = subprocess.Popen(
args,
stderr=subprocess.PIPE,
)
stderr_tee = TeeThread(proc.stderr, sys.stderr, 'stderr')
# Start our process. Collect/tee 'stdout' and 'stderr'.
stderr_tee.start()
try:
proc.wait()
except KeyboardInterrupt:
proc.kill()
raise
finally:
stderr_tee.join()
return proc.returncode, None, stderr_tee.data
def computeDelay(self, iteration):
"""Returns: the delay (in seconds) for a given iteration
The first iteration has a delay of '0'.
Args:
iteration: (int) The iteration index (starting with zero as the first
iteration)
"""
if (not self.delay) or (iteration == 0):
return 0
if self.delay_factor == 0:
# Linear delay
return iteration * self.delay
# Exponential delay
return (self.delay_factor ** (iteration - 1)) * self.delay
def __call__(self, *args):
returncode = 0
for i in xrange(self.retry_count):
# If the previous run failed and a delay is configured, delay before the
# next run.
delay = self.computeDelay(i)
if delay > 0:
self.logger.info("Delaying for [%s second(s)] until next retry", delay)
time.sleep(delay)
self.logger.debug("Executing subprocess (%d/%d) with arguments: %s",
(i+1), self.retry_count, args)
returncode, _, stderr = self.execute(*args)
self.logger.debug("Process terminated with return code: %d", returncode)
if returncode == 0:
break
if not self.shouldRetry(stderr):
self.logger.error("Process failure was not known to be transient; "
"terminating with return code %d", returncode)
break
return returncode
def main(args):
parser = optparse.OptionParser()
parser.disable_interspersed_args()
parser.add_option('-v', '--verbose',
action='count', default=0,
help="Increase verbosity; can be specified multiple times")
parser.add_option('-c', '--retry-count', metavar='COUNT',
type=int, default=GitRetry.DEFAULT_RETRY_COUNT,
help="Number of times to retry (default=%default)")
parser.add_option('-d', '--delay', metavar='SECONDS',
type=float, default=GitRetry.DEFAULT_DELAY_SECS,
help="Specifies the amount of time (in seconds) to wait "
"between successive retries (default=%default). This "
"can be zero.")
parser.add_option('-D', '--delay-factor', metavar='FACTOR',
type=int, default=2,
help="The exponential factor to apply to delays in between "
"successive failures (default=%default). If this is "
"zero, delays will increase linearly. Set this to "
"one to have a constant (non-increasing) delay.")
opts, args = parser.parse_args(args)
# Configure logging verbosity
if opts.verbose == 0:
logging.getLogger().setLevel(logging.WARNING)
elif opts.verbose == 1:
logging.getLogger().setLevel(logging.INFO)
else:
logging.getLogger().setLevel(logging.DEBUG)
# Execute retries
retry = GitRetry(
retry_count=opts.retry_count,
delay=opts.delay,
delay_factor=opts.delay_factor,
)
return retry(*args)
if __name__ == '__main__':
logging.basicConfig()
logging.getLogger().setLevel(logging.WARNING)
try:
sys.exit(main(sys.argv[1:]))
except KeyboardInterrupt:
sys.stderr.write('interrupted\n')
sys.exit(1)

View File

@ -1,148 +0,0 @@
#!/usr/bin/env python
'''
aaa
'''
import os
import urllib
import zipfile
import platform
import sys
import subprocess
import tempfile
import argparse
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
print("==> setup_android.py set ssl context ok")
except Exception:
pass
from retry import retry
if(sys.version_info.major >= 3):
import urllib.request
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
COCOS2D_X = os.path.abspath(os.path.join(DIR_PATH, "../.."))
# ROOT_DIR/cocos2d-x
ROOT_DIR = os.path.abspath(os.path.join(COCOS2D_X, ".."))
NDK_VER = "19.2.5345600" # "r19c"
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
ANDROID_SDK = os.path.join(ROOT_DIR, "android-sdk")
ANDROID_NDK = os.path.join(ANDROID_SDK, "ndk/" + NDK_VER)
SDK_MANAGER = os.path.join(ROOT_DIR, "cmdline-tools/bin/sdkmanager")
SYSTEM = platform.system().lower()
if SYSTEM == "windows":
SDK_MANAGER = SDK_MANAGER + ".bat"
def run(command):
print("=" * 80)
print(command)
subprocess.check_call(command.split())
def run_with_yes(command):
print("=" * 80)
print("yes|" + command)
f = tempfile.TemporaryFile("w")
repeat_yes = 50
f.write("y\n" * repeat_yes)
f.seek(0)
subprocess.check_call(command.split(), stdin=f)
def unzip(zip_file, directory):
print("=" * 80)
print("Unzip: " + zip_file + " to " + directory)
if SYSTEM == "windows":
zipfile.ZipFile(zip_file).extractall(directory)
else:
# module zipfile ignore priviliges i.e. +x
cmd = "unzip -d " + directory + " " + zip_file
subprocess.check_output(cmd.split())
def download(url, zip_file):
print("=" * 80)
print("Download: " + url + ", file: " + zip_file)
try:
os.remove(zip_file)
except OSError:
pass
if(sys.version_info.major >= 3):
urllib.request.urlretrieve(url, zip_file)
else:
urllib.urlretrieve(url, zip_file)
@retry(Exception, tries=5, delay=1, backoff=1)
def install_android_ndk():
file_name = "android-ndk-" + NDK_VER + "-" + SYSTEM + "-x86_64.zip"
url = "https://dl.google.com/android/repository/" + file_name
zip_file = os.path.abspath(os.path.join(ROOT_DIR, file_name))
download(url, zip_file)
unzip(zip_file, ROOT_DIR)
@retry(Exception, tries=5, delay=1, backoff=1)
def install_android_cmdline_tools():
file_plat = platform.system().lower()
if file_plat == "darwin":
file_plat = "mac"
file_name = "commandlinetools-{system}-7302050_latest.zip".format(system=file_plat)
url = "https://dl.google.com/android/repository/" + file_name
zip_file = os.path.abspath(os.path.join(ROOT_DIR, file_name)) # folder is cmdline-tools
download(url, zip_file)
unzip(zip_file, os.path.join(ROOT_DIR, ""))
@retry(Exception, tries=5, delay=1, backoff=1)
def install_android_sdk():
# list packages
# run_with_yes(SDK_MANAGER + " --list --sdk_root=" + ANDROID_SDK)
switches = " --verbose --sdk_root=" + ANDROID_SDK + " "
cmd_base = SDK_MANAGER + switches
packages = [
'platform-tools',
'cmdline-tools;latest',
'platforms;android-28',
'build-tools;29.0.2',
'ndk;' + NDK_VER
]
run_with_yes(cmd_base + " ".join(packages))
# run_with_yes(cmd_base + " --install ndk;" + NDK_VER)
def export_environment(ndk_only):
with open(os.path.join(ROOT_DIR, "environment.sh"), "a") as myfile:
if not ndk_only:
myfile.write("export ANDROID_HOME=" + ANDROID_SDK + "\n")
myfile.write("export ANDROID_SDK_ROOT=" + ANDROID_SDK + "\n")
myfile.write("export ANDROID_NDK_HOME=" + ANDROID_NDK + "\n")
myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n")
with open(os.path.join(ROOT_DIR, "environment.ps1"), "a") as myfile:
if not ndk_only:
myfile.write("$env:ANDROID_HOME=\"" + ANDROID_SDK + "\"\n")
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK + "\"\n")
myfile.write("$env:ANDROID_NDK_HOME=\"" + ANDROID_NDK + "\"\n")
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n")
def main(ndk_only):
# if not ndk_only:
install_android_cmdline_tools()
install_android_sdk()
# install_android_ndk()
export_environment(ndk_only)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Install android sdk/ndk')
parser.add_argument("--ndk_only", help="Install ndk only", action="store_true")
args = parser.parse_args()
main(args.ndk_only)

View File