Skip to content

Commit d343048

Browse files
authored
Merge pull request #5 from madsmtm/cleanup-ci
Fix CI setup
2 parents c496ec1 + b819901 commit d343048

File tree

17 files changed

+258
-85
lines changed

17 files changed

+258
-85
lines changed

.github/workflows/ci.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
# Faster compilation and error on warnings
12+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
13+
14+
jobs:
15+
fmt:
16+
name: Check formatting
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Check formatting
21+
uses: actions-rs/cargo@v1
22+
with:
23+
command: fmt
24+
args: -- --check
25+
26+
test:
27+
name: Test
28+
strategy:
29+
matrix:
30+
platform:
31+
- { os: ubuntu-latest } # TODO: 32bit and gcc-multilib
32+
- { os: macos-10.15 }
33+
- { os: macos-11 }
34+
# - { target: x86_64-apple-ios, os: macos-latest, }
35+
# - { target: aarch64-apple-ios, os: macos-latest, }
36+
37+
runs-on: ${{ matrix.platform.os }}
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
42+
- name: Cache Rust
43+
uses: actions/cache@v2
44+
with:
45+
path: |
46+
~/.cargo/
47+
target/
48+
key: ${{ matrix.platform.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
49+
restore-keys: |
50+
${{ matrix.platform.os }}-cargo-
51+
52+
- name: Install Packages
53+
if: contains(matrix.platform.os, 'ubuntu')
54+
run: sudo apt-get install gobjc clang make
55+
56+
- name: Install different Rust toolchain
57+
# A default toolchain is already installed
58+
if: matrix.platform.target
59+
uses: actions-rs/toolchain@v1
60+
with:
61+
toolchain: stable
62+
target: ${{ matrix.platform.target }}
63+
profile: minimal
64+
override: true
65+
66+
- name: Check documentation
67+
uses: actions-rs/cargo@v1
68+
with:
69+
# TODO: Disallow warnings here
70+
command: doc
71+
args: --no-deps --document-private-items
72+
73+
- # Run before we install GNUStep as a "fail fast" mechanism
74+
name: Run checks
75+
uses: actions-rs/cargo@v1
76+
with:
77+
command: check
78+
args: --verbose
79+
80+
- name: Install GNUStep libobjc2
81+
if: contains(matrix.platform.os, 'ubuntu')
82+
run: |
83+
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
84+
tar -xzf v1.9.tar.gz
85+
mkdir libobjc2-1.9/build
86+
cd libobjc2-1.9/build
87+
export CC="clang"
88+
export CXX="clang++"
89+
cmake ../
90+
sudo make install
91+
92+
- name: Install GNUStep make
93+
if: contains(matrix.platform.os, 'ubuntu')
94+
run: |
95+
wget https://github.com/gnustep/tools-make/archive/refs/tags/make-2_9_0.tar.gz
96+
tar -xzf make-2_9_0.tar.gz
97+
cd tools-make-make-2_9_0
98+
./configure --with-library-combo=ng-gnu-gnu
99+
sudo make install
100+
101+
- name: Install GNUStep-Base
102+
if: contains(matrix.platform.os, 'ubuntu')
103+
run: |
104+
wget https://github.com/gnustep/libs-base/archive/refs/tags/base-1_28_0.tar.gz
105+
tar -xzf base-1_28_0.tar.gz
106+
cd libs-base-base-1_28_0
107+
./configure --disable-tls
108+
sudo make install
109+
110+
- name: Setup environment
111+
if: contains(matrix.platform.os, 'ubuntu')
112+
run: |
113+
ls -al /usr/local/lib
114+
ls -al /usr/local/include
115+
echo "LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH" >> $GITHUB_ENV
116+
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
117+
echo "CPATH=/usr/local/include:$CPATH" >> $GITHUB_ENV
118+
119+
- name: Build and run tests
120+
uses: actions-rs/cargo@v1
121+
with:
122+
command: test
123+
# TODO: `objc/exception` feature is broken in objc_foundation
124+
# TODO: `objc_foundation/block` feature doesn't work on GNUStep
125+
args: --verbose --no-fail-fast --no-default-features

.travis-disabled.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
sudo: false
2+
language: rust
3+
cache: cargo
4+
os: osx
5+
6+
# Run on master and PRs
7+
if: branch = master
8+
9+
script:
10+
- cargo test --workspace --verbose
11+
- # TODO: cargo test --workspace --verbose --all-features
12+
13+
jobs:
14+
include:
15+
- name: MacOS 10.11
16+
osx_image: xcode7.3
17+
18+
- name: MacOS 10.13 (with 32bit)
19+
osx_image: xcode9.4
20+
rust: nightly
21+
# 32-bit targets only have tier 3 support
22+
install: rustup component add rust-src
23+
script:
24+
- cargo test --workspace --verbose
25+
- # TODO: cargo test --workspace --verbose --all-features
26+
- # objc_exception doesn't work on 32bit?
27+
cargo test --workspace --exclude objc_exception --verbose -Z build-std --target i686-apple-darwin
28+
- # TODO: cargo test --workspace --verbose --all-features -Z build-std --target i686-apple-darwin
29+
30+
- name: MacOS 11.3
31+
osx_image: xcode12.5
32+
33+
- name: iOS nightly
34+
osx_image: xcode7.3
35+
rust: nightly
36+
before_install: rustup component add rust-src
37+
# Install rust-test-ios
38+
install: curl -LO https://github.com/SSheldon/rust-test-ios/releases/download/0.1.1/rust-test-ios && chmod +x rust-test-ios
39+
before_script:
40+
# Enable -Z build-std, 32-bit targets only have tier 3 support
41+
- printf '[unstable]\nbuild-std = ["std"]\n' > $HOME/.cargo/config.toml
42+
# Remove workspace since `rust-test-ios` is not made for that
43+
- rm Cargo.toml
44+
# TODO: env: FEATURES="exception"
45+
script: cd objc && ../rust-test-ios

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ members = [
66
"objc_foundation",
77
"objc_id",
88
]
9+
exclude = ["objc/tests-ios"]

objc/.travis.yml

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

objc/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ exclude = [
1515
".gitignore",
1616
".travis.yml",
1717
"doc.sh",
18-
"travis_install.sh",
19-
"travis_test.sh",
2018
"tests-ios/**",
2119
]
2220

objc/tests-ios/prelude.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[macro_use]
2+
extern crate objc;
3+
14
use objc::rc::*;
25
use objc::runtime::*;
36
pub use objc::*;

objc/travis_install.sh

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

objc/travis_test.sh

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

objc_exception/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
22
cc::Build::new()
33
.file("extern/exception.m")
4+
.flag("-fobjc-exceptions")
45
.compile("libexception.a");
56
}

objc_exception/extern/exception.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
#include <objc/objc.h>
2-
#include <objc/NSObject.h>
3-
4-
void RustObjCExceptionThrow(id exception) {
5-
@throw exception;
6-
}
1+
// Always available in Objective-C
2+
// See https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain
3+
id objc_retain(id value);
74

85
int RustObjCExceptionTryCatch(void (*try)(void *), void *context, id *error) {
96
@try {
107
try(context);
118
if (error) {
12-
*error = nil;
9+
*error = (id)0; // nil
1310
}
1411
return 0;
1512
} @catch (id exception) {
1613
if (error) {
17-
*error = [exception retain];
14+
*error = objc_retain(exception);
1815
}
1916
return 1;
2017
}

0 commit comments

Comments
 (0)