Skip to content

Commit a8e20a4

Browse files
committed
Update CI
1 parent e57f11b commit a8e20a4

3 files changed

Lines changed: 59 additions & 143 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: test
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request:
7-
branches: [main]
7+
branches: [ main ]
88

99
permissions:
1010
contents: read
@@ -14,121 +14,19 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
macos:
18-
name: macOS
19-
runs-on: macos-26
20-
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v6
23-
- name: Run tests
24-
run: swift test
25-
26-
darwin:
27-
name: ${{ matrix.name }}
28-
runs-on: macos-26
29-
strategy:
30-
fail-fast: false
31-
matrix:
32-
include:
33-
- name: iOS
34-
destination: platform=iOS Simulator,OS=latest,name=iPhone 16 Pro
35-
- name: tvOS
36-
destination: platform=tvOS Simulator,OS=latest,name=Apple TV 4K (3rd generation)
37-
- name: watchOS
38-
destination: platform=watchOS Simulator,OS=latest,name=Apple Watch Series 10 (46mm)
39-
- name: visionOS
40-
destination: platform=visionOS Simulator,OS=latest,name=Apple Vision Pro
41-
steps:
42-
- name: Checkout code
43-
uses: actions/checkout@v6
44-
- name: Run tests
45-
run: |
46-
xcodebuild test \
47-
-scheme compression \
48-
-destination '${{ matrix.destination }}'
49-
linux:
50-
name: Linux (${{ matrix.name }})
51-
strategy:
52-
fail-fast: false
53-
matrix:
54-
include:
55-
- name: "6.3"
56-
container: "swift:6.3"
57-
test-args: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
58-
- name: "nightly-main"
59-
container: "swiftlang/swift:nightly-main-jammy"
60-
test-args: ""
61-
runs-on: ubuntu-latest
62-
container: ${{ matrix.container }}
63-
steps:
64-
- name: Checkout code
65-
uses: actions/checkout@v6
66-
- name: Run tests
67-
run: swift test ${{ matrix.test-args }}
68-
69-
linux-musl:
70-
runs-on: ubuntu-latest
71-
container: swift:6.3
72-
steps:
73-
- name: Checkout code
74-
uses: actions/checkout@v6
75-
- name: Install Swift SDK for Linux Musl
76-
run: |
77-
version_num="$(swiftc --version | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1)"
78-
tag="swift-${version_num}-RELEASE"
79-
sdk_info="$(curl -s https://www.swift.org/api/v1/install/releases.json | jq -r --arg tag "$tag" '.[] | select(.tag == $tag).platforms[] | select(.platform == "static-sdk") | [.version, .checksum] | @tsv')"
80-
version="$(echo "$sdk_info" | cut -f1)"
81-
checksum="$(echo "$sdk_info" | cut -f2)"
82-
swift sdk install "https://download.swift.org/$(echo $tag | tr [A-Z] [a-z])/static-sdk/$tag/${tag}_static-linux-${version}.artifactbundle.tar.gz" --checksum "$checksum"
83-
- name: Build for Linux Musl
84-
run: swift build --swift-sdk x86_64-swift-linux-musl
85-
86-
wasm:
87-
runs-on: ubuntu-latest
88-
container: swift:6.3
89-
steps:
90-
- name: Checkout code
91-
uses: actions/checkout@v6
92-
- name: Install WebAssembly SDK
93-
run: |
94-
apt-get update -y -q && apt-get install -y -q curl jq
95-
tag="$(swiftc --version | grep -Po '(?<=\().+(?=\))')"
96-
checksum="$(curl -s https://www.swift.org/api/v1/install/releases.json | \
97-
jq -r --arg tag "$tag" '.[] | select(.tag == $tag).platforms[] | select(.platform == "wasm-sdk").checksum // empty')"
98-
swift sdk install https://download.swift.org/$(echo $tag | tr [A-Z] [a-z])/wasm-sdk/$tag/${tag}_wasm.artifactbundle.tar.gz --checksum "$checksum"
99-
- name: Build for WebAssembly
100-
run: swift build --swift-sdk wasm32-unknown-wasi
101-
102-
windows:
103-
strategy:
104-
fail-fast: false
105-
matrix:
106-
swift-version:
107-
- 6.3
108-
runs-on: windows-latest
109-
steps:
110-
- name: Checkout code
111-
uses: actions/checkout@v6
112-
- name: Setup Swift for Windows
113-
uses: compnerd/gha-setup-swift@main
114-
with:
115-
branch: swift-${{ matrix.swift-version }}-release
116-
tag: ${{ matrix.swift-version }}-RELEASE
117-
- name: Build and test
118-
run: swift test
119-
120-
android:
121-
strategy:
122-
fail-fast: false
123-
matrix:
124-
swift-version:
125-
- 6.3
126-
runs-on: ubuntu-latest
127-
steps:
128-
- name: Checkout code
129-
uses: actions/checkout@v6
130-
- name: Setup Swift for Android
131-
uses: skiptools/swift-android-action@v2
132-
with:
133-
swift-version: ${{ matrix.swift-version }}
134-
free-disk-space: true
17+
tests:
18+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.11
19+
with:
20+
linux_swift_versions: "[\"6.3\", \"nightly-main\"]"
21+
linux_build_command: "swift test --explicit-target-dependency-import-check error"
22+
enable_linux_static_sdk_build: true
23+
linux_static_sdk_versions: "[\"6.3\"]"
24+
enable_wasm_sdk_build: true
25+
wasm_sdk_versions: "[\"6.3\"]"
26+
windows_swift_versions: "[\"6.3\"]"
27+
enable_android_sdk_build: true
28+
android_sdk_versions: "[\"6.3\"]"
29+
enable_macos_checks: true
30+
enable_ios_checks: true
31+
enable_freebsd_checks: true
32+
enable_embedded_wasm_sdk_build: true

Benchmarks/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ let package = Package(
1717
],
1818
path: "CompressionBenchmarks",
1919
plugins: [
20-
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
20+
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
2121
]
22-
),
22+
)
2323
]
2424
)

Sources/CZlib/include/CZlib.h

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,53 @@
22
#define CZLIB_H
33

44
#include "zlib.h"
5+
6+
#if __has_include(<lifetimebound.h>)
57
#include <lifetimebound.h>
8+
#endif
9+
#if __has_include(<ptrcheck.h>)
610
#include <ptrcheck.h>
11+
#endif
12+
13+
#if defined(__has_feature) && __has_feature(bounds_attributes)
14+
#define __has_ptrcheck 1
15+
#else
16+
#define __has_ptrcheck 0
17+
#endif
18+
19+
#if defined(__has_feature) && __has_feature(bounds_safety_attributes)
20+
#define __has_bounds_safety_attributes 1
21+
#else
22+
#define __has_bounds_safety_attributes 0
23+
#endif
24+
25+
#if __has_ptrcheck || __has_bounds_safety_attributes
26+
#define __counted_by(N) __attribute__((__counted_by__(N)))
27+
#endif
28+
29+
#if defined(__cplusplus) && defined(__has_cpp_attribute)
30+
#define __use_cpp_spelling(x) __has_cpp_attribute(x)
31+
#else
32+
#define __use_cpp_spelling(x) 0
33+
#endif
34+
35+
#if __use_cpp_spelling(clang::noescape)
36+
#define __noescape [[clang::noescape]]
37+
#else
38+
#define __noescape __attribute__((noescape))
39+
#endif
740

841
#if defined(_WIN32)
9-
typedef unsigned char uint8_t;
42+
#define snprintf _snprintf
43+
#endif
44+
45+
#include <stdint.h>
46+
47+
#if !defined(__APPLE__) && !defined(__FreeBSD__)
1048
typedef uint8_t u_int8_t;
11-
typedef unsigned short uint16_t;
1249
typedef uint16_t u_int16_t;
13-
typedef unsigned uint32_t;
1450
typedef uint32_t u_int32_t;
15-
typedef unsigned long long uint64_t;
1651
typedef uint64_t u_int64_t;
17-
#define snprintf _snprintf
18-
#else
19-
#include <stdint.h>
2052
#endif
2153

2254
static inline int CZlib_deflateInit2(z_streamp strm, int level, int method,
@@ -41,18 +73,4 @@ static inline Bytef *CZlib_voidPtr_to_BytefPtr_mut(uint8_t *__counted_by(len)
4173
return (Bytef *)in;
4274
}
4375

44-
static inline int CZlib_inflateInitDiag(z_streamp strm, int windowBits,
45-
int *outVersionError,
46-
int *outStreamError) {
47-
// Call inflateInit2_ directly so we can observe which error path fires
48-
*outVersionError = 0;
49-
*outStreamError = 0;
50-
int rc = inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
51-
if (rc == Z_VERSION_ERROR)
52-
*outVersionError = 1;
53-
if (rc == Z_STREAM_ERROR)
54-
*outStreamError = 1;
55-
return rc;
56-
}
57-
5876
#endif /* CZLIB_H */

0 commit comments

Comments
 (0)