Skip to content

Commit c5fde3e

Browse files
committed
Merge remote-tracking branch 'origin/master' into paulliu/ckbtc-utxo-cache
2 parents f15eae9 + af2c159 commit c5fde3e

File tree

241 files changed

+8408
-3046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+8408
-3046
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
/licenses/ @dfinity/idx
1212
/bin/ict @dfinity/idx
1313
/bin/ @dfinity/idx
14-
/bin/afl_test.sh @dfinity/product-security
15-
/bin/afl_wrapper.sh @dfinity/product-security
16-
/bin/build-all-fuzzers.sh @dfinity/product-security
17-
/bin/fuzzing_coverage.sh @dfinity/product-security
14+
/bin/fuzzing/ @dfinity/product-security
1815

1916
# [Bazel]
2017
.bazelrc @dfinity/idx

.github/actions/bazel-test-all/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ inputs:
77
release-build:
88
required: false
99
default: true
10+
execlogs-artifact-name:
11+
required: false
12+
description: "When provided, the execlogs will be uploaded as an artifact with the specified name."
1013
BAZEL_COMMAND:
1114
required: true
1215
default: 'test'
@@ -62,7 +65,9 @@ runs:
6265
BRANCH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
6366
with:
6467
GPG_PASSPHRASE: ${{ inputs.GPG_PASSPHRASE }}
68+
execlogs-artifact-name: ${{ inputs.execlogs-artifact-name }}
6569
run: |
70+
set -euo pipefail
6671
6772
diff_only='${{ inputs.diff-only }}'
6873
release_build='${{ inputs.release-build }}'

.github/actions/bazel-upload-checksums/action.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/actions/bazel/action.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
required: true
77
description: |
88
The commands to run. Will be evaluated with bash.
9+
execlogs-artifact-name:
10+
required: false
11+
description: "When provided, the execlogs will be uploaded as an artifact with the specified name."
912
GPG_PASSPHRASE:
1013
required: true
1114
description: "GPG key to encrypt build events. Upload can be disabled by explicitly setting the input to an empty string."
@@ -70,6 +73,55 @@ runs:
7073
${{ steps.metrics-tmpdir.outputs.dir }}/bazel-bep-*.pb.gpg
7174
${{ steps.metrics-tmpdir.outputs.dir }}/profile-*.json
7275
76+
77+
# Remove unnecessary entries from the JSON execlogs and create a CSV out of them
78+
- name: Clean up execlogs
79+
shell: bash
80+
if: (success() || failure()) && inputs.execlogs-artifact-name != ''
81+
run: |
82+
execlogs_json_in='${{ steps.metrics-tmpdir.outputs.dir }}/execlogs.json'
83+
find '${{ steps.metrics-tmpdir.outputs.dir }}' -name 'execlog-*.json' \
84+
-exec cat {} \; > "$execlogs_json_in"
85+
86+
execlogs_csv_out='${{ steps.metrics-tmpdir.outputs.dir }}/execlogs.csv'
87+
if ! [ -s "$execlogs_json_in" ]; then
88+
echo "no execlogs found"
89+
exit 0
90+
fi
91+
92+
# this filters out some entries from the input JSON execlogs. Without this,
93+
# jq takes 3+ minutes to parse the execlogs.
94+
# Effectively removes a full line of "commandArgs", and takes care of skipping
95+
# multiple lines for some multiline array values we don't care about
96+
prog='
97+
BEGIN { arr = 0; }
98+
arr == 1 && / }],?/ { arr = 0; next }
99+
arr == 1 { next }
100+
/ "commandArgs":.*/ { next }
101+
/ "environmentVariables": \[\{/ { arr = 1; next; }
102+
/ "inputs": \[\{/ { arr = 1; next; }
103+
{ print }
104+
'
105+
106+
# Turns the JSON execlogs into a CSV with the following columns:
107+
# <label>,<output path>,<hash>
108+
# only the target labels matching "whitelist_pat" are considered
109+
whitelist_pat='^//'
110+
time (cat "$execlogs_json_in" \
111+
| awk "$prog" \
112+
| jq -cMr --arg whitelist_pat "$whitelist_pat" \
113+
'select(.targetLabel | test($whitelist_pat)) | .targetLabel as $targetLabel | .actualOutputs | map(. | $targetLabel+","+.path+","+.digest.hash) | .[]' \
114+
>"$execlogs_csv_out")
115+
116+
- name: Upload execution log
117+
if: (success() || failure()) && inputs.execlogs-artifact-name != ''
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: ${{ inputs.execlogs-artifact-name }}
121+
if-no-files-found: ignore
122+
path: |
123+
${{ steps.metrics-tmpdir.outputs.dir }}/execlogs.csv
124+
73125
- name: Cleanup
74126
shell: bash
75127
if: always()

.github/actions/bazel/bin/bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ fi
5858
if [[ $bazel_command == "build" ]] || [[ $bazel_command == "test" ]]; then
5959
command_timestamp=$(date +%s)
6060
bazel_args+=(
61+
62+
# write execlogs, mostly for build reproducibility checks
63+
--execution_log_json_file="$BAZEL_ACTION_METRICS_OUT/execlog-$command_timestamp.json"
64+
6165
--verbose_failures=true
6266

6367
# enables BES upload (see config)

.github/workflows-source/ci-main.yml

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,14 @@ jobs:
193193
id: bazel-test-all
194194
uses: ./.github/actions/bazel-test-all/
195195
with:
196+
execlogs-artifact-name: execlogs-bazel-test-all
196197
diff-only: ${{ needs.config.outputs.diff_only }}
197198
release-build: ${{ needs.config.outputs.release_build }}
198199
BAZEL_COMMAND: test --config=ci ${{ steps.bazel-extra-args.outputs.BAZEL_EXTRA_ARGS }}
199200
BAZEL_TARGETS: //...
200201
CLOUD_CREDENTIALS_CONTENT: ${{ secrets.CLOUD_CREDENTIALS_CONTENT }}
201202
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
202203

203-
- name: Upload SHA256SUMS (cache)
204-
uses: ./.github/actions/bazel-upload-checksums/
205-
with:
206-
artifact-name: shasums-cache
207-
208204
bazel-test-macos-intel:
209205
name: Bazel Test macOS Intel
210206
timeout-minutes: 130
@@ -300,43 +296,38 @@ jobs:
300296
- <<: *checkout
301297
- name: Run Build IC
302298
id: build-ic
303-
run: ./ci/scripts/run-build-ic.sh
299+
uses: ./.github/actions/bazel
300+
with:
301+
execlogs-artifact-name: execlogs-build-ic
302+
run: ./ci/scripts/run-build-ic.sh
304303
env:
305-
BAZEL_COMMAND: build --config=ci
306-
BAZEL_TARGETS: //...
307304
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
308305
BRANCH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
309306
RUN_ON_DIFF_ONLY: ${{ needs.config.outputs.diff_only }}
310307
RELEASE_BUILD: ${{ needs.config.outputs.release_build }}
311-
- name: Upload SHA256SUMS (nocache)
312-
uses: ./.github/actions/bazel-upload-checksums/
313-
with:
314-
artifact-name: shasums-nocache
315308

316309
build-determinism:
317310
name: Build Determinism
318311
runs-on: ubuntu-latest
319-
timeout-minutes: 30
320-
# NOTE: this expects "build-ic" to have built the same set of targets
321-
# as "bazel-test-all"
322312
needs: [build-ic, bazel-test-all]
323313
steps:
324-
- <<: *checkout
325-
- name: Download SHA256SUMS (cache)
314+
- name: Download execution logs (cache)
326315
uses: actions/download-artifact@v4
327316
with:
328-
name: shasums-cache
329-
path: shasums-cache
330-
- name: Download SHA256SUMS (nocache)
317+
name: execlogs-bazel-test-all
318+
path: execlogs-cache
319+
- name: Download execution logs (nocache)
331320
uses: actions/download-artifact@v4
332321
with:
333-
name: shasums-nocache
334-
path: shasums-nocache
322+
name: execlogs-build-ic
323+
path: execlogs-nocache
335324

336325
- name: Build Determinism Test
337326
run: |
338-
n_lines_cache=$(cat shasums-cache/SHA256SUMS | wc -l)
339-
n_lines_nocache=$(cat shasums-nocache/SHA256SUMS | wc -l)
327+
set -euo pipefail
328+
329+
n_lines_cache=$(cat execlogs-cache/execlogs.csv | wc -l)
330+
n_lines_nocache=$(cat execlogs-nocache/execlogs.csv | wc -l)
340331
echo "comparing $n_lines_cache (cache) and $n_lines_nocache (nocache) lines"
341332
342333
# running tests may not pull all targets locally. If that's the case,
@@ -346,17 +337,28 @@ jobs:
346337
exit 0
347338
fi
348339
349-
# this checks that all lines in the first argument (subset) are identical
350-
# in the second argument (set)
351-
difference=$(comm -23 <(sort shasums-nocache/SHA256SUMS | uniq) <(sort shasums-cache/SHA256SUMS | uniq))
352-
if [ -n "$difference" ]; then
353-
echo "Build Determinism Check Failed! Please contact IDX."
354-
echo "The following artifacts were different:"
355-
echo "$difference"
356-
exit 1
357-
fi
340+
# sort the files by the field we join on (artifact path), see below
341+
sponge=$(mktemp)
342+
343+
sort -t, -k2 <execlogs-cache/execlogs.csv >"$sponge"
344+
cp "$sponge" execlogs-cache/execlogs.csv
345+
346+
sort -t, -k2 <execlogs-nocache/execlogs.csv >"$sponge"
347+
cp "$sponge" execlogs-nocache/execlogs.csv
348+
349+
rm "$sponge"
358350
359-
echo "Build Determinism Check Successful"
351+
# join the CSVs (separator ',') and compare the hashes. This creates a table with the following columns:
352+
# //rs/foo,bazel-out/path/to-artifact,deadbeef,deafb33f
353+
# target label (1.1), artifact path (1.2), and hashes (1.3 & 2.3). The join is done
354+
# on the artifact path, second field on input one (-1) and input two (-2) :'-12 -22'
355+
# The output is then compared with awk, printing mismatches, and keeping track of how many mismatches we
356+
# encountered.
357+
join \
358+
-t, -o 1.1,1.2,1.3,2.3 -12 -22 \
359+
execlogs-cache/execlogs.csv \
360+
execlogs-nocache/execlogs.csv \
361+
| awk -F, 'BEGIN { N_BAD=0; } $3 != $4 { print $1 " " $2 ": " $3 " != " $4; N_BAD++; } END { if (N_BAD) { print N_BAD " mismatches found"; exit 1; } else { print "No mismatches"; }; }'
360362
361363
cargo-clippy-linux:
362364
name: Cargo Clippy Linux

.github/workflows-source/ci-pr-only.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ jobs:
5454
filters: |
5555
fuzzers:
5656
- '.github/workflows/ci-pr-only.yml'
57-
- 'bin/build-all-fuzzers.sh'
57+
- 'bin/fuzzing/build-all-fuzzers.sh'
5858
- 'bazel/fuzz_testing.bzl'
5959
- name: Run Bazel Build Fuzzers Archives
6060
id: bazel-build-fuzzers-archives
6161
if: steps.filter.outputs.fuzzers == 'true'
6262
shell: bash
6363
run: |
6464
set -euo pipefail
65-
cd "${GITHUB_WORKSPACE}"/bin
65+
cd "${GITHUB_WORKSPACE}"/bin/fuzzing/
6666
./build-all-fuzzers.sh --zip
6767
6868
lock-generate:
@@ -95,7 +95,8 @@ jobs:
9595
- name: Checkout
9696
uses: actions/checkout@v4
9797
with:
98-
ref: ${{ github.head_ref }}
98+
repository: ${{ github.event.pull_request.head.repo.full_name }}
99+
ref: ${{ github.event.pull_request.head.ref }}
99100
token: ${{ steps.app-token.outputs.token }}
100101
- name: Run Lock Generate
101102
id: lock-generate

.github/workflows-source/schedule-hourly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ jobs:
7373
- <<: *checkout
7474
- name: Run Libfuzzer targets
7575
shell: bash
76-
run: ./bin/run-all-fuzzers.sh --libfuzzer 100
76+
run: ./bin/fuzzing/run-all-fuzzers.sh --libfuzzer 100
7777
- name: Run AFL targets
7878
shell: bash
79-
run: ./bin/run-all-fuzzers.sh --afl 100
79+
run: ./bin/fuzzing/run-all-fuzzers.sh --afl 100
8080
- name: Post Slack Notification
8181
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
8282
if: failure()

0 commit comments

Comments
 (0)