-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
488 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: 'v*' | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
# Fail on all warnings. | ||
RUSTFLAGS: '-Dwarnings' | ||
|
||
jobs: | ||
build: | ||
name: Build ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Toolchain versions | ||
run: | | ||
rustc --version | ||
cargo --version | ||
- name: Build | ||
run: cargo build --release --all-targets --all-features --verbose | ||
|
||
- name: Clippy | ||
run: cargo clippy --release --all-targets --all-features --verbose | ||
|
||
- name: Test | ||
run: cargo test --release --all-targets --all-features | ||
|
||
# Create release only for tag commit. | ||
## General | ||
- name: General release artifacts | ||
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' }} | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: collection.toml | ||
|
||
## Ubuntu | ||
- name: Prepare Ubuntu release | ||
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' }} | ||
run: strip target/release/collection | ||
|
||
- name: Create Ubuntu release | ||
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' }} | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: target/release/collection | ||
|
||
## Windows | ||
- name: Create Windows release | ||
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.os == 'windows-latest' }} | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: target/release/collection.exe |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "collection" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
rand = "0.8" | ||
serde = {version = "1.0", features = ["derive"]} | ||
toml = "0.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
title = "Title" | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 10 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 0 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 1 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 2 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 3 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 4 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 5 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 6 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 7 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 8 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "12345678901234567890", "A", "Be"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 10 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight"] | ||
|
||
[[collections]] | ||
label = "Items" | ||
width = 10 | ||
items = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use serde::Deserialize; | ||
|
||
// Struct to hold the [[collections]] table. | ||
#[derive(Debug, Deserialize)] | ||
pub struct Collection { | ||
pub label: String, | ||
pub width: u8, | ||
pub items: Vec<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
pub mod collection; | ||
|
||
use serde::Deserialize; | ||
use std::error::Error; | ||
use std::fs; | ||
|
||
use collection::Collection; | ||
|
||
// Top level struct to hold entire input configuration. | ||
#[derive(Debug, Deserialize)] | ||
pub struct Config { | ||
pub title: String, | ||
pub collections: Vec<Collection>, | ||
} | ||
|
||
impl Config { | ||
pub fn read() -> Result<Config, Box<dyn Error>> { | ||
let filename = "collection.toml"; | ||
|
||
let contents = fs::read_to_string(filename).map_err(|err| format!("Unable to read file '{}'. Error: {}", filename, err))?; | ||
|
||
let input: Config = toml::from_str(&contents).map_err(|err| format!("Unable to load data from '{}'. Error: {}", filename, err))?; | ||
|
||
Ok(input) | ||
} | ||
} |
Oops, something went wrong.