Skip to content

Commit a6eb601

Browse files
committed
Add GHA CI
1 parent be2d18f commit a6eb601

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

.github/workflows/build.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Build
7+
8+
env:
9+
RUSTFLAGS: '--deny warnings'
10+
11+
jobs:
12+
build-std:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust: [stable]
17+
FEATURES: ['', 'from_str', 'no_std']
18+
19+
include:
20+
# Test nightly but don't fail
21+
- rust: nightly
22+
experimental: true
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions-rs/toolchain@v1
27+
with:
28+
profile: minimal
29+
toolchain: ${{ matrix.rust }}
30+
target: ${{ matrix.TARGET }}
31+
override: true
32+
- uses: actions-rs/cargo@v1
33+
with:
34+
command: build
35+
args: --target=x86_64-unknown-linux-gnu --features=${{ matrix.FEATURES }}
36+
- uses: actions-rs/cargo@v1
37+
with:
38+
command: test
39+
args: --target=x86_64-unknown-linux-gnu --features=${{ matrix.FEATURES }}
40+
41+
build-no-std:
42+
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
rust: [stable]
46+
TARGET: [thumbv6m-none-eabi, thumbv7m-none-eabi]
47+
48+
include:
49+
# Test nightly but don't fail
50+
- rust: nightly
51+
experimental: true
52+
TARGET: x86_64-unknown-linux-gnu
53+
54+
steps:
55+
- uses: actions/checkout@v2
56+
- uses: actions-rs/toolchain@v1
57+
with:
58+
profile: minimal
59+
toolchain: ${{ matrix.rust }}
60+
target: ${{ matrix.TARGET }}
61+
override: true
62+
- uses: actions-rs/cargo@v1
63+
with:
64+
command: build
65+
args: --target=${{ matrix.TARGET }} --features no_std
66+
67+
fmt:
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v2
71+
- uses: actions-rs/toolchain@v1
72+
with:
73+
profile: minimal
74+
toolchain: stable
75+
override: true
76+
components: rustfmt
77+
- uses: actions-rs/cargo@v1
78+
with:
79+
command: fmt
80+
args: --all -- --check
81+
82+
clippy:
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v2
86+
- uses: actions-rs/toolchain@v1
87+
with:
88+
profile: minimal
89+
toolchain: 1.52.1 # clippy is too much of a moving target at the moment
90+
override: true
91+
components: clippy
92+
- uses: actions-rs/clippy-check@v1
93+
with:
94+
token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/humidity.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
//! Types and constants for handling humidity.
22
33
use super::measurement::*;
4+
#[cfg(not(feature = "no_std"))]
45
use density::Density;
6+
#[cfg(not(feature = "no_std"))]
57
use pressure::Pressure;
8+
#[cfg(not(feature = "no_std"))]
69
use temperature::Temperature;
710

811
/// The `Humidity` struct can be used to deal with relative humidity
@@ -32,7 +35,9 @@ use temperature::Temperature;
3235
///
3336
/// let humidity = Humidity::from_percent(85.0);
3437
/// let temp = Temperature::from_celsius(18.0);
38+
/// #[cfg(not(feature="no_std"))]
3539
/// let dewpoint = humidity.as_dewpoint(temp);
40+
/// #[cfg(not(feature="no_std"))]
3641
/// println!("At {} humidity, air at {} has a dewpoint of {}", humidity, temp, dewpoint);
3742
///
3843
/// ```
@@ -162,41 +167,47 @@ mod test {
162167
assert_almost_eq(o, 0.1);
163168
}
164169
// Dewpoint calculation
170+
#[cfg(not(feature = "no_std"))]
165171
#[test]
166172
fn to_dewpoint1() {
167173
let humidity = Humidity::from_percent(85.0);
168174
let temp = Temperature::from_celsius(18.0);
169175
let dewpoint = humidity.as_dewpoint(temp);
170176
assert_almost_eq(dewpoint.as_celsius(), 15.44);
171177
}
178+
#[cfg(not(feature = "no_std"))]
172179
#[test]
173180
fn to_dewpoint2() {
174181
let humidity = Humidity::from_percent(40.0);
175182
let temp = Temperature::from_celsius(5.0);
176183
let dewpoint = humidity.as_dewpoint(temp);
177184
assert_almost_eq(dewpoint.as_celsius(), -7.5);
178185
}
186+
#[cfg(not(feature = "no_std"))]
179187
#[test]
180188
fn to_dewpoint3() {
181189
let humidity = Humidity::from_percent(95.0);
182190
let temp = Temperature::from_celsius(30.0);
183191
let dewpoint = humidity.as_dewpoint(temp);
184192
assert_almost_eq(dewpoint.as_celsius(), 29.11);
185193
}
194+
#[cfg(not(feature = "no_std"))]
186195
#[test]
187196
fn from_dewpoint1() {
188197
let temp = Temperature::from_celsius(18.0);
189198
let dewpoint = Temperature::from_celsius(15.44);
190199
let rh = Humidity::from_dewpoint(dewpoint, temp);
191200
assert_almost_eq(rh.as_percent(), 85.0);
192201
}
202+
#[cfg(not(feature = "no_std"))]
193203
#[test]
194204
fn vapour_pressure() {
195205
let humidity = Humidity::from_percent(60.0);
196206
let temp = Temperature::from_celsius(25.0);
197207
let vp = humidity.as_vapor_pressure(temp);
198208
assert_almost_eq(vp.as_hectopascals(), 19.011);
199209
}
210+
#[cfg(not(feature = "no_std"))]
200211
#[test]
201212
// also tests as_vapor_pressure() on the fly
202213
fn absolute_humidity() {
@@ -205,6 +216,7 @@ mod test {
205216
let density = humidity.as_absolute_humidity(temp);
206217
assert_almost_eq(density.as_kilograms_per_cubic_meter(), 0.0138166);
207218
}
219+
#[cfg(not(feature = "no_std"))]
208220
#[test]
209221
// round-trip test
210222
fn from_dewpoint2() {

0 commit comments

Comments
 (0)