Skip to content

Commit

Permalink
Add GitHub actions, remove Travis (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Mobarak authored Feb 11, 2021
1 parent caa3b8b commit 7c1dcea
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 93 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI
on:
push:
branches:
- 'master'
pull_request:
jobs:
lint:
name: Format and lint
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
name: Format Check
with:
command: fmt
args: -- --check
- uses: actions-rs/cargo@v1
name: Lint
with:
command: clippy
args: --all-features --all-targets -- -D warnings
test:
name: Tests
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
name: Run tests
with:
command: test
args: --all-features --all-targets
build:
name: Build binaries
needs:
- lint
- test
strategy:
matrix:
os: [windows-2019, macos-10.15, ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
toolchain: stable
override: true
- uses: davidB/rust-cargo-make@v1
- name: Run CI
run: cargo make ci-flow
50 changes: 50 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
name: Publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
binary_target: x86_64-unknown-linux-musl
- os: windows-2019
binary_target: x86_64-pc-windows-msvc
- os: macos-10.15
binary_target: x86_64-apple-darwin
steps:
- name: Install musl tools
if: matrix.os == 'ubuntu-18.04'
run: sudo apt-get install musl-tools
- name: Checkout
uses: actions/checkout@v2
- name: Install rust for target ${{ matrix.binary_target }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable-${{ matrix.binary_target }}
profile: minimal
- uses: davidB/rust-cargo-make@v1
- name: Pull tags
run: git fetch --tags --prune --unshallow
- name: Fetch `git describe --tags`
id: git_describe
run: |
echo "::set-output name=result::$(git describe --tags)"
- name: Build Binary
run: "
cargo make zip-release-ci-flow
--env CARGO_MAKE_RELEASE_FLOW_TARGET=${{ matrix.binary_target }}
--env CARGO_MAKE_PROJECT_VERSION=${{ steps.git_describe.outputs.result }}"
- name: Upload Binaries
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '*.zip'
tag: ${{ github.ref }}
overwrite: true
file_glob: true
16 changes: 0 additions & 16 deletions .travis.sh

This file was deleted.

72 changes: 0 additions & 72 deletions .travis.yml

This file was deleted.

54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ curl = "0.4"
curl-sys = "0.4"
structopt = "0.3"
chrono = "0.4"

[build-dependencies]
vergen = "3"
11 changes: 11 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extern crate vergen;

use vergen::{generate_cargo_keys, ConstantsFlags};

fn main() {
let mut flags = ConstantsFlags::all();
flags.toggle(ConstantsFlags::SEMVER_FROM_CARGO_PKG);

// Generate the 'cargo:' key output
generate_cargo_keys(flags).expect("Unable to generate the cargo keys!");
}
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use structopt::StructOpt;
const CURLOPT_HTTP09_ALLOWED: CURLoption = 285;

#[derive(Debug, StructOpt)]
#[structopt(name = "ntripping", about = "NTRIP command line client.")]
#[structopt(name = "ntripping", about = "NTRIP command line client.", version = env!("VERGEN_SEMVER_LIGHTWEIGHT"))]
struct Opt {
#[structopt(long, default_value = "na.skylark.swiftnav.com:2101/CRS")]
url: String,
Expand All @@ -34,7 +34,7 @@ type Result<T> = std::result::Result<T, Box<dyn Error>>;

thread_local! {
static CURL: RefCell<Easy> = RefCell::new(Easy::new());
static LAST: RefCell<SystemTime> = RefCell::new(UNIX_EPOCH.clone());
static LAST: RefCell<SystemTime> = RefCell::new(UNIX_EPOCH);
}

fn checksum(buf: &[u8]) -> u8 {
Expand Down Expand Up @@ -91,7 +91,7 @@ fn main() -> Result<()> {
let now = SystemTime::now();
let elapsed = LAST.with(|last| {
let dur = now.duration_since(*last.borrow());
dur.unwrap_or(Duration::from_secs(0)).as_secs()
dur.unwrap_or_else(|_| Duration::from_secs(0)).as_secs()
});
if elapsed > 10 {
CURL.with(|curl| curl.borrow().unpause_read().unwrap());
Expand All @@ -103,10 +103,10 @@ fn main() -> Result<()> {
let now = SystemTime::now();
let elapsed = LAST.with(|last| {
let dur = now.duration_since(*last.borrow());
dur.unwrap_or(Duration::from_secs(0)).as_secs()
dur.unwrap_or_else(|_| Duration::from_secs(0)).as_secs()
});
if elapsed > 10 {
LAST.with(|last| *last.borrow_mut() = now.clone());
LAST.with(|last| *last.borrow_mut() = now);
let datetime: DateTime<Utc> = now.into();
let time = datetime.format("%H%M%S.00");
let gpgga = format!(
Expand Down

0 comments on commit 7c1dcea

Please sign in to comment.