From 1ca096e7ce71940c6201d55215b7e9eb430522b7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 24 Feb 2020 16:51:53 +0300 Subject: [PATCH] Added auto caching for Github CI. --- .github/workflows/linux.yml | 6 ++++++ .github/workflows/mac.yml | 6 ++++++ .github/workflows/win.yml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 23d21c244..a083df13a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -33,6 +33,7 @@ jobs: ONLY_CACHE: "false" MANUAL_CACHING: "6" DOC_PATH: "docs/building-cmake.md" + AUTO_CACHING: "1" steps: - name: Get repository name. @@ -56,6 +57,7 @@ jobs: p doc - name: First set up. + shell: bash run: | cd .. mv $REPO_NAME temp @@ -87,6 +89,10 @@ jobs: gcc --version > CACHE_KEY.txt echo $MANUAL_CACHING >> CACHE_KEY.txt + if [ "$AUTO_CACHING" == "1" ]; then + thisFile=$REPO_NAME/.github/workflows/linux.yml + echo `md5sum $thisFile | cut -c -32` >> CACHE_KEY.txt + fi md5cache=$(md5sum CACHE_KEY.txt | cut -c -32) echo ::set-env name=CACHE_KEY::$md5cache diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 9aa29942c..9e29fb255 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -35,6 +35,8 @@ jobs: ONLY_CACHE: "false" MANUAL_CACHING: "2" DOC_PATH: "docs/building-xcode.md" + AUTO_CACHING: "1" + steps: - name: Get repository name. run: echo ::set-env name=REPO_NAME::${GITHUB_REPOSITORY##*/} @@ -61,6 +63,10 @@ jobs: echo $MIN_MAC >> CACHE_KEY.txt echo $PREFIX >> CACHE_KEY.txt echo $MANUAL_CACHING >> CACHE_KEY.txt + if [ "$AUTO_CACHING" == "1" ]; then + thisFile=$REPO_NAME/.github/workflows/mac.yml + echo `md5 -q $thisFile` >> CACHE_KEY.txt + fi echo ::set-env name=CACHE_KEY::`md5 -q CACHE_KEY.txt` echo ::add-path::$PWD/Libraries/depot_tools diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 815b9b68c..6118a4c86 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -30,6 +30,8 @@ jobs: ONLY_CACHE: "false" MANUAL_CACHING: "2" DOC_PATH: "docs/building-msvc.md" + AUTO_CACHING: "1" + steps: - name: Get repository name. shell: bash @@ -69,6 +71,10 @@ jobs: - name: Generate cache key. shell: bash run: | + if [ "$AUTO_CACHING" == "1" ]; then + thisFile=$REPO_NAME/.github/workflows/win.yml + echo `md5sum $thisFile | awk '{ print $1 }'` >> CACHE_KEY.txt + fi echo ::set-env name=CACHE_KEY::`md5sum CACHE_KEY.txt | awk '{ print $1 }'` - name: Choco installs.