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 all 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
45 changes: 40 additions & 5 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 build 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 build 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 All @@ -69,18 +101,21 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'

- name: Populate environment
run: ./make.sh ci-export-vars

- name: Download Binaries
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/

- name: Unpack binaries
run: tar -xvzf ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} -C ./build/

- name: Build defi image
run: rm .dockerignore && ./make.sh docker-defi-build
run: rm .dockerignore && ./make.sh docker-build-from-binaries

- name: Login to Docker Hub
uses: docker/login-action@v2
Expand Down
14 changes: 6 additions & 8 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 Expand Up @@ -85,18 +80,21 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'

- name: Populate environment
run: ./make.sh ci-export-vars

- name: Download Binaries
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/

- name: Unpack binaries
run: tar -xvzf ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} -C ./build/

- name: Build defi image
run: rm .dockerignore && ./make.sh docker-defi-build
run: rm .dockerignore && ./make.sh docker-build-from-binaries

- name: Login to Docker Hub
uses: docker/login-action@v2
Expand Down
14 changes: 6 additions & 8 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 All @@ -57,15 +52,18 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'

- name: Populate environment
run: ./make.sh ci-export-vars

- name: Download Binaries
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/

- name: Unpack binaries
run: tar -xvzf ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} -C ./build/

- name: Build defi image
run: rm .dockerignore && ./make.sh docker-defi-build
run: rm .dockerignore && ./make.sh docker-build-from-binaries
6 changes: 4 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: ./ci/extended_lint/main.sh

rust:
name: Rust Lints
name: Rust Lint
runs-on: ubuntu-latest
container: defi/ain-builder:latest
env:
Expand All @@ -57,10 +57,12 @@ jobs:
- name: Setup dependencies for user
run: ./make.sh ci-setup-user-deps

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

- 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
23 changes: 19 additions & 4 deletions .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 Expand Up @@ -76,7 +93,6 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'

- id: 'auth'
name: 'Authenticate to Google Cloud'
Expand Down Expand Up @@ -120,15 +136,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'

- name: Download Snapshot
run: aria2c -x16 -s16 https://storage.googleapis.com/team-drop/master-datadir/datadir-${{matrix.blocks.start}}.tar.gz

- name: Create datadir
run: mkdir $DATADIR && tar -C $DATADIR -xvf datadir-${{matrix.blocks.start}}.tar.gz

- name: Download Binaries
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defi-bins
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
5 changes: 2 additions & 3 deletions contrib/dockerfiles/defi.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ ARG TARGET=x86_64-pc-linux-gnu

FROM --platform=linux/amd64 ubuntu:latest as defi
ARG TARGET
ARG PACKAGE
ARG BINARY_DIR
ENV PATH=/app/bin:$PATH
LABEL org.defichain.name="defichain"
LABEL org.defichain.arch=${TARGET}

WORKDIR /app
COPY ${PACKAGE} ./
RUN tar -xvzf ${PACKAGE} --strip-components 1
COPY ${BINARY_DIR} ./

RUN useradd --create-home defi && \
mkdir -p /data && \
Expand Down
Loading
Loading