mirror of
https://github.com/apognu/tuigreet.git
synced 2024-09-11 07:25:29 +03:00
Update CI workflows.
This commit is contained in:
parent
a3b95d1bad
commit
ef41d59918
58
.github/workflows/dev.yml
vendored
58
.github/workflows/dev.yml
vendored
@ -3,50 +3,54 @@ name: Development build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'dev/*'
|
||||
- "dev/*"
|
||||
|
||||
jobs:
|
||||
clippy:
|
||||
if: "!contains(github.event.head_commit.message, 'skip ci')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Lint
|
||||
run: |
|
||||
cargo clippy
|
||||
cargo clippy --release
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test
|
||||
|
||||
build:
|
||||
if: "!contains(github.event.head_commit.message, 'skip ci')"
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- { name: 'x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false }
|
||||
- { name: 'i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true }
|
||||
- { name: 'armv7h', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true }
|
||||
- { name: 'aarch64', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true }
|
||||
- {
|
||||
name: "x86_64",
|
||||
os: "ubuntu-latest",
|
||||
target: "x86_64-unknown-linux-gnu",
|
||||
cross: false,
|
||||
}
|
||||
runs-on: ${{ matrix.arch.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: target/
|
||||
key: cargo-cache-${{ matrix.arch.target }}
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
shared-key: cargo-cache-${{ matrix.arch.target }}
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target=${{ matrix.arch.target }}
|
||||
use-cross: ${{ matrix.arch.cross }}
|
||||
run: |
|
||||
cargo build --release --target=${{ matrix.arch.target }}
|
||||
- name: Rename artifact
|
||||
run: mv target/${{ matrix.arch.target }}/release/tuigreet target/${{ matrix.arch.target }}/release/tuigreet-dev-${{ matrix.arch.name }}
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: tuigreet-dev-${{ matrix.arch.name }}
|
||||
path: target/${{ matrix.arch.target }}/release/tuigreet-dev-${{ matrix.arch.name }}
|
||||
|
74
.github/workflows/release.yml
vendored
74
.github/workflows/release.yml
vendored
@ -9,52 +9,52 @@ jobs:
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref }}
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Lint
|
||||
run: |
|
||||
cargo clippy
|
||||
cargo clippy --release
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test
|
||||
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- { name: 'x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false }
|
||||
- { name: 'i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true }
|
||||
- { name: 'armv7h', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true }
|
||||
- { name: 'aarch64', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true }
|
||||
- {
|
||||
name: "x86_64",
|
||||
os: "ubuntu-latest",
|
||||
target: "x86_64-unknown-linux-gnu",
|
||||
cross: false,
|
||||
}
|
||||
runs-on: ${{ matrix.arch.os }}
|
||||
steps:
|
||||
- name: Get the version
|
||||
id: version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref }}
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: target/
|
||||
key: cargo-cache-${{ matrix.arch.target }}
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
shared-key: cargo-cache-${{ matrix.arch.target }}
|
||||
- run: rm -rf .git/
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target=${{ matrix.arch.target }}
|
||||
use-cross: ${{ matrix.arch.cross }}
|
||||
run: |
|
||||
cargo build --release --target=${{ matrix.arch.target }}
|
||||
- name: Rename artifact
|
||||
run: mv target/${{ matrix.arch.target }}/release/tuigreet target/${{ matrix.arch.target }}/release/tuigreet-${{ steps.version.outputs.VERSION }}-${{ matrix.arch.name }}
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: tuigreet-${{ steps.version.outputs.VERSION }}-${{ matrix.arch.name }}
|
||||
path: target/${{ matrix.arch.target }}/release/tuigreet-${{ steps.version.outputs.VERSION }}-${{ matrix.arch.name }}
|
||||
@ -78,10 +78,12 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- { name: 'x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false }
|
||||
- { name: 'i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true }
|
||||
- { name: 'armv7h', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true }
|
||||
- { name: 'aarch64', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true }
|
||||
- {
|
||||
name: "x86_64",
|
||||
os: "ubuntu-latest",
|
||||
target: "x86_64-unknown-linux-gnu",
|
||||
cross: false,
|
||||
}
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
steps:
|
||||
@ -89,12 +91,12 @@ jobs:
|
||||
id: version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: target/out
|
||||
- name: Get Release
|
||||
id: get_release
|
||||
uses: bruceadams/get-release@v1.2.0
|
||||
uses: bruceadams/get-release@v1.3.2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Upload artifacts
|
||||
|
66
.github/workflows/tip.yml
vendored
66
.github/workflows/tip.yml
vendored
@ -7,60 +7,64 @@ on:
|
||||
|
||||
jobs:
|
||||
clippy:
|
||||
if: "!contains(github.event.head_commit.message, 'skip ci')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Lint
|
||||
run: |
|
||||
cargo clippy
|
||||
cargo clippy --release
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test
|
||||
|
||||
build:
|
||||
if: "!contains(github.event.head_commit.message, 'skip ci')"
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- { name: 'x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false }
|
||||
- { name: 'i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true }
|
||||
- { name: 'armv7h', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true }
|
||||
- { name: 'aarch64', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true }
|
||||
- {
|
||||
name: "x86_64",
|
||||
os: "ubuntu-latest",
|
||||
target: "x86_64-unknown-linux-gnu",
|
||||
cross: false,
|
||||
}
|
||||
runs-on: ${{ matrix.arch.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: target/
|
||||
key: cargo-cache-${{ matrix.arch.target }}
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
shared-key: cargo-cache-${{ matrix.arch.target }}
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target=${{ matrix.arch.target }}
|
||||
use-cross: ${{ matrix.arch.cross }}
|
||||
run: |
|
||||
cargo build --release --target=${{ matrix.arch.target }}
|
||||
- name: Rename artifact
|
||||
run: mv target/${{ matrix.arch.target }}/release/tuigreet target/${{ matrix.arch.target }}/release/tuigreet-tip-${{ matrix.arch.name }}
|
||||
run: mv target/${{ matrix.arch.target }}/release/tuigreet target/${{ matrix.arch.target }}/release/tuigreet-dev-${{ matrix.arch.name }}
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: tuigreet-tip-${{ matrix.arch.name }}
|
||||
path: target/${{ matrix.arch.target }}/release/tuigreet-tip-${{ matrix.arch.name }}
|
||||
name: tuigreet-dev-${{ matrix.arch.name }}
|
||||
path: target/${{ matrix.arch.target }}/release/tuigreet-dev-${{ matrix.arch.name }}
|
||||
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: target/out
|
||||
- name: Create release
|
||||
uses: eine/tip@tip
|
||||
uses: pyTooling/Actions/releaser@r0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: target/out/*/*
|
||||
|
@ -69,6 +69,25 @@ pub enum Mode {
|
||||
Processing,
|
||||
}
|
||||
|
||||
// This enum models how secret values should be displayed on terminal.
|
||||
#[derive(SmartDefault, Debug, Copy, Clone)]
|
||||
pub enum SecretDisplay {
|
||||
#[default]
|
||||
// All characters hidden.
|
||||
Hidden,
|
||||
// All characters are replaced by a placeholder character.
|
||||
Character(char),
|
||||
}
|
||||
|
||||
impl SecretDisplay {
|
||||
pub fn show(&self) -> bool {
|
||||
match self {
|
||||
SecretDisplay::Hidden => false,
|
||||
SecretDisplay::Character(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Greeter {
|
||||
#[default(DEFAULT_LOCALE)]
|
||||
@ -108,13 +127,11 @@ pub struct Greeter {
|
||||
pub username_mask: Option<String>,
|
||||
// Prompt that should be displayed to ask for entry.
|
||||
pub prompt: Option<String>,
|
||||
|
||||
// Whether the current edition prompt should be hidden.
|
||||
pub secret: bool,
|
||||
// Whether to display replacement characters for secret entries.
|
||||
pub asterisks: bool,
|
||||
// Which character to use for secret entries.
|
||||
#[default(DEFAULT_ASTERISKS_CHAR)]
|
||||
pub asterisks_char: char,
|
||||
pub asking_for_secret: bool,
|
||||
// How should secrets be displayed?
|
||||
pub secret_display: SecretDisplay,
|
||||
|
||||
// Whether last logged-in user should be remembered.
|
||||
pub remember: bool,
|
||||
@ -399,14 +416,20 @@ impl Greeter {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
if let Some(value) = self.config().opt_str("asterisks-char") {
|
||||
if value.chars().count() != 1 {
|
||||
eprintln!("--asterisks-char can only have one single character as its value");
|
||||
print_usage(opts);
|
||||
process::exit(1);
|
||||
}
|
||||
if self.config().opt_present("asterisks") {
|
||||
let asterisk = if let Some(value) = self.config().opt_str("asterisks-char") {
|
||||
if value.chars().count() != 1 {
|
||||
eprintln!("--asterisks-char can only have one single character as its value");
|
||||
print_usage(opts);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
self.asterisks_char = value.chars().next().unwrap();
|
||||
value.chars().next().unwrap()
|
||||
} else {
|
||||
DEFAULT_ASTERISKS_CHAR
|
||||
};
|
||||
|
||||
self.secret_display = SecretDisplay::Character(asterisk);
|
||||
}
|
||||
|
||||
if let Some(format) = self.config().opt_str("time-format") {
|
||||
@ -449,7 +472,6 @@ impl Greeter {
|
||||
self.remember = self.config().opt_present("remember");
|
||||
self.remember_session = self.config().opt_present("remember-session");
|
||||
self.remember_user_session = self.config().opt_present("remember-user-session");
|
||||
self.asterisks = self.config().opt_present("asterisks");
|
||||
self.greeting = self.option("greeting");
|
||||
|
||||
// If the `--cmd` argument is provided, it will override the selected session.
|
||||
|
@ -70,14 +70,14 @@ impl Ipc {
|
||||
AuthMessageType::Secret => {
|
||||
greeter.mode = Mode::Password;
|
||||
greeter.working = false;
|
||||
greeter.secret = true;
|
||||
greeter.asking_for_secret = true;
|
||||
greeter.set_prompt(&auth_message);
|
||||
}
|
||||
|
||||
AuthMessageType::Visible => {
|
||||
greeter.mode = Mode::Password;
|
||||
greeter.working = false;
|
||||
greeter.secret = false;
|
||||
greeter.asking_for_secret = false;
|
||||
greeter.set_prompt(&auth_message);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use tui::{
|
||||
use crate::{
|
||||
info::get_hostname,
|
||||
ui::{prompt_value, util::*, Frame},
|
||||
Greeter, Mode,
|
||||
Greeter, Mode, SecretDisplay,
|
||||
};
|
||||
|
||||
const GREETING_INDEX: usize = 0;
|
||||
@ -90,11 +90,10 @@ pub fn draw(greeter: &mut Greeter, f: &mut Frame) -> Result<(u16, u16), Box<dyn
|
||||
if greeter.mode == Mode::Password || greeter.previous_mode == Mode::Password {
|
||||
f.render_widget(answer_label, chunks[ANSWER_INDEX]);
|
||||
|
||||
if !greeter.secret || greeter.asterisks {
|
||||
let value = if greeter.secret && greeter.asterisks {
|
||||
greeter.asterisks_char.to_string().repeat(greeter.buffer.chars().count())
|
||||
} else {
|
||||
greeter.buffer.clone()
|
||||
if !greeter.asking_for_secret || greeter.secret_display.show() {
|
||||
let value = match (greeter.asking_for_secret, greeter.secret_display) {
|
||||
(true, SecretDisplay::Character(asterisk)) => asterisk.to_string().repeat(greeter.buffer.chars().count()),
|
||||
_ => greeter.buffer.clone(),
|
||||
};
|
||||
|
||||
let answer_value_text = Span::from(value);
|
||||
@ -135,7 +134,7 @@ pub fn draw(greeter: &mut Greeter, f: &mut Frame) -> Result<(u16, u16), Box<dyn
|
||||
let answer_length = greeter.buffer.chars().count();
|
||||
let offset = get_cursor_offset(greeter, answer_length);
|
||||
|
||||
if greeter.secret && !greeter.asterisks {
|
||||
if greeter.asking_for_secret && !greeter.secret_display.show() {
|
||||
Ok((1 + cursor.x + greeter.prompt_width() as u16, ANSWER_INDEX as u16 + prompt_padding + cursor.y))
|
||||
} else {
|
||||
Ok((1 + cursor.x + greeter.prompt_width() as u16 + offset as u16, ANSWER_INDEX as u16 + prompt_padding + cursor.y))
|
||||
|
Loading…
Reference in New Issue
Block a user