Skip to content

Commit e1020f8

Browse files
committed
Verify BLAKE3 bundled files using CI
1 parent 0aa5c88 commit e1020f8

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/ext/hash/blake3/upstream_blake3/c/blake3.h b/ext/hash/blake3/upstream_blake3/c/blake3.h
2+
index 35f2bb9..59f68a7 100644
3+
--- a/ext/hash/blake3/upstream_blake3/c/blake3.h
4+
+++ b/ext/hash/blake3/upstream_blake3/c/blake3.h
5+
@@ -44,6 +44,7 @@ typedef struct {
6+
uint64_t chunk_counter;
7+
uint8_t buf[BLAKE3_BLOCK_LEN];
8+
uint8_t buf_len;
9+
+ uint8_t padding_1[5];
10+
uint8_t blocks_compressed;
11+
uint8_t flags;
12+
} blake3_chunk_state;
13+
@@ -58,6 +59,7 @@ typedef struct {
14+
// don't know whether more input is coming. This is different from how the
15+
// reference implementation does things.
16+
uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN];
17+
+ uint8_t padding_2[7];
18+
} blake3_hasher;
19+
20+
BLAKE3_API const char *blake3_version(void);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
set -ex
3+
cd "$(dirname "$0")/../../.."
4+
5+
tmp_dir=/tmp/php-src-download-bundled/blake3
6+
rm -rf "$tmp_dir"
7+
8+
revision=refs/tags/1.8.3
9+
10+
git clone --depth 1 --revision="$revision" https://github.com/BLAKE3-team/BLAKE3.git "$tmp_dir"
11+
12+
rm -rf ext/hash/blake3/upstream_blake3
13+
mkdir ext/hash/blake3/upstream_blake3
14+
cp -R "$tmp_dir"/c ext/hash/blake3/upstream_blake3
15+
cp "$tmp_dir"/LICENSE_CC0 ext/hash/blake3/upstream_blake3
16+
17+
cd ext/hash/blake3/upstream_blake3
18+
19+
# remove unneeded files
20+
rm -R c/blake3_c_rust_bindings
21+
rm -R c/cmake
22+
rm -R c/dependencies
23+
rm c/.gitignore
24+
rm c/blake3_tbb.cpp
25+
rm c/blake3-config.cmake.in
26+
rm c/CMakeLists.txt
27+
rm c/CMakePresets.json
28+
rm c/example.c
29+
rm c/example_tbb.c
30+
rm c/libblake3.pc.in
31+
rm c/main.c
32+
rm c/Makefile.testing
33+
rm c/README.md
34+
rm c/test.py
35+
36+
# patch customized files
37+
git apply -v ../../../../.github/scripts/download-bundled/blake3.h.patch

.github/workflows/verify-bundled-files.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths: &paths
66
- '.github/scripts/download-bundled/**'
77
- 'Zend/asm/**'
8+
- 'ext/hash/blake3/upstream_blake3/**'
89
- 'ext/pcre/pcre2lib/**'
910
- 'ext/uri/uriparser/**'
1011
pull_request:
@@ -34,6 +35,9 @@ jobs:
3435
'boost-context':
3536
- '.github/scripts/download-bundled/boost-context.*'
3637
- 'Zend/asm/**'
38+
blake3:
39+
- '.github/scripts/download-bundled/blake3.*'
40+
- 'ext/hash/blake3/upstream_blake3/**'
3741
pcre2:
3842
- '.github/scripts/download-bundled/pcre2.*'
3943
- 'ext/pcre/pcre2lib/**'
@@ -50,6 +54,15 @@ jobs:
5054
echo "::group::Verify files"
5155
.github/scripts/test-directory-unchanged.sh Zend/asm
5256
echo "::endgroup::"
57+
- name: BLAKE3
58+
if: ${{ !cancelled() && (steps.changes.outputs.blake3 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
59+
run: |
60+
echo "::group::Download"
61+
.github/scripts/download-bundled/blake3.sh
62+
echo "::endgroup::"
63+
echo "::group::Verify files"
64+
.github/scripts/test-directory-unchanged.sh 'ext/hash/blake3/upstream_blake3'
65+
echo "::endgroup::"
5366
- name: PCRE2
5467
if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
5568
run: |

0 commit comments

Comments
 (0)