diff --git a/.github/actions/cache-submodules/action.yaml b/.github/actions/cache-submodules/action.yaml new file mode 100644 index 0000000..2eb3170 --- /dev/null +++ b/.github/actions/cache-submodules/action.yaml @@ -0,0 +1,34 @@ +name: Cache dependencies +inputs: + platform: + required: true + target: + required: true + bits: + required: true +outputs: + cache-hit: + value: ${{ steps.cache.outputs.cache-hit }} +runs: + using: "composite" + steps: + - name: Hash submodule revisions + id: hash + working-directory: addons/godot_xterm/native/thirdparty + shell: bash + run: | + godot_cpp_rev=$(git ls-tree HEAD godot-cpp --object-only) + libuv_rev=$(git ls-tree HEAD libuv --object-only) + libtsm_rev=$(git ls-tree HEAD libtsm --object-only) + hash_cmd=$([[ $RUNNER_OS == 'Windows' ]] && echo 'sha1sum' || echo 'shasum') + hash_of_hashes=$(echo -n "$godot_cpp_rev$libuv_rev$libtsm_rev" | $hash_cmd | head -c 40) + echo "::set-output name=hash::$hash_of_hashes" + - name: Cache submodules + uses: actions/cache@v3 + id: cache + with: + path: addons/godot_xterm/native/thirdparty + key: thirdparty-${{ inputs.platform }}-${{ inputs.bits }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }} + restore-keys: | + thirdparty-${{ inputs.platform }}-${{ inputs.bits }}-${{ inputs.target }}- + thirdparty-${{ inputs.platform }}-${{ inputs.bits }}- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b4fc855..5bb3871 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,8 +15,6 @@ env: EMSCRIPTEN_CACHE_VERSION: 1 EXPORT_TEMPLATE_CACHE_VERSION: 1 GODOT_CACHE_VERSION: 1 - GODOT_CPP_CACHE_VERSION: 1 - LIBUV_CACHE_VERSION: 1 jobs: build: @@ -46,33 +44,13 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive - - - name: Get godot-cpp submodule commit hash - shell: bash - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - echo ::set-env name=GODOT_CPP_COMMIT_HASH::$(git ls-tree HEAD addons/godot_xterm/native/thirdparty/godot-cpp -l | cut -d\ -f3) - - name: Cache godot-cpp bindings - uses: actions/cache@v2 - id: cache - env: - cache-name: cache-godot-cpp + - name: Cache submodules + uses: ./.github/actions/cache-submodules + id: cache-submodules with: - path: addons/godot_xterm/native/thirdparty/godot-cpp - key: godot-cpp-${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.bits }}-${{ env.GODOT_CPP_COMMIT_HASH }}-v${{ env.GODOT_CPP_CACHE_VERSION }} - - name: Get libuv submodule commit hash - shell: bash - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - echo ::set-env name=LIBUV_COMMIT_HASH::$(git ls-tree HEAD addons/godot_xterm/native/thirdparty/libuv -l | cut -d\ -f3) - - name: Cache libuv - uses: actions/cache@v2 - id: cache-libuv - with: - path: addons/godot_xterm/native/thirdparty/libuv - key: libuv-cache-${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.bits }}-${{ env.LIBUV_COMMIT_HASH }}-v${{ env.LIBUV_CACHE_VERSION }} + platform: ${{ matrix.platform }} + target: ${{ matrix.target }} + bits: ${{ matrix.bits }} - name: Cache emscripten if: ${{ matrix.platform == 'javascript' }} uses: actions/cache@v2 @@ -110,19 +88,19 @@ jobs: arch: win${{ matrix.bits }} - name: Build godot-cpp bindings - if: steps.cache.outputs.cache-hit != 'true' + if: steps.cache-submodules.outputs.cache-hit != 'true' run: | cd addons/godot_xterm/native/thirdparty/godot-cpp scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2 - name: Setup cmake - if: steps.cache-libuv.outputs.cache-hit != 'true' + if: steps.cache-submodules.outputs.cache-hit != 'true' uses: jwlawson/actions-setup-cmake@v1.9 with: cmake-version: '3.15.4' use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }} - name: Build libuv - if: steps.cache-libuv.outputs.cache-hit != 'true' + if: steps.cache-submodules.outputs.cache-hit != 'true' shell: bash env: TARGET: ${{ matrix.target }}