From 4567eee79eccbc5517aef3cc9a492b45e0946beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 24 Jul 2020 10:19:19 +0200 Subject: [PATCH] CI: Backport GitHub Actions setup from `master` Removes AppVeyor and all Travis jobs but the iOS one, which hasn't been ported to GitHub Actions yet (should be done soon). Backports new style scripts from `master` branch too to do the same checks. --- .appveyor.yml | 51 ------- .github/workflows/android_builds.yml | 72 ++++++++++ .github/workflows/javascript_builds.yml | 76 +++++++++++ .github/workflows/linux_builds.yml | 117 ++++++++++++++++ .github/workflows/macos_builds.yml | 94 +++++++++++++ .github/workflows/static_checks.yml | 32 +++++ .../{main.yml => windows_builds.yml} | 56 ++++---- .travis.yml | 127 +----------------- misc/{travis => ci}/android-tools-linux.sh | 4 +- misc/ci/sources.list | 4 + misc/scripts/black_format.sh | 35 +++++ misc/scripts/clang_format.sh | 58 ++++++++ .../{fix_headers.py => copyright_headers.py} | 105 +++++++-------- misc/scripts/file_format.sh | 59 ++++++++ misc/scripts/fix_style.sh | 60 --------- misc/travis/black-format.sh | 48 ------- misc/travis/ccache-osx.sh | 43 ------ misc/travis/clang-format.sh | 48 ------- 18 files changed, 626 insertions(+), 463 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .github/workflows/android_builds.yml create mode 100644 .github/workflows/javascript_builds.yml create mode 100644 .github/workflows/linux_builds.yml create mode 100644 .github/workflows/macos_builds.yml create mode 100644 .github/workflows/static_checks.yml rename .github/workflows/{main.yml => windows_builds.yml} (71%) rename misc/{travis => ci}/android-tools-linux.sh (97%) create mode 100644 misc/ci/sources.list create mode 100755 misc/scripts/black_format.sh create mode 100755 misc/scripts/clang_format.sh rename misc/scripts/{fix_headers.py => copyright_headers.py} (53%) create mode 100755 misc/scripts/file_format.sh delete mode 100755 misc/scripts/fix_style.sh delete mode 100755 misc/travis/black-format.sh delete mode 100755 misc/travis/ccache-osx.sh delete mode 100755 misc/travis/clang-format.sh diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 026a5daab23..00000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,51 +0,0 @@ -image: Visual Studio 2019 - -platform: x64 - -environment: - HOME: "%HOMEDRIVE%%HOMEPATH%" - PYTHON: C:\Python38 - SCONS_CACHE_ROOT: "%HOME%\\scons_cache" - SCONS_CACHE_LIMIT: 1024 - OPTIONS: "debug_symbols=no verbose=yes progress=no" - EXTRA_ARGS: "warnings=all werror=yes" - matrix: - - GD_PLATFORM: windows - TARGET: release_debug - TOOLS: yes - -matrix: - fast_finish: true - -init: - - ps: if ($env:APPVEYOR_REPO_BRANCH -ne "3.2") { $env:APPVEYOR_CACHE_SKIP_SAVE = "true" } - -cache: - - "%SCONS_CACHE_ROOT%" - -install: - - SET "PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - - pip install -U wheel # needed for pip install scons to work, otherwise a flag is missing - - pip install scons # use stable scons - - if defined VS call "%VS%" %ARCH% # if defined - so we can also use mingw - -before_build: - - echo %GD_PLATFORM% - - python --version - - scons --version - - set "SCONS_CACHE=%SCONS_CACHE_ROOT%\%APPVEYOR_REPO_BRANCH%" - -build_script: - - scons platform=%GD_PLATFORM% target=%TARGET% tools=%TOOLS% %OPTIONS% %EXTRA_ARGS% - -after_build: - - git rev-parse --short=9 HEAD > VERSION_HASH.txt - - set /P VERSION_HASH= < VERSION_HASH.txt - - cd bin - - mv godot.windows.opt.tools.64.exe godot_%APPVEYOR_REPO_BRANCH%-%VERSION_HASH%_win64.exe - - 7z a -mx9 godot_%APPVEYOR_REPO_BRANCH%-%VERSION_HASH%_win64.zip *.exe - -artifacts: - - path: bin/godot_${APPVEYOR_REPO_BRANCH}-${VERSION_HASH}_win64.zip - name: Win64 release_debug editor build - type: zip diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml new file mode 100644 index 00000000000..e05909f79e1 --- /dev/null +++ b/.github/workflows/android_builds.yml @@ -0,0 +1,72 @@ +name: Android Builds +on: [push, pull_request] + +# Global Cache Settings +env: + GODOT_BASE_BRANCH: 3.2 + SCONS_CACHE_LIMIT: 4096 + +jobs: + android-template: + runs-on: "ubuntu-20.04" + + name: Template (target=release, tools=no) + + steps: + - uses: actions/checkout@v2 + + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Install all packages (except scons) + - name: Configure dependencies + run: | + sudo apt-get install openjdk-8-jdk + echo "::set-env name=JAVA_HOME::usr/lib/jvm/java-8-openjdk-amd64" + + - name: Install Android SDK and NDK + run: | + echo "::set-env name=PATH::/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:${PATH}" + java -version + echo "::set-env name=ANDROID_HOME::$(pwd)/godot-dev/build-tools/android-sdk" + echo "::set-env name=ANDROID_NDK_ROOT::$(pwd)/godot-dev/build-tools/android-ndk" + misc/ci/android-tools-linux.sh + source ~/.bashrc + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: android-template-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Use python 3.x release (works cross platform) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # You can test your matrix by printing the current Python version + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=android target=release tools=no diff --git a/.github/workflows/javascript_builds.yml b/.github/workflows/javascript_builds.yml new file mode 100644 index 00000000000..be305c0c09f --- /dev/null +++ b/.github/workflows/javascript_builds.yml @@ -0,0 +1,76 @@ +name: JavaScript Builds +on: [push, pull_request] + +# Global Cache Settings +env: + GODOT_BASE_BRANCH: 3.2 + SCONS_CACHE_LIMIT: 4096 + EM_VERSION: latest + EM_CACHE_FOLDER: 'emsdk-cache' + +jobs: + javascript-template: + runs-on: "ubuntu-20.04" + name: Template (target=release, tools=no) + + steps: + - uses: actions/checkout@v2 + + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: javascript-template-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Additional cache for Emscripten generated system libraries + - name: Load Emscripten cache + id: javascript-template-emscripten-cache + uses: actions/cache@v2 + with: + path: ${{env.EM_CACHE_FOLDER}} + key: ${{env.EM_VERSION}}-${{github.job}} + + # Use python 3.x release (works cross platform) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # You can test your matrix by printing the current Python version + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + - name: Set up Emscripten latest + uses: mymindstorm/setup-emsdk@v6 + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + + - name: Verify Emscripten setup + run: | + emcc -v + + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=javascript target=release tools=no use_closure_compiler=yes diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml new file mode 100644 index 00000000000..701b705f142 --- /dev/null +++ b/.github/workflows/linux_builds.yml @@ -0,0 +1,117 @@ +name: Linux Builds +on: [push, pull_request] + +# Global Cache Settings +env: + GODOT_BASE_BRANCH: 3.2 + SCONS_CACHE_LIMIT: 4096 + +jobs: + linux-editor: + runs-on: "ubuntu-20.04" + name: Editor w/ Mono (target=release_debug, tools=yes) + + steps: + - uses: actions/checkout@v2 + + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Install all packages (except scons) + - name: Configure dependencies + run: | + sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ + libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: linux-editor-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Use python 3.x release (works cross platform; best to keep self contained in it's own step) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # Setup scons, print python version and scons version info, so if anything is broken it won't run the build. + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + # We should always be explicit with our flags usage here since it's gonna be sure to always set those flags + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=x11 tools=yes target=release_debug module_mono_enabled=yes mono_glue=no + + linux-template: + runs-on: "ubuntu-20.04" + name: Template w/ Mono (target=release, tools=no) + + steps: + - uses: actions/checkout@v2 + + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Install all packages (except scons) + - name: Configure dependencies + run: | + sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ + libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: linux-template-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Use python 3.x release (works cross platform) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # You can test your matrix by printing the current Python version + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=x11 target=release tools=no module_mono_enabled=yes mono_glue=no diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml new file mode 100644 index 00000000000..28fc4885d89 --- /dev/null +++ b/.github/workflows/macos_builds.yml @@ -0,0 +1,94 @@ +name: MacOS Builds +on: [push, pull_request] + +# Global Cache Settings +env: + GODOT_BASE_BRANCH: 3.2 + SCONS_CACHE_LIMIT: 4096 + +jobs: + macos-editor: + runs-on: "macos-latest" + + name: Editor (target=release_debug, tools=yes) + + steps: + - uses: actions/checkout@v2 + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: macos-editor-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Use python 3.x release (works cross platform; best to keep self contained in it's own step) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # Setup scons, print python version and scons version info, so if anything is broken it won't run the build. + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + # We should always be explicit with our flags usage here since it's gonna be sure to always set those flags + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=osx tools=yes target=release_debug + + macos-template: + runs-on: "macos-latest" + name: Template (target=release, tools=no) + + steps: + - uses: actions/checkout@v2 + + # Upload cache on completion and check it out now + - name: Load .scons_cache directory + id: macos-template-cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} + + # Use python 3.x release (works cross platform) + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + # Semantic version range syntax or exact version of a Python version + python-version: '3.x' + # Optional - x64 or x86 architecture, defaults to x64 + architecture: 'x64' + + # You can test your matrix by printing the current Python version + - name: Configuring Python packages + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + python --version + scons --version + + - name: Compilation + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + scons -j2 verbose=yes warnings=all werror=yes platform=osx target=release tools=no diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 00000000000..87339da776b --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,32 @@ +name: Static Checks +on: [push, pull_request] + +jobs: + static-checks: + name: Static Checks (clang-format, black format, file format, documentation checks) + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq dos2unix recode clang-format + sudo pip3 install black pygments + + - name: File formatting checks (file_format.sh) + run: | + bash ./misc/scripts/file_format.sh + + - name: Style checks via clang-format (clang_format.sh) + run: | + bash ./misc/scripts/clang_format.sh + + - name: Python style checks via black (black_format.sh) + run: | + bash ./misc/scripts/black_format.sh + + - name: Documentation checks + run: | + doc/tools/makerst.py --dry-run doc/classes modules diff --git a/.github/workflows/main.yml b/.github/workflows/windows_builds.yml similarity index 71% rename from .github/workflows/main.yml rename to .github/workflows/windows_builds.yml index 2ef335fe020..99f609a3fd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/windows_builds.yml @@ -1,52 +1,45 @@ -# Engine build CI -name: Godot CI - -on: - # will build EVERY pull request - pull_request: - - # will only build explicit branches - push: - branches: [ master, 3.2, 3.1, 3.0 ] +name: Windows Builds +on: [push, pull_request] # Global Cache Settings # SCONS_CACHE for windows must be set in the build environment env: + GODOT_BASE_BRANCH: 3.2 SCONS_CACHE_MSVC_CONFIG: true - SCONS_CACHE_LIMIT: 8192 + SCONS_CACHE_LIMIT: 4096 + jobs: windows-editor: # Windows 10 with latest image runs-on: "windows-latest" # Windows Editor - checkout with the plugin - name: Windows Editor (target=release_debug, tools=yes) + name: Editor (target=release_debug, tools=yes) steps: - uses: actions/checkout@v2 - # Upload cache on completion and check it out now - # Editing this is pretty dangerous for windows since it can break and needs properly tested with a fresh cache. - # Linux with this will work reliably, so not as bad to edit for Linux. + # Upload cache on completion and check it out now + # Editing this is pretty dangerous for Windows since it can break and needs to be properly tested with a fresh cache. - name: Load .scons_cache directory id: windows-editor-cache uses: RevoluPowered/cache@v2.1 with: path: /.scons_cache/ - key: ${{runner.os}}-editor-${{github.sha}} + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} restore-keys: | - ${{runner.os}}-editor-${{github.sha}} - ${{runner.os}}-editor - ${{runner.os}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} # Use python 3.x release (works cross platform; best to keep self contained in it's own step) - name: Set up Python 3.x uses: actions/setup-python@v2 with: # Semantic version range syntax or exact version of a Python version - python-version: '3.x' + python-version: '3.x' # Optional - x64 or x86 architecture, defaults to x64 - architecture: 'x64' + architecture: 'x64' # Setup scons, print python version and scons version info, so if anything is broken it won't run the build. - name: Configuring Python packages @@ -72,36 +65,34 @@ jobs: # name: windows-editor (x64) # path: bin/godot.windows.opt.tools.64.exe - windows-template: runs-on: "windows-latest" - name: Windows Template (target=release, tools=no) + name: Template (target=release, tools=no) steps: - uses: actions/checkout@v2 # Upload cache on completion and check it out now - # Editing this is pretty dangerous for windows since it can break and needs properly tested with a fresh cache. - # Linux with this will work reliably, so not as bad to edit for Linux. + # Editing this is pretty dangerous for Windows since it can break and needs to be properly tested with a fresh cache. - name: Load .scons_cache directory id: windows-template-cache uses: RevoluPowered/cache@v2.1 with: path: /.scons_cache/ - key: ${{runner.os}}-template-${{github.sha}} + key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} restore-keys: | - ${{runner.os}}-template-${{github.sha}} - ${{runner.os}}-template - ${{runner.os}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{github.job}}-${{env.GODOT_BASE_BRANCH}} - # Use python 3.x release (works cross platform) + # Use python 3.x release (works cross platform) - name: Set up Python 3.x uses: actions/setup-python@v2 with: # Semantic version range syntax or exact version of a Python version - python-version: '3.x' + python-version: '3.x' # Optional - x64 or x86 architecture, defaults to x64 - architecture: 'x64' + architecture: 'x64' # You can test your matrix by printing the current Python version - name: Configuring Python packages @@ -110,6 +101,7 @@ jobs: python -m pip install scons pywin32 python --version scons --version + - name: Compilation env: SCONS_CACHE: /.scons_cache/ diff --git a/.travis.yml b/.travis.yml index 6acd0ab0d9b..485e943dfd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,11 @@ language: cpp # OS config, depends on actual 'os' in build matrix dist: xenial -stages: - - check - - build - env: global: - SCONS_CACHE=$HOME/.scons_cache/$TRAVIS_BRANCH - SCONS_CACHE_LIMIT=1024 - - OPTIONS="debug_symbols=no verbose=yes progress=no builtin_libpng=yes" - - secure: "uch9QszCgsl1qVbuzY41P7S2hWL2IiNFV4SbAYRCdi0oJ9MIu+pVyrQdpf3+jG4rH6j4Rffl+sN17Zz4dIDDioFL1JwqyCqyCyswR8uACC0Rr8gr4Mi3+HIRbv+2s2P4cIQq41JM8FJe84k9jLEMGCGh69w+ibCWoWs74CokYVA=" + - OPTIONS="debug_symbols=no verbose=yes progress=no" cache: directories: @@ -20,56 +15,9 @@ cache: matrix: include: - - name: Static checks (clang-format) + Documentation checks - stage: check - env: STATIC_CHECKS=yes - os: linux - compiler: gcc - addons: - apt: - sources: - - llvm-toolchain-xenial-8 - packages: - - clang-format-8 - - - name: Linux editor (debug, GCC 9, with Mono) + - name: iOS export template (release, Clang) stage: build - env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes" - os: linux - compiler: gcc-9 - addons: - apt: - sources: - - mono - - ubuntu-toolchain-r-test - packages: - - &gcc9_deps [gcc-9, g++-9] - - &linux_deps [libasound2-dev, libgl1-mesa-dev, libglu1-mesa-dev, libx11-dev, libxcursor-dev, libxi-dev, libxinerama-dev, libxrandr-dev] - - &linux_mono_deps [mono-devel, msbuild, nuget] - - - name: Linux export template (release, Clang) - stage: build - env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes" - os: linux - compiler: clang - addons: - apt: - packages: - - *linux_deps - - - name: Android export template (release_debug, Clang) - stage: build - env: PLATFORM=android TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes" - os: linux - compiler: clang - addons: - apt: - packages: - - openjdk-8-jdk - - - name: macOS editor (debug, Clang) - stage: build - env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes" + env: PLATFORM=iphone TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang os: osx compiler: clang addons: @@ -78,76 +26,9 @@ matrix: - scons update: true - - name: iOS export template (debug, Clang) - stage: build - env: PLATFORM=iphone TOOLS=no TARGET=debug CACHE_NAME=${PLATFORM}-clang - os: osx - compiler: clang - addons: - homebrew: - packages: - - scons - update: true - - - name: Linux headless editor (release_debug, GCC 9, testing project exporting and script running) - stage: build - env: PLATFORM=server TOOLS=yes TARGET=release_debug CACHE_NAME=${PLATFORM}-tools-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="warnings=extra werror=yes" TEST_PROJECT=yes - os: linux - compiler: gcc-9 - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - *gcc9_deps - - *linux_deps - - - name: Linux export template (release_debug, GCC 5, without 3D support) - stage: build - env: PLATFORM=x11 TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-5 EXTRA_ARGS="CXXFLAGS=-fno-strict-aliasing disable_3d=yes" - os: linux - compiler: gcc - addons: - apt: - packages: - - *linux_deps - before_install: - eval "${MATRIX_EVAL}" - -install: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - pyenv global 3.7.1 system; - pip3 install --user scons; - fi - scons --version - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PLATFORM" = "android" ]; then - export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64; - export PATH=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:${PATH}; - java -version; - misc/travis/android-tools-linux.sh; - fi - - if [ "$STATIC_CHECKS" = "yes" ]; then - unset SCONS_CACHE; - pip3 install --user black pygments; - fi - -before_script: - - if [ "$PLATFORM" = "android" ]; then - export ANDROID_HOME=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-sdk; - export ANDROID_NDK_ROOT=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-ndk; - fi script: - - if [ "$STATIC_CHECKS" = "yes" ]; then - sh ./misc/travis/clang-format.sh && - sh ./misc/travis/black-format.sh && - doc/tools/makerst.py --dry-run doc/classes modules; - else - scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS && - if [ "$TEST_PROJECT" = "yes" ]; then - git clone --depth 1 "https://github.com/godotengine/godot-tests.git"; - sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.x11.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg; - godot-tests/tests/project_export/test_project.sh "bin/godot_server.x11.opt.tools.64"; - fi - fi + - scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS diff --git a/misc/travis/android-tools-linux.sh b/misc/ci/android-tools-linux.sh similarity index 97% rename from misc/travis/android-tools-linux.sh rename to misc/ci/android-tools-linux.sh index 00a8b73d3a9..6114551861c 100755 --- a/misc/travis/android-tools-linux.sh +++ b/misc/ci/android-tools-linux.sh @@ -24,12 +24,12 @@ ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR ANDROID_SDK_SHA256=92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9 -ANDROID_NDK_RELEASE=r20 +ANDROID_NDK_RELEASE=r21 ANDROID_NDK_DIR=android-ndk ANDROID_NDK_FILENAME=android-ndk-$ANDROID_NDK_RELEASE-linux-x86_64.zip ANDROID_NDK_URL=$ANDROID_BASE_URL/$ANDROID_NDK_FILENAME ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR -ANDROID_NDK_SHA1=8665fc84a1b1f0d6ab3b5fdd1e30200cc7b9adff +ANDROID_NDK_SHA1=afc9c0b9faad222898ac8168c78ad4ccac8a1b5c echo echo "Download and install Android development tools ..." diff --git a/misc/ci/sources.list b/misc/ci/sources.list new file mode 100644 index 00000000000..4d8f94f35c4 --- /dev/null +++ b/misc/ci/sources.list @@ -0,0 +1,4 @@ +deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse diff --git a/misc/scripts/black_format.sh b/misc/scripts/black_format.sh new file mode 100755 index 00000000000..04dfe32f606 --- /dev/null +++ b/misc/scripts/black_format.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This script runs black on all Python files in the repo. + +set -uo pipefail + +# Apply black. +echo -e "Formatting Python files..." +PY_FILES=$(find \( -path "./.git" \ + -o -path "./thirdparty" \ + \) -prune \ + -o \( -name "SConstruct" \ + -o -name "SCsub" \ + -o -name "*.py" \ + \) -print) +black -l 120 $PY_FILES + +git diff > patch.patch +FILESIZE="$(stat -c%s patch.patch)" +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the black style rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh new file mode 100755 index 00000000000..5131f7fe333 --- /dev/null +++ b/misc/scripts/clang_format.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# This script runs clang-format and fixes copyright headers on all relevant files in the repo. +# This is the primary script responsible for fixing style violations. + +set -uo pipefail +IFS=$'\n\t' + +CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl") + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude some files. + if [[ "$f" == "thirdparty"* ]]; then + continue + elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then + continue + fi + + for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do + if [[ "$f" == *"$extension" ]]; then + # Run clang-format. + clang-format -i "$f" + # Fix copyright headers, but not all files get them. + if [[ "$f" == *"inc" ]]; then + continue 2 + elif [[ "$f" == *"glsl" ]]; then + continue 2 + elif [[ "$f" == *"theme_data.h" ]]; then + continue 2 + elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then + continue 2 + fi + python misc/scripts/copyright_headers.py "$f" + continue 2 + fi + done +done + +git diff > patch.patch +FILESIZE="$(stat -c%s patch.patch)" +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the clang-format style rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/misc/scripts/fix_headers.py b/misc/scripts/copyright_headers.py similarity index 53% rename from misc/scripts/fix_headers.py rename to misc/scripts/copyright_headers.py index 7af97eec4bb..bf1e0d3f9cc 100755 --- a/misc/scripts/fix_headers.py +++ b/misc/scripts/copyright_headers.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import sys + header = """\ /*************************************************************************/ /* $filename */ @@ -33,70 +35,61 @@ header = """\ /*************************************************************************/ """ -files = open("files", "r") +fname = sys.argv[1] -fname = files.readline() +# Handle replacing $filename with actual filename and keep alignment +fsingle = fname.strip() +if fsingle.find("/") != -1: + fsingle = fsingle[fsingle.rfind("/") + 1 :] +rep_fl = "$filename" +rep_fi = fsingle +len_fl = len(rep_fl) +len_fi = len(rep_fi) +# Pad with spaces to keep alignment +if len_fi < len_fl: + for x in range(len_fl - len_fi): + rep_fi += " " +elif len_fl < len_fi: + for x in range(len_fi - len_fl): + rep_fl += " " +if header.find(rep_fl) != -1: + text = header.replace(rep_fl, rep_fi) +else: + text = header.replace("$filename", fsingle) +text += "\n" -while fname != "": +# We now have the proper header, so we want to ignore the one in the original file +# and potentially empty lines and badly formatted lines, while keeping comments that +# come after the header, and then keep everything non-header unchanged. +# To do so, we skip empty lines that may be at the top in a first pass. +# In a second pass, we skip all consecutive comment lines starting with "/*", +# then we can append the rest (step 2). - # Handle replacing $filename with actual filename and keep alignment - fsingle = fname.strip() - if fsingle.find("/") != -1: - fsingle = fsingle[fsingle.rfind("/") + 1 :] - rep_fl = "$filename" - rep_fi = fsingle - len_fl = len(rep_fl) - len_fi = len(rep_fi) - # Pad with spaces to keep alignment - if len_fi < len_fl: - for x in range(len_fl - len_fi): - rep_fi += " " - elif len_fl < len_fi: - for x in range(len_fi - len_fl): - rep_fl += " " - if header.find(rep_fl) != -1: - text = header.replace(rep_fl, rep_fi) - else: - text = header.replace("$filename", fsingle) - text += "\n" +fileread = open(fname.strip(), "r") +line = fileread.readline() +header_done = False - # We now have the proper header, so we want to ignore the one in the original file - # and potentially empty lines and badly formatted lines, while keeping comments that - # come after the header, and then keep everything non-header unchanged. - # To do so, we skip empty lines that may be at the top in a first pass. - # In a second pass, we skip all consecutive comment lines starting with "/*", - # then we can append the rest (step 2). - - fileread = open(fname.strip(), "r") +while line.strip() == "": # Skip empty lines at the top line = fileread.readline() - header_done = False - while line.strip() == "": # Skip empty lines at the top - line = fileread.readline() +if line.find("/**********") == -1: # Godot header starts this way + # Maybe starting with a non-Godot comment, abort header magic + header_done = True - if line.find("/**********") == -1: # Godot header starts this way - # Maybe starting with a non-Godot comment, abort header magic +while not header_done: # Handle header now + if line.find("/*") != 0: # No more starting with a comment header_done = True + if line.strip() != "": + text += line + line = fileread.readline() - while not header_done: # Handle header now - if line.find("/*") != 0: # No more starting with a comment - header_done = True - if line.strip() != "": - text += line - line = fileread.readline() +while line != "": # Dump everything until EOF + text += line + line = fileread.readline() - while line != "": # Dump everything until EOF - text += line - line = fileread.readline() +fileread.close() - fileread.close() - - # Write - filewrite = open(fname.strip(), "w") - filewrite.write(text) - filewrite.close() - - # Next file - fname = files.readline() - -files.close() +# Write +filewrite = open(fname.strip(), "w") +filewrite.write(text) +filewrite.close() diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh new file mode 100755 index 00000000000..30988e51c67 --- /dev/null +++ b/misc/scripts/file_format.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# This script ensures proper POSIX text file formatting and a few other things. +# This is supplementary to clang-black-format.sh, but should be run before it. + +set -uo pipefail +IFS=$'\n\t' + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude some types of files. + if [[ "$f" == *"csproj" ]]; then + continue + elif [[ "$f" == *"sln" ]]; then + continue + elif [[ "$f" == *"patch" ]]; then + continue + elif [[ "$f" == *"pot" ]]; then + continue + elif [[ "$f" == *"po" ]]; then + continue + elif [[ "$f" == "thirdparty"* ]]; then + continue + elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then + continue + fi + # Ensures that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensures that files have LF line endings. + dos2unix "$f" 2> /dev/null + # Ensures that files do not contain a BOM. + sed -i '1s/^\xEF\xBB\xBF//' "$f" + # Ensures that files end with newline characters. + tail -c1 < "$f" | read -r _ || echo >> "$f"; + # Remove trailing space characters. + sed -z -i 's/\x20\x0A/\x0A/g' "$f" + # Remove the character sequence "== true" if it has a leading space. + sed -z -i 's/\x20== true//g' "$f" +done + +git diff > patch.patch +FILESIZE="$(stat -c%s patch.patch)" +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh deleted file mode 100755 index b33cb0a7b43..00000000000 --- a/misc/scripts/fix_style.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -# Command line arguments -run_clang_format=false -run_fix_headers=false -usage="Invalid argument. Usage:\n$0