Skip to content

Commit

Permalink
Merge branch 'master' into astolfo-feature/builtin-quaternion
Browse files Browse the repository at this point in the history
  • Loading branch information
RealAstolfo authored Feb 5, 2023
2 parents 5b5d522 + a2b57de commit 1bc92aa
Show file tree
Hide file tree
Showing 100 changed files with 6,151 additions and 1,804 deletions.
51 changes: 51 additions & 0 deletions .github/composite/godot-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

name: godot
description: "Run Godot integration tests"

inputs:
artifact-name:
required: true
description: "Name of the compiled Godot artifact to download"

binary-filename:
required: true
description: "Filename of the Godot executable"


runs:
using: "composite"
steps:
- uses: actions/checkout@v3

# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Store variable to Godot binary"
run: |
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
echo "GODOT4_BIN=$runnerDir/godot_bin/${{ inputs.binary-filename }}" >> $GITHUB_ENV
shell: bash

# - name: "Check cache for installed Godot version"
# id: "cache-godot"
# uses: actions/cache@v3
# with:
# path: ${{ runner.temp }}/godot_bin
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}
# shell: bash

- name: "Download Godot artifact"
# if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/${{ inputs.artifact-name }}.zip \
-Lo artifact.zip \
--retry 3
unzip artifact.zip -d $RUNNER_DIR/godot_bin
shell: bash

- name: "Prepare Godot executable"
run: |
chmod +x $GODOT4_BIN
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,27 @@ inputs:
default: ''
description: "Extra command line arguments for 'cargo build', e.g. features"

with-llvm:
required: false
description: "Set to 'true' if LLVM should be installed"
default: ''


runs:
using: "composite"
steps:
- uses: actions/checkout@v3

# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Store variable to Godot binary"
run: |
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
echo "GODOT4_BIN=$runnerDir/godot_bin/${{ inputs.binary-filename }}" >> $GITHUB_ENV
shell: bash

# - name: "Check cache for installed Godot version"
# id: "cache-godot"
# uses: actions/cache@v3
# with:
# path: ${{ runner.temp }}/godot_bin
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}

- name: "Download Godot artifact"
# if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/${{ inputs.artifact-name }}.zip -Lo artifact.zip
unzip artifact.zip -d $RUNNER_DIR/godot_bin
shell: bash
- name: "Install Godot"
uses: ./.github/composite/godot-install
with:
artifact-name: ${{ inputs.artifact-name }}
binary-filename: ${{ inputs.binary-filename }}

# The chmod seems still necessary, although applied before uploading artifact. Possibly modes are not preserved.
# The `| xargs` pattern trims the output, since printed version may contain extra newline, which causes problems in env vars.
- name: "Inspect Godot version"
run: |
chmod +x $GODOT4_BIN
godotVer=$($GODOT4_BIN --version | xargs || true)
gitSha=$(echo $godotVer | sed -E "s/.+custom_build\.//")
echo "GODOT_BUILT_FROM=_Built from [\`$godotVer\`](https://github.com/godotengine/godot/commit/$gitSha)._" >> $GITHUB_ENV
Expand Down Expand Up @@ -89,10 +77,7 @@ runs:
uses: ./.github/composite/rust
with:
rust: ${{ inputs.rust-toolchain }}

- name: "Install LLVM"
uses: ./.github/composite/llvm
# TODO only run it on systems needed
with-llvm: ${{ inputs.with-llvm }}

- name: "Build godot-rust"
run: |
Expand All @@ -109,7 +94,7 @@ runs:
run: |
cd itest/godot
echo "OUTCOME=itest" >> $GITHUB_ENV
$GODOT4_BIN --headless 2>&1 | tee >(grep "SCRIPT ERROR:" -q && {
$GODOT4_BIN --headless 2>&1 | tee "${{ runner.temp }}/log.txt" | tee >(grep "SCRIPT ERROR:" -q && {
printf "\n -- Godot engine encountered error, abort...\n";
pkill godot
echo "OUTCOME=godot-runtime" >> $GITHUB_ENV
Expand All @@ -119,6 +104,14 @@ runs:
echo "OUTCOME=success" >> $GITHUB_ENV
shell: bash

- name: "Check for memory leaks"
run: |
if grep -q "ObjectDB instances leaked at exit" "${{ runner.temp }}/log.txt"; then
echo "OUTCOME=godot-leak" >> $GITHUB_ENV
exit 2
fi
shell: bash

- name: "Conclusion"
if: always()
run: |
Expand All @@ -137,10 +130,17 @@ runs:
exit 2
;;
"godot-leak")
echo "### :x: Memory leak" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
echo "Integration tests cause memory leaks." >> $GITHUB_STEP_SUMMARY
exit 3
;;
"itest")
echo "### :x: Godot integration tests failed" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
exit 3
exit 4
;;
"header-diff")
Expand All @@ -150,7 +150,7 @@ runs:
*)
echo "### :x: Unknown error occurred" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
exit 4
exit 5
;;
esac
shell: bash
11 changes: 11 additions & 0 deletions .github/composite/rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ inputs:
required: false
description: "Rust toolchain, e.g. 'stable' or 'nightly'"
default: stable

components:
required: false
description: "Components array"
default: ''

cache-key:
required: false
description: "Extra key to resolve cache"
default: ''

with-llvm:
required: false
description: "Set to 'true' if LLVM should be installed"
default: ''

runs:
using: "composite"
steps:
Expand All @@ -41,6 +48,10 @@ runs:
with:
shared-key: ${{ inputs.cache-key }}

- name: "Install LLVM"
uses: ./.github/composite/llvm
if: ${{ inputs.with-llvm == 'true' }}

- name: "Set environment variables used by toolchain"
run: |
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
Expand Down
3 changes: 2 additions & 1 deletion .github/external-config/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ header:
paths:
- '**/*.rs'
- '**/*.gd'
- '**/*.sh'
- '.github/**/*.yml'

paths-ignore:
Expand All @@ -20,7 +21,7 @@ header:

language:
GDScript:
extensions: ['.gd']
extensions: ['.gd', '.sh']
comment_style_id: 'Hashtag'
Rust:
extensions: ['.rs']
Expand Down
81 changes: 63 additions & 18 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ on:
- trying

env:
GDEXT_FEATURES: 'godot-core/convenience'
GDEXT_CRATE_ARGS: '-p godot-codegen -p godot-ffi -p godot-core -p godot-macros -p godot'
GDEXT_FEATURES: '--features godot-core/convenience'
# GDEXT_CRATE_ARGS: '-p godot-codegen -p godot-ffi -p godot-core -p godot-macros -p godot'

defaults:
run:
Expand All @@ -31,17 +31,41 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust
with:
rust: stable
components: rustfmt

- name: "Check rustfmt"
run: cargo fmt --all -- --check


clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust

# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Install Godot"
uses: ./.github/composite/godot-install
with:
artifact-name: godot-linux
binary-filename: godot.linuxbsd.editor.dev.x86_64

- name: "Check clippy"
run: |
cargo clippy --all-targets $GDEXT_FEATURES -- -D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf \
-D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings
unit-test:
name: unit-test (${{ matrix.name }})
name: unit-test (${{ matrix.name }}${{ matrix.rust-special }})
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
Expand All @@ -54,21 +78,25 @@ jobs:
- name: macos
os: macos-11
rust-toolchain: stable
godot-binary: godot.macos.editor.dev.x86_64

- name: windows
os: windows-latest
rust-toolchain: stable-x86_64-pc-windows-msvc
godot-binary: godot.windows.editor.dev.x86_64.exe

# Don't use latest Ubuntu (22.04) as it breaks lots of ecosystem compatibility.
# If ever moving to ubuntu-latest, need to manually install libtinfo5 for LLVM.
- name: linux
os: ubuntu-20.04
rust-toolchain: stable
godot-binary: godot.linuxbsd.editor.dev.x86_64

- name: linux-minimal-deps
- name: linux
os: ubuntu-20.04
rust-toolchain: stable
rust-special: minimal-deps
rust-special: -minimal-deps
godot-binary: godot.linuxbsd.editor.dev.x86_64

steps:
- uses: actions/checkout@v3
Expand All @@ -78,33 +106,39 @@ jobs:
with:
rust: stable
cache-key: ${{ matrix.rust-special }} # 'minimal-deps' or empty/not defined
with-llvm: ${{ matrix.name == 'macos' }}

- name: "Install Rust nightly (minimal deps)"
uses: ./.github/composite/rust
with:
rust: nightly
cache-key: minimal-deps-nightly
if: ${{ matrix.rust-special == 'minimal-deps' }}
if: ${{ matrix.rust-special == '-minimal-deps' }}

- name: "Install minimal dependency versions from Cargo"
run: cargo +nightly update -Z minimal-versions
if: ${{ matrix.rust-special == 'minimal-deps' }}
if: ${{ matrix.rust-special == '-minimal-deps' }}

- name: "Install LLVM"
uses: ./.github/composite/llvm
if: matrix.name == 'macos'
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Install Godot"
uses: ./.github/composite/godot-install
with:
artifact-name: godot-${{ matrix.name }}
binary-filename: ${{ matrix.godot-binary }}

- name: "Compile tests"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES --no-run
run: cargo test $GDEXT_FEATURES --no-run

- name: "Test"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES ${{ matrix.testflags }}
run: cargo test $GDEXT_FEATURES


itest-godot:
name: itest-godot (${{ matrix.name }})
godot-itest:
name: godot-itest (${{ matrix.name }})
runs-on: ${{ matrix.os }}
continue-on-error: false
# TODO: continue-on-error: false, as soon as memory errors are fixed
continue-on-error: ${{ contains(matrix.name, 'memcheck') }}
timeout-minutes: 24
strategy:
fail-fast: false # cancel all jobs as soon as one fails?
Expand All @@ -130,15 +164,25 @@ jobs:
rust-toolchain: stable
godot-binary: godot.linuxbsd.editor.dev.x86_64

- name: linux-memcheck-gcc
os: ubuntu-20.04
rust-toolchain: stable
godot-binary: godot.linuxbsd.editor.dev.x86_64.san

- name: linux-memcheck-clang
os: ubuntu-20.04
rust-toolchain: stable
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san

steps:
- uses: actions/checkout@v3

- name: "Run Godot integration test"
uses: ./.github/composite/godot
uses: ./.github/composite/godot-itest
with:
artifact-name: godot-${{ matrix.name }}
binary-filename: ${{ matrix.godot-binary }}
#godot_ver: ${{ matrix.godot }}
with-llvm: ${{ matrix.name == 'macos' }}


license-guard:
Expand All @@ -161,8 +205,9 @@ jobs:
if: github.event_name == 'push' && success()
needs:
- rustfmt
- clippy
- unit-test
- itest-godot
- godot-itest
- license-guard
runs-on: ubuntu-20.04
steps:
Expand Down
Loading

0 comments on commit 1bc92aa

Please sign in to comment.