Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix secrets #431

Merged
merged 5 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build_and_test_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ jobs:
- name: Test and build release
if: inputs.release
env:
SHEET_ID: ${{ env.SHEET_ID }}
SHEET_ID: ${{ secrets.SHEET_ID }}
RUST_LOG: info
run: cargo test --release -- --nocapture && cargo build --release

- name: Test and build debug
if: ${{ !inputs.release }}
env:
SHEET_ID: ${{ env.SHEET_ID }}
SHEET_ID: ${{ secrets.SHEET_ID }}
RUST_LOG: info
run: cargo test -- --nocapture && cargo build

- name: Move binary
Expand Down
7 changes: 5 additions & 2 deletions core/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod prelude {
}

use self::finite_state::{Fs, Row};
use anyhow::{anyhow, Context};
use anyhow::{anyhow, bail, Context};
use bytes::Buf;
use csv::Reader;
use finite_state::MultilangFs;
Expand Down Expand Up @@ -42,6 +42,9 @@ fn get_finite_state(rdr: Reader<impl Read>, lang: Lang) -> anyhow::Result<Fs> {
.collect::<Result<Vec<Row>, _>>()
.context("Cannot parse csv")?;
rows.retain(|record| !record.is_empty());
if rows.is_empty() {
bail!("No data");
}
for r in rows.iter_mut() {
r.key = r.key.trim().to_string();
r.question = r.question.trim().to_string();
Expand All @@ -59,7 +62,7 @@ pub fn get_data_from_file(filename: &str) -> anyhow::Result<MultilangFs> {
}

pub async fn get_data_from_web() -> anyhow::Result<MultilangFs> {
let sheet_id = env!("SHEET_ID");
let sheet_id = option_env!("SHEET_ID").ok_or_else(|| anyhow!("SHEET_ID is not set"))?;
assert!(Lang::iter().count() == 1, "Only one language is supported");
let lang = Lang::iter().next().unwrap();
let sheet_name = lang.name();
Expand Down
12 changes: 5 additions & 7 deletions core/tests/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ pre-formatted fixed-width code block written in the Python programming language
} else {
get_data_from_file("../table.csv")?
};
data.iter()
.for_each(|(lang, fs)| log::info!("Testing {lang} with {} nodes", fs.num_nodes()));
for (lang, fs) in data.into_iter() {
let n_nodes = fs.num_nodes();
test_fs(fs)?;
log::info!("All tests passed for {lang} with {n_nodes} nodes");
}
assert!(!data.is_empty());
assert!(data.iter().all(|(_, fs)| fs.num_nodes() > 1));
data.into_iter()
.inspect(|(lang, fs)| log::info!("Testing {lang} with {} nodes", fs.num_nodes()))
.try_for_each(|(_, fs)| test_fs(fs))?;

Ok(())
}
Expand Down