Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Paul van Tilburg | afca20c96f | |
Paul van Tilburg | 2d34eee49a | |
Paul van Tilburg | a52313ffb7 | |
Admar Schoonen | f39a3a33ee | |
Paul van Tilburg | a59b4eefe1 | |
Paul van Tilburg | 1aad3e2eb6 | |
Paul van Tilburg | 929508a9cc | |
Paul van Tilburg | 23e4f731a0 | |
Paul van Tilburg | d84440304a |
|
@ -1,64 +1,19 @@
|
|||
name: "Check, Test and Lint Using Cargo"
|
||||
name: "Check, lint and test using Cargo"
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
- push
|
||||
- workflow_dispatch
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
check_lint:
|
||||
name: Check, lint and test
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Use sparse Cargo index for crates.io
|
||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Run cargo check
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Use sparse Cargo index for crates.io
|
||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Run cargo test
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-features
|
||||
|
||||
lints:
|
||||
name: Lints
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
- name: Install Rust stable toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
|
@ -69,14 +24,25 @@ jobs:
|
|||
- name: Use sparse Cargo index for crates.io
|
||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Run cargo fmt
|
||||
- name: Run cargo check
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
command: check
|
||||
|
||||
- name: Run cargo clippy
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
||||
- name: Run cargo fmt
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
- name: Run cargo test
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-features
|
|
@ -0,0 +1,85 @@
|
|||
name: "Release"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: "Release"
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine the version of the release
|
||||
run: |
|
||||
VERSION=${GITHUB_REF_NAME#v}
|
||||
echo "Releasing version: $VERSION"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Use sparse Cargo index for crates.io
|
||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Install cargo-deb
|
||||
uses: https://github.com/brndnmtthws/rust-action-cargo-binstall@v1
|
||||
with:
|
||||
packages: cargo-deb
|
||||
|
||||
- name: Run cargo-deb
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: deb
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.20.1'
|
||||
|
||||
- name: Release to Gitea
|
||||
uses: actions/release-action@main
|
||||
with:
|
||||
# This is available by default.
|
||||
api_key: '${{ secrets.RELEASE_TOKEN }}'
|
||||
files: target/debian/sinoptik*.deb
|
||||
title: 'Release ${{ env.VERSION }}'
|
||||
|
||||
release-crate:
|
||||
name: "Release crate"
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Use sparse Cargo index for crates.io
|
||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Register the Gitea crate registry with Cargo
|
||||
run: echo -e '[registries.luon]\nindex = "https://git.luon.net/paul/_cargo-index.git"' >> /root/.cargo/config.toml
|
||||
|
||||
- name: Run cargo publish
|
||||
uses: https://github.com/actions-rs/cargo@v1
|
||||
env:
|
||||
# This needs to be provided for the repository; no login necessary as a result.
|
||||
CARGO_REGISTRIES_LUON_TOKEN: '${{ secrets.CARGO_REGISTRIES_LUON_TOKEN }}'
|
||||
with:
|
||||
command: publish
|
||||
args: --registry luon
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.6]
|
||||
|
||||
### Added
|
||||
|
||||
* Add full release Gitea Actions workflow
|
||||
|
||||
### Changed
|
||||
|
||||
* Simplify Gitea Actions check, lint and test workflow
|
||||
* Improve no known map colors found error description
|
||||
|
||||
### Fixed
|
||||
|
||||
* Update coordinates of Eindhoven in tests (Nomatim changed its geocoding)
|
||||
* Increase sampling area to 31×31 pixels (#26)
|
||||
* Switch to new Buienradar color scheme/maps key (#27)
|
||||
|
||||
## [0.2.5]
|
||||
|
||||
### Added
|
||||
|
@ -88,7 +105,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
Initial release.
|
||||
|
||||
[Unreleased]: https://git.luon.net/paul/sinoptik/compare/v0.2.5...HEAD
|
||||
[Unreleased]: https://git.luon.net/paul/sinoptik/compare/v0.2.6...HEAD
|
||||
[0.2.6]: https://git.luon.net/paul/sinoptik/compare/v0.2.5...v0.2.6
|
||||
[0.2.5]: https://git.luon.net/paul/sinoptik/compare/v0.2.4...v0.2.5
|
||||
[0.2.4]: https://git.luon.net/paul/sinoptik/compare/v0.2.3...v0.2.4
|
||||
[0.2.3]: https://git.luon.net/paul/sinoptik/compare/v0.2.2...v0.2.3
|
||||
|
|
|
@ -1834,7 +1834,7 @@ checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f"
|
|||
|
||||
[[package]]
|
||||
name = "sinoptik"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
dependencies = [
|
||||
"assert_float_eq",
|
||||
"assert_matches",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "sinoptik"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
authors = [
|
||||
"Admar Schoonen <admar@luon.net",
|
||||
"Paul van Tilburg <paul@luon.net>"
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -189,7 +189,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
fn maps_stub(map_count: u32) -> RetrievedMaps {
|
||||
let map_color = Rgba::from([73, 218, 33, 255]); // First color from map key.
|
||||
let map_color = Rgba::from([0x00, 0x8A, 0x00, 0xFF]); // First color from map key.
|
||||
let image =
|
||||
DynamicImage::ImageRgba8(RgbaImage::from_pixel(820 * map_count, 988, map_color));
|
||||
|
||||
|
@ -213,8 +213,8 @@ mod tests {
|
|||
let response = client.get("/forecast?address=eindhoven").dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
let json = response.into_json::<JsonValue>().expect("Not valid JSON");
|
||||
assert_float_absolute_eq!(json["lat"].as_f64().unwrap(), 51.44855695, 1e-8);
|
||||
assert_float_absolute_eq!(json["lon"].as_f64().unwrap(), 5.45012252, 1e-8);
|
||||
assert_float_absolute_eq!(json["lat"].as_f64().unwrap(), 51.4392648, 1e-8);
|
||||
assert_float_absolute_eq!(json["lon"].as_f64().unwrap(), 5.478633, 1e-8);
|
||||
assert_matches!(json["time"], JsonValue::Number(_));
|
||||
assert_matches!(json.get("AQI"), None);
|
||||
assert_matches!(json.get("NO2"), None);
|
||||
|
@ -231,8 +231,8 @@ mod tests {
|
|||
.dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
let json = response.into_json::<JsonValue>().expect("Not valid JSON");
|
||||
assert_float_absolute_eq!(json["lat"].as_f64().unwrap(), 51.44855695, 1e-8);
|
||||
assert_float_absolute_eq!(json["lon"].as_f64().unwrap(), 5.45012252, 1e-8);
|
||||
assert_float_absolute_eq!(json["lat"].as_f64().unwrap(), 51.4392648, 1e-8);
|
||||
assert_float_absolute_eq!(json["lon"].as_f64().unwrap(), 5.478633, 1e-8);
|
||||
assert_matches!(json["time"], JsonValue::Number(_));
|
||||
assert_matches!(json.get("AQI"), Some(JsonValue::Array(_)));
|
||||
assert_matches!(json.get("NO2"), Some(JsonValue::Array(_)));
|
||||
|
|
28
src/maps.rs
28
src/maps.rs
|
@ -47,8 +47,8 @@ pub(crate) enum Error {
|
|||
#[error("Failed to join a task: {0}")]
|
||||
Join(#[from] rocket::tokio::task::JoinError),
|
||||
|
||||
/// Found no known (map key) colors in samples.
|
||||
#[error("Found not known colors in samples")]
|
||||
/// Did not find any known (map key) colors in samples.
|
||||
#[error("Did not find any known colors in samples")]
|
||||
NoKnownColorsInSamples,
|
||||
|
||||
/// No maps found (yet).
|
||||
|
@ -78,22 +78,22 @@ type MapKeyHistogram = HashMap<Rgb<u8>, u32>;
|
|||
/// Note that the actual score starts from 1, not 0 as per this array.
|
||||
#[rustfmt::skip]
|
||||
const MAP_KEY: [[u8; 3]; 10] = [
|
||||
[0x49, 0xDA, 0x21],
|
||||
[0x30, 0xD2, 0x00],
|
||||
[0xFF, 0xF8, 0x8B],
|
||||
[0xFF, 0xF6, 0x42],
|
||||
[0xFD, 0xBB, 0x31],
|
||||
[0xFD, 0x8E, 0x24],
|
||||
[0xFC, 0x10, 0x3E],
|
||||
[0x97, 0x0A, 0x33],
|
||||
[0xA6, 0x6D, 0xBC],
|
||||
[0xB3, 0x30, 0xA1],
|
||||
[0x00, 0x8A, 0x00], // #008A00
|
||||
[0x01, 0xAD, 0x01], // #01AD01
|
||||
[0x8C, 0xD6, 0x00], // #8CD600
|
||||
[0xAE, 0xE7, 0x00], // #AEE700
|
||||
[0xF8, 0xE7, 0x1C], // #F8E71C
|
||||
[0xF5, 0xD4, 0x23], // #F5D423
|
||||
[0xFF, 0x95, 0x00], // #FF9500
|
||||
[0xE8, 0x53, 0x00], // #E85300
|
||||
[0xD7, 0x07, 0x26], // #D70726
|
||||
[0xAD, 0x01, 0x01], // #AD0101
|
||||
];
|
||||
|
||||
/// The Buienradar map sample size.
|
||||
///
|
||||
/// Determiess the number of pixels in width/height that is samples around the sampling coordinate.
|
||||
const MAP_SAMPLE_SIZE: [u32; 2] = [11, 11];
|
||||
/// Determines the number of pixels in width/height that is sampled around the sampling coordinate.
|
||||
const MAP_SAMPLE_SIZE: [u32; 2] = [31, 31];
|
||||
|
||||
/// The interval between map refreshes (in seconds).
|
||||
const REFRESH_INTERVAL: tokio::time::Duration = tokio::time::Duration::from_secs(60);
|
||||
|
|
Loading…
Reference in New Issue