forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (156 loc) · 5.74 KB
/
build-src.yml
File metadata and controls
171 lines (156 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Build source
on:
workflow_call:
inputs:
build-target:
description: "Target name as defined by inputs.sh"
required: true
type: string
container-path:
description: "Path to built container at registry"
required: true
type: string
depends-key:
description: "Key needed to access cached depends"
required: true
type: string
depends-host:
description: "Host triplet from depends build"
required: true
type: string
depends-dep-opts:
description: "DEP_OPTS used to build depends"
required: false
type: string
default: ""
outputs:
key:
description: "Key needed for restoring artifacts bundle"
value: ${{ jobs.build-src.outputs.key }}
jobs:
build-src:
name: Build source
runs-on: ubuntu-24.04
outputs:
key: ${{ steps.bundle.outputs.key }}
container:
image: ${{ inputs.container-path }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 50
- name: Initial setup
id: setup
run: |
git config --global --add safe.directory "$PWD"
git fetch -fu origin develop:develop
BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
echo "HOST=${HOST}" >> $GITHUB_OUTPUT
echo "PR_BASE_SHA=${{ github.event.pull_request.base.sha || '' }}" >> $GITHUB_OUTPUT
shell: bash
- name: Restore SDKs cache
uses: actions/cache/restore@v4
if: inputs.build-target == 'mac'
with:
path: |
depends/SDKs
key: depends-sdks-${{ hashFiles('depends/hosts/darwin.mk') }}
fail-on-cache-miss: true
- name: Restore depends cache
uses: actions/cache/restore@v4
with:
path: depends/built/${{ inputs.depends-host }}
key: ${{ inputs.depends-key }}
fail-on-cache-miss: true
- name: Rebuild depends prefix
run: |
# Use the HOST and DEP_OPTS from the depends build, not this build-target
# This ensures the build_id matches the cached packages
make -j$(nproc) -C depends HOST="${{ inputs.depends-host }}" ${{ inputs.depends-dep-opts }}
shell: bash
- name: Restore ccache cache
uses: actions/cache/restore@v4
with:
path: |
/cache/ccache
key: ccache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
restore-keys: |
ccache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-
- name: Build source
run: |
CCACHE_MAXSIZE="400M"
CACHE_DIR="/cache"
mkdir /output
BASE_OUTDIR="/output"
BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
./ci/dash/build_src.sh
ccache -X 9
ccache -c
du -hd0 "${BASE_OUTDIR}"
rm -rf "${BASE_OUTDIR}"
shell: bash
- name: Save ccache cache
if: |
github.event_name == 'push' &&
github.ref_name == github.event.repository.default_branch
uses: actions/cache/save@v4
with:
path: |
/cache/ccache
key: ccache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
- name: Restore ctcache cache
if: inputs.build-target == 'linux64_multiprocess'
uses: actions/cache/restore@v4
with:
path: |
/cache/ctcache
key: ctcache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
restore-keys: |
ctcache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-
- name: Run linters
if: inputs.build-target == 'linux64_multiprocess'
run: |
CACHE_DIR="/cache"
export BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
./ci/dash/lint-tidy.sh
shell: bash
- name: Save ctcache cache
if: |
inputs.build-target == 'linux64_multiprocess' &&
github.event_name == 'push' &&
github.ref_name == github.event.repository.default_branch
uses: actions/cache/save@v4
with:
path: |
/cache/ctcache
key: ctcache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
- name: Run unit tests
run: |
BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
./ci/dash/test_unittests.sh
shell: bash
- name: Bundle artifacts
id: bundle
run: |
export BUILD_TARGET="${{ inputs.build-target }}"
export BUNDLE_KEY="build-${BUILD_TARGET}-$(git rev-parse --short=8 HEAD)"
find "build-ci/dashcore-${BUILD_TARGET}/src/" -name "*.a" -type f -delete
find "build-ci/dashcore-${BUILD_TARGET}/src/" -name "*.o" -type f -delete
./ci/dash/bundle-artifacts.sh create
echo "key=${BUNDLE_KEY}" >> "${GITHUB_OUTPUT}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.bundle.outputs.key }}
path: |
${{ steps.bundle.outputs.key }}.tar.zst
compression-level: 0
overwrite: true
retention-days: 3