Skip to content

Commit

Permalink
Added build
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecardleitao committed Feb 29, 2024
1 parent 454a89a commit e0bebda
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Test

on: [push, pull_request]
on:
release:
types: [created]
push:
pull_request:

jobs:
test:
Expand Down Expand Up @@ -31,3 +35,31 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: Run etl
run: cargo run --features="build-binary" --bin etl_private_jets

build-and-publish-binaries:
permissions: write-all
name: Publish binaries (${{ matrix.target }})
needs: [run]
if: github.event_name == 'release'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz tar.xz tar.zst
- target: x86_64-apple-darwin
archive: zip
steps:
- uses: actions/checkout@v3
- name: Compile and release
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
EXTRA_COMMAND_FLAGS: --features=build-binary

6 changes: 3 additions & 3 deletions src/bin/country.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ use flights::{
};
use time::Date;

static TEMPLATE: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bin/country.md"));

fn render(context: &Context) -> Result<(), Box<dyn Error>> {
let path = format!("{}_story.md", context.country.name.to_lowercase());

let template = std::fs::read_to_string("src/bin/country.md")?;

let mut tt = tinytemplate::TinyTemplate::new();
tt.set_default_formatter(&tinytemplate::format_unescaped);
tt.add_template("t", &template)?;
tt.add_template("t", TEMPLATE)?;

let rendered = tt.render("t", context)?;

Expand Down
9 changes: 6 additions & 3 deletions src/bin/period.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ pub struct Context {
pub ratio_commercial_300km: String,
}

static TEMPLATE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/period_template.md"
));

fn render(context: &Context) -> Result<(), Box<dyn Error>> {
let path = "story.md";

let template = std::fs::read_to_string("src/bin/period_template.md")?;

let mut tt = tinytemplate::TinyTemplate::new();
tt.set_default_formatter(&tinytemplate::format_unescaped);
tt.add_template("t", &template)?;
tt.add_template("t", TEMPLATE)?;

let rendered = tt.render("t", context)?;

Expand Down
8 changes: 5 additions & 3 deletions src/bin/single_day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use tinytemplate::TinyTemplate;

use flights::*;

static TEMPLATE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/single_day_template.md"
));
static TEMPLATE_NAME: &'static str = "t";

#[derive(serde::Serialize, serde::Deserialize, Debug)]
Expand Down Expand Up @@ -157,11 +161,9 @@ fn process_leg(
dane_years,
};

let template = std::fs::read_to_string("src/bin/single_day_template.md")?;

let mut tt = TinyTemplate::new();
tt.set_default_formatter(&tinytemplate::format_unescaped);
tt.add_template(TEMPLATE_NAME, &template)?;
tt.add_template(TEMPLATE_NAME, TEMPLATE)?;

let rendered = tt.render(TEMPLATE_NAME, &context)?;

Expand Down

0 comments on commit e0bebda

Please sign in to comment.