Skip to content

Commit 9f70bfb

Browse files
authored
Merge pull request #53 from runlevel5/ci/pin-actions-add-audit
(ci): bump actions, pin to SHA, add cargo audit
2 parents 9482175 + 2c8a0eb commit 9f70bfb

3 files changed

Lines changed: 30 additions & 32 deletions

File tree

.github/workflows/main.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ name: Main
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
lint:
710
name: Lints Checks
811
runs-on: ubuntu-latest
912
steps:
1013
- name: Checkout sources
11-
uses: actions/checkout@v4
14+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1215

1316
- name: Install stable toolchain
1417
run: |
@@ -33,8 +36,23 @@ jobs:
3336

3437
steps:
3538
- name: Checkout sources
36-
uses: actions/checkout@v4
39+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3740

3841
- name: Run Tests
3942
run: |
4043
cargo test
44+
45+
audit:
46+
name: Security Audit
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: read
50+
checks: write
51+
steps:
52+
- name: Checkout sources
53+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
54+
55+
- name: Run cargo audit
56+
uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}

examples/repl.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ fn main() {
55
let method = "telex";
66
let mut rl = DefaultEditor::new().unwrap();
77

8-
loop {
9-
let Ok(input) = rl.readline("(input): ") else {
10-
break;
11-
};
12-
8+
while let Ok(input) = rl.readline("(input): ") {
139
let mut result = String::new();
1410

1511
for word in input.split_whitespace() {

src/bin/vietnamese_generator.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,16 @@ fn is_valid_combination(initial: &str, rhyme: &str) -> bool {
6666

6767
// Rule: k/g/ng vs c/gh/ngh
6868
match initial {
69-
"c" | "g" | "ng" => {
70-
if is_front_vowel_rhyme {
71-
return false;
72-
} // c, g, ng must be followed by other vowels.
73-
}
74-
"k" | "gh" | "ngh" => {
75-
if !is_front_vowel_rhyme {
76-
return false;
77-
} // k, gh, ngh must be followed by i, e, ê, y.
78-
}
79-
"qu" => {
80-
// 'qu' acts as a single unit and cannot be followed by a rhyme starting with 'u' or 'o'.
81-
if "uo".contains(first_char_of_rhyme) {
82-
return false;
83-
}
84-
}
85-
"gi" => {
86-
// Avoid "gi" + i-initial rhyme like "giiên", which is not a valid word.
87-
if first_char_of_rhyme == 'i' {
88-
return false;
89-
}
90-
}
91-
_ => {}
69+
// c, g, ng must be followed by other vowels.
70+
"c" | "g" | "ng" if is_front_vowel_rhyme => false,
71+
// k, gh, ngh must be followed by i, e, ê, y.
72+
"k" | "gh" | "ngh" if !is_front_vowel_rhyme => false,
73+
// 'qu' acts as a single unit and cannot be followed by a rhyme starting with 'u' or 'o'.
74+
"qu" if "uo".contains(first_char_of_rhyme) => false,
75+
// Avoid "gi" + i-initial rhyme like "giiên", which is not a valid word.
76+
"gi" if first_char_of_rhyme == 'i' => false,
77+
_ => true,
9278
}
93-
94-
true
9579
}
9680

9781
/// Applies a tone mark to the correct vowel in a syllable.

0 commit comments

Comments
 (0)