Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Replace Travis with GitHub action for linting & tests #47

Merged
merged 13 commits into from Sep 27, 2019
30 changes: 0 additions & 30 deletions .ci/lint.sh

This file was deleted.

46 changes: 0 additions & 46 deletions .ci/test.sh

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,43 @@
on: push
name: CI
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

# make sure all code has been formatted with rustfmt
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check --color always

# run clippy to verify we have no warnings
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings

test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
45 changes: 0 additions & 45 deletions .travis.yml
Expand Up @@ -26,51 +26,6 @@ matrix:
fast_finish: true

include:
# _ _ _
# | | (_) | |
# | | _ _ __ | |_
# | | | | '_ \| __|
# | |____| | | | | |_
# |______|_|_| |_|\__|

# 1. Ensure rustfmt does not produce diffs. We always use
# the default rustfmt settings.
# 2. Ensure there are no clippy warnings.
- name: "stable lint"
# We could use a lint stage here, but prefer to go wide
#
stage: test
rust: stable
os: linux
script: .ci/lint.sh

# _______ _
# |__ __| | |
# | | ___ ___| |_
# | |/ _ \/ __| __|
# | | __/\__ \ |_
# |_|\___||___/\__|

# Tests all platforms on stable
# and additionally running beta and nightly
# tests on Linux as Linux runs are generally
# faster in every aspect on Travis

- name: "stable test linux"
stage: test
rust: stable
os: linux
script: .ci/test.sh

- name: "stable test osx"
rust: stable
os: osx
script: .ci/test.sh

- name: "stable test windows"
rust: stable
os: windows
script: .ci/test.sh

# Add more testing stages if you have them!

Expand Down
3 changes: 3 additions & 0 deletions cli/src/main.rs
@@ -1,3 +1,6 @@
#![warn(clippy::all)]
#![warn(rust_2018_idioms)]

use structopt::StructOpt;

use std::path::PathBuf;
Expand Down
3 changes: 3 additions & 0 deletions lib/src/lib.rs
@@ -1,3 +1,6 @@
#![warn(clippy::all)]
#![warn(rust_2018_idioms)]

//! `texture-synthesis` is a light API for Multiresolution Stochastic Texture Synthesis,
//! a non-parametric example-based algorithm for image generation.
//!
Expand Down
14 changes: 9 additions & 5 deletions lib/src/multires_stochastic_texture_synthesis.rs
Expand Up @@ -300,15 +300,19 @@ impl Generator {
let y_t = self.output_size.height as i32 - y_b;

if a[0] < x_l {
rtree.insert([a[0] + (self.output_size.width as i32), a[1]]); // +x
rtree.insert([a[0] + (self.output_size.width as i32), a[1]]);
// +x
} else if a[0] > x_r {
rtree.insert([a[0] - (self.output_size.width as i32), a[1]]); // -x
rtree.insert([a[0] - (self.output_size.width as i32), a[1]]);
// -x
}

if a[1] < y_b {
rtree.insert([a[0], a[1] + (self.output_size.height as i32)]); // +Y
rtree.insert([a[0], a[1] + (self.output_size.height as i32)]);
// +Y
} else if a[1] > y_t {
rtree.insert([a[0], a[1] - (self.output_size.height as i32)]); // -Y
rtree.insert([a[0], a[1] - (self.output_size.height as i32)]);
// -Y
}
}
resolved.push((*b, *score));
Expand Down Expand Up @@ -1190,7 +1194,7 @@ fn get_single_example_level<'a>(
fn get_single_guide_level(
guides_pyramid: &Option<GuidesPyramidStruct>,
pyramid_level: usize,
) -> Option<GuidesStruct> {
) -> Option<GuidesStruct<'_>> {
if let Some(ref guides_pyr) = guides_pyramid {
Some(guides_pyr.to_guides_struct(pyramid_level))
} else {
Expand Down