Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add cpp caching and rust cache fixes in CI build workflows #2721

Merged
merged 44 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e49782c
Add ccache into ci build-dev workflow, add caching
sieniven Nov 26, 2023
0884778
Fix build failure
sieniven Nov 26, 2023
adde748
Disable save if rust cache condition
sieniven Nov 26, 2023
53f6bd8
Add build type
sieniven Nov 26, 2023
c03998c
Revert rust cache
sieniven Nov 26, 2023
b308b57
Remove rust caching from release and staging
sieniven Nov 26, 2023
992b4f1
Add shared key to rust cache
sieniven Nov 26, 2023
fc36f53
Fix ccache and rust cache key
sieniven Nov 26, 2023
c673a20
Switch debugging log
sieniven Nov 26, 2023
4a0b02c
Explicitly set ccache_dir
sieniven Nov 26, 2023
6b6ee7c
Disable delete cpp cache on master
sieniven Nov 26, 2023
c8e4f6c
Fix make.sh
sieniven Nov 26, 2023
e943993
Fix ccache dir
sieniven Nov 26, 2023
0786d24
Fix ccache dir
sieniven Nov 26, 2023
76abfdb
Disable save if on rust cache
sieniven Nov 26, 2023
f9b445b
Add gh deps
sieniven Nov 26, 2023
29a9762
Fix base deps
sieniven Nov 26, 2023
d9741b8
Use cpp caching to all workflows
sieniven Nov 27, 2023
cfcf99b
Install gh deps on ci setup deps
sieniven Nov 27, 2023
ab6cb01
Make.sh fixes
sieniven Nov 27, 2023
c1b5776
Enable save only on master in build dev
sieniven Nov 27, 2023
199d9d0
Better rename
sieniven Nov 27, 2023
37d4859
Fix if condition
sieniven Nov 27, 2023
b7be296
Enable cpp save
sieniven Nov 27, 2023
d4aa675
Enable save cache condition check
sieniven Nov 27, 2023
d004ae7
Merge branch 'master' of github.com:DeFiCh/ain into niven/ci-add-cache
sieniven Nov 29, 2023
809e99b
Switch to set-safe-directory setting
sieniven Nov 29, 2023
ffebf7e
Revert from set safe directory
sieniven Nov 29, 2023
f1b9760
Unpack package and port into docker image instead
sieniven Nov 29, 2023
6b67dd8
Add debugging log
sieniven Nov 29, 2023
b674f08
Fix tar command
sieniven Nov 29, 2023
a45beda
Resave cache
sieniven Nov 29, 2023
16c9202
Save only on master
sieniven Nov 29, 2023
40f679f
Pass binary dir relative to docker root context
sieniven Nov 29, 2023
95b39b3
Save rust cache separately for lint
sieniven Nov 29, 2023
2e6cb88
Better shared key naming
sieniven Nov 29, 2023
389a1f4
Save cache
sieniven Nov 29, 2023
183f529
Re-enable save only on master for rust lint
sieniven Nov 29, 2023
7529d36
Better rename
sieniven Nov 29, 2023
889869c
Re-enable save only on master
sieniven Nov 29, 2023
0459cb1
Rename
sieniven Nov 29, 2023
36aca41
Rename to docker build from binaries
sieniven Nov 30, 2023
c6b1445
Better rename
sieniven Nov 30, 2023
bdc4ae3
Merge branch 'master' into niven/ci-add-cache
sieniven Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.code
.cache
.ccache
.idea

# Editors.
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,27 @@ jobs:

- name: Setup dependencies
run: ./make.sh ci-setup-deps

- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build and package
run: ./make.sh release
Expand All @@ -61,6 +74,25 @@ jobs:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}

- name: Delete previous cpp cache
if: ${{ github.ref == 'refs/heads/master' && steps.cpp-cache-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Save cpp cache
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/cache/save@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

docker-build:
runs-on: ubuntu-latest
needs: [build]
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}

- name: Build and package
run: ./make.sh release

Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/build-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}

- name: Build and package
run: ./make.sh release

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ jobs:
- name: Setup dependencies for user
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Rust build cache
uses: Swatinem/rust-cache@v2
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build depends and configure
run: ./make.sh build-deps && ./make.sh build-conf
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/tests-ethlibs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,23 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build binaries
run: ./make.sh build
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/tests-frontier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
TARGET: x86_64-pc-linux-gnu
MAKE_DEBUG: 0

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -30,10 +34,23 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build binaries
run: ./make.sh build
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/tests-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ concurrency:

run-name: ${{ inputs.name || github.event.pull_request.title || github.ref_name }}

env:
TARGET: x86_64-pc-linux-gnu
MAKE_DEBUG: 0

jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'ci/sync') || github.event_name == 'workflow_dispatch'
Expand All @@ -40,10 +44,23 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build binaries
run: ./make.sh build
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
TARGET: x86_64-pc-linux-gnu
MAKE_DEBUG: 0

jobs:
e2e-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -45,10 +49,23 @@ jobs:
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}

- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build binaries
run: ./make.sh build
Expand Down Expand Up @@ -76,10 +93,13 @@ jobs:
- name: Setup dependencies for user
run: ./make.sh ci-setup-user-deps

- uses: Swatinem/rust-cache@v2
- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}

- name: Build deps and configure
run: ./make.sh build-deps && ./make.sh build-conf
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.code
.cache
.ccache
.idea

# Editors.
Expand Down
26 changes: 25 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ pkg_install_deps() {
software-properties-common build-essential git libtool autotools-dev automake \
pkg-config bsdmainutils python3 python3-pip python3-venv libssl-dev libevent-dev libboost-system-dev \
libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \
libminiupnpc-dev libzmq3-dev libqrencode-dev wget \
libminiupnpc-dev libzmq3-dev libqrencode-dev wget ccache \
libdb-dev libdb++-dev libdb5.3 libdb5.3-dev libdb5.3++ libdb5.3++-dev \
curl cmake zip unzip libc6-dev gcc-multilib locales locales-all

Expand Down Expand Up @@ -743,6 +743,20 @@ pkg_install_deps_osx_tools() {
_fold_end
}

pkg_install_gh_cli() {
_fold_start "pkg-install-gh_cli"
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \
dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] \
https://cli.github.com/packages stable main" | \
tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt-get update
apt-get install -y gh

}

pkg_install_llvm() {
_fold_start "pkg-install-llvm"
# shellcheck disable=SC2086
Expand Down Expand Up @@ -1140,11 +1154,20 @@ _nproc() {

# shellcheck disable=SC2129
ci_export_vars() {
local build_dir="${BUILD_DIR}"

if [[ -n "${GITHUB_ACTIONS-}" ]]; then
# GitHub Actions
echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV"
echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"

if [[ "${MAKE_DEBUG}" == "1" ]]; then
echo "BUILD_TYPE=debug" >> "$GITHUB_ENV"
else
echo "BUILD_TYPE=release" >> "$GITHUB_ENV"
fi

if [[ "${TARGET}" == "x86_64-w64-mingw32" ]]; then
echo "PKG_TYPE=zip" >> "$GITHUB_ENV"
else
Expand All @@ -1158,6 +1181,7 @@ ci_setup_deps() {
DEBIAN_FRONTEND=noninteractive pkg_install_deps
DEBIAN_FRONTEND=noninteractive pkg_setup_locale
DEBIAN_FRONTEND=noninteractive pkg_install_llvm
DEBIAN_FRONTEND=noninteractive pkg_install_gh_cli
ci_setup_deps_target
}

Expand Down