Skip to content

Commit

Permalink
Github workflow build cache (#4150)
Browse files Browse the repository at this point in the history
Cache intermediary build artefacts to speed up build time.
  • Loading branch information
pwojcikdev committed Apr 11, 2023
1 parent f65e58a commit 4f4ccf7
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .github/actions/restore-git-mtimes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "restore-git-mtimes"
description: "Restore file modification timestamps from git commit timestamps"
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
repository: "MestreLion/git-tools"
ref: a42a069bc755f0fa81316965335cb33dbf22a968 # pin latest commit
path: "git-tools"
- run: $GITHUB_WORKSPACE/git-tools/git-restore-mtime
shell: bash
- run: git submodule foreach --recursive '$GITHUB_WORKSPACE/git-tools/git-restore-mtime'
shell: bash
63 changes: 63 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,34 @@ jobs:
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0 # full history needed for restoring file timestamps

- name: Restore Timestamps
uses: ./.github/actions/restore-git-mtimes
continue-on-error: true

- name: Restore Build Cache
uses: actions/cache/restore@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-build-cache

- name: Fetch Deps
run: TEST=1 ci/actions/osx/install_deps.sh

- name: Build Tests
run: ci/build-ci.sh "/tmp/qt/lib/cmake/Qt5";

- name: Save Build Cache
# only save build cache from develop to avoid polluting it by other branches / PRs
if: github.ref == 'refs/heads/develop' && success()
uses: actions/cache/save@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-build-cache

- name: Run Tests
run: cd build && sudo TEST_USE_ROCKSDB=$TEST_USE_ROCKSDB ../ci/test.sh .
env:
Expand Down Expand Up @@ -60,13 +81,34 @@ jobs:
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0 # full history needed for restoring file timestamps

- name: Restore Timestamps
uses: ./.github/actions/restore-git-mtimes
continue-on-error: true

- name: Restore Build Cache
uses: actions/cache/restore@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache

- name: Fetch Deps
run: ci/actions/linux/install_deps.sh

- name: Build Tests
run: docker run -e TEST_USE_ROCKSDB -e RELEASE -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cd /workspace && ./ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5"

- name: Save Build Cache
# only save build cache from develop to avoid polluting it by other branches / PRs
if: github.ref == 'refs/heads/develop' && success()
uses: actions/cache/save@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache

- name: Run Tests
run: docker run -e RELEASE -e TEST_USE_ROCKSDB -e DEADLINE_SCALE_FACTOR -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cd /workspace/build && ../ci/test.sh ."
env:
Expand All @@ -92,6 +134,18 @@ jobs:
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0 # full history needed for restoring file timestamps

- name: Restore Timestamps
uses: ./.github/actions/restore-git-mtimes
continue-on-error: true

- name: Restore Build Cache
uses: actions/cache/restore@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-build-cache

- name: Windows Defender
run: ci/actions/windows/disable_windows_defender.ps1
Expand All @@ -102,6 +156,15 @@ jobs:
- name: Build Tests
run: ci/actions/windows/build.ps1

- name: Save Build Cache
# only save build cache from develop to avoid polluting it by other branches / PRs
if: github.ref == 'refs/heads/develop' && success()
uses: actions/cache/save@v3
continue-on-error: true
with:
path: build
key: ${{ runner.os }}-build-cache

- name: Run Tests [TEST_USE_ROCKSDB=${{ env.TEST_USE_ROCKSDB }}]
run: ci/actions/windows/run.ps1
env:
Expand Down
6 changes: 1 addition & 5 deletions ci/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
qt_dir=${1}
build_target=${2:-all}

set -o errexit
set -o nounset
set -o xtrace
OS=$(uname)

source "$(dirname "$BASH_SOURCE")/impl/code-inspector.sh"
code_inspect "${ROOTPATH:-.}"

mkdir build
mkdir -p build
pushd build

if [[ "${RELEASE:-false}" == "true" ]]; then
Expand Down Expand Up @@ -49,7 +46,6 @@ cmake \
-DPORTABLE=1 \
-DNANO_WARN_TO_ERR=ON \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DQt5_DIR=${qt_dir} \
-DCI_TEST="1" \
${BACKTRACE:-} \
Expand Down

0 comments on commit 4f4ccf7

Please sign in to comment.