Skip to content

Commit cc8746c

Browse files
authored
Separate integration and package tests (#134)
1 parent b7b84d0 commit cc8746c

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ jobs:
3232
-p swift-bridge-ir \
3333
-p swift-bridge-macro \
3434
-p swift-integration-tests
35+
36+
swift-package-test:
37+
runs-on: macOS-11
38+
timeout-minutes: 30
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
43+
- uses: actions-rs/toolchain@v1
44+
with:
45+
toolchain: stable
46+
47+
- name: Add rust targets
48+
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
49+
50+
- name: Run swift package tests
51+
run: ./test-swift-packages.sh
3552

3653
integration-test:
3754
runs-on: macOS-11
@@ -48,7 +65,7 @@ jobs:
4865
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
4966

5067
- name: Run integration tests
51-
run: ./test-integration.sh
68+
run: ./test-swift-rust-integration.sh
5269

5370
build-examples:
5471
runs-on: macOS-11

test-swift-packages.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Swift package tests
4+
5+
set -e
6+
7+
export RUSTFLAGS="-D warnings"
8+
9+
# Change to the root directory of the Xcode project
10+
cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P
11+
THIS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
12+
ROOT_DIR="$THIS_DIR"
13+
cd $ROOT_DIR
14+
15+
# Make a temp directory
16+
TEMP_DIR=$(mktemp -d)
17+
18+
# Delete the temp directory before the shell exits
19+
trap 'rm -rf $TEMP_DIR' EXIT
20+
21+
# Copy directories related to all of the building and test running to the temp directory
22+
for DIR in crates src examples SwiftRustIntegrationTestRunner
23+
do
24+
cp -r $DIR/ $TEMP_DIR/$DIR
25+
done
26+
cp Cargo.toml $TEMP_DIR
27+
cd $TEMP_DIR/SwiftRustIntegrationTestRunner
28+
29+
# Build Rust
30+
mkdir -p swift-package-rust-library-fixture/generated
31+
32+
./swift-package-rust-library-fixture/build.sh
33+
34+
# Create Swift Package
35+
cargo run -p integration-test-create-swift-package
36+
37+
# Test Swift Package
38+
cd swift-package-test-package
39+
swift test

test-integration.sh renamed to test-swift-rust-integration.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,6 @@ ROOT_DIR="$THIS_DIR"
1212
cd $ROOT_DIR
1313

1414
cd SwiftRustIntegrationTestRunner
15-
16-
# Delete previous generated files/folders
17-
rm -r swift-package-rust-library-fixture/generated || true
18-
rm -r swift-package-rust-library-fixture/MySwiftPackage || true
19-
rm -r swift-package-rust-library-fixture/target || true
20-
rm -r swift-package-test-package/.build || true
21-
22-
# Build Rust
23-
mkdir swift-package-rust-library-fixture/generated
24-
25-
./swift-package-rust-library-fixture/build.sh
26-
27-
# Create Swift Package
28-
cargo run -p integration-test-create-swift-package
29-
30-
# Test Swift Package
31-
cd swift-package-test-package
32-
swift test
33-
cd ..
34-
3515
# If project files don't exist before Xcode begins building we get something like:
3616
# error: Build input file cannot be found: '/path/to/Generated/SwiftBridgeCore.swift'
3717
# So.. here we create empty versions of the files that will get generated during the

0 commit comments

Comments
 (0)