Extract submodule cache steps to compound action

Creates a reusable action for caching submodules in the thirdparty
directory.
This commit is contained in:
Leroy Hopson 2022-06-01 09:54:06 +07:00
parent 1d51acb38d
commit 5108c7cabd
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 43 additions and 31 deletions

View file

@ -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 }}-

View file

@ -15,8 +15,6 @@ env:
EMSCRIPTEN_CACHE_VERSION: 1 EMSCRIPTEN_CACHE_VERSION: 1
EXPORT_TEMPLATE_CACHE_VERSION: 1 EXPORT_TEMPLATE_CACHE_VERSION: 1
GODOT_CACHE_VERSION: 1 GODOT_CACHE_VERSION: 1
GODOT_CPP_CACHE_VERSION: 1
LIBUV_CACHE_VERSION: 1
jobs: jobs:
build: build:
@ -46,33 +44,13 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
submodules: recursive submodules: recursive
- name: Cache submodules
- name: Get godot-cpp submodule commit hash uses: ./.github/actions/cache-submodules
shell: bash id: cache-submodules
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
with: with:
path: addons/godot_xterm/native/thirdparty/godot-cpp platform: ${{ matrix.platform }}
key: godot-cpp-${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.bits }}-${{ env.GODOT_CPP_COMMIT_HASH }}-v${{ env.GODOT_CPP_CACHE_VERSION }} target: ${{ matrix.target }}
- name: Get libuv submodule commit hash bits: ${{ matrix.bits }}
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 }}
- name: Cache emscripten - name: Cache emscripten
if: ${{ matrix.platform == 'javascript' }} if: ${{ matrix.platform == 'javascript' }}
uses: actions/cache@v2 uses: actions/cache@v2
@ -110,19 +88,19 @@ jobs:
arch: win${{ matrix.bits }} arch: win${{ matrix.bits }}
- name: Build godot-cpp bindings - name: Build godot-cpp bindings
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache-submodules.outputs.cache-hit != 'true'
run: | run: |
cd addons/godot_xterm/native/thirdparty/godot-cpp cd addons/godot_xterm/native/thirdparty/godot-cpp
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2 scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2
- name: Setup cmake - 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 uses: jwlawson/actions-setup-cmake@v1.9
with: with:
cmake-version: '3.15.4' cmake-version: '3.15.4'
use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }} use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }}
- name: Build libuv - name: Build libuv
if: steps.cache-libuv.outputs.cache-hit != 'true' if: steps.cache-submodules.outputs.cache-hit != 'true'
shell: bash shell: bash
env: env:
TARGET: ${{ matrix.target }} TARGET: ${{ matrix.target }}