Skip to content

Commit

Permalink
ci(actions): add ci action
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenira committed Oct 28, 2023
1 parent c723075 commit 6143689
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 7 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

on:
push:
pull_request:
- master

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
protobuf-compiler
- name: Build
run: cargo build --locked -v
- name: Upload
uses: actions/upload-artifact@v3
with:
name: daktilo-nvim-debug
path: target/debug/libdaktilo_nvim*

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
protobuf-compiler
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Generate code coverage
run: cargo llvm-cov --lcov --output-path lcov.info
env:
OUT_DIR: target
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: Check typos
uses: crate-ci/typos@master
- name: Validate commit messages
run: |
git show-ref
curl -sSfL https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip | zcat > convco
chmod +x convco
./convco check ${{ github.event.workflow_run.head_sha }}..${{ github.event.pull_request.head.sha }}
rm convco
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
protobuf-compiler
- name: Check code formatting
run: cargo fmt --all -- --check
- name: Check lints
run: cargo clippy -- -D warnings
- name: Run cargo-audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run msrv
shell: bash
run: |
curl -s 'https://api.github.com/repos/foresterre/cargo-msrv/releases' | \
jq -r "[.[] | select(.prerelease == false)][0].assets[] | \
select(.name | ascii_downcase | test(\"linux.*x86_64|x86_64.*linux\")).browser_download_url" | \
wget -qi -
tar -xvf cargo-msrv*.tar* -C ~/.cargo/bin/ cargo-msrv
printf "%s" "Checking MSRV..."
cargo msrv --output-format json verify | tail -n 1 | jq --exit-status '.success'
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "GPL-3.0"

[lib]
crate-type = ["cdylib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl BufInfo {
}

fn start(config: Config) -> oxi::Result<()> {
let (sender, reciever) = unbounded_channel::<BufInfo>();
let (message_sender, mut message_reciever) = unbounded_channel::<MessageEvent>();
let (sender, receiver) = unbounded_channel::<BufInfo>();
let (message_sender, mut message_receiver) = unbounded_channel::<MessageEvent>();

api::create_autocmd(
["CursorMovedI"],
Expand All @@ -83,7 +83,7 @@ fn start(config: Config) -> oxi::Result<()> {
)?;

let handle = AsyncHandle::new(move || {
let message = message_reciever.blocking_recv().unwrap();
let message = message_receiver.blocking_recv().unwrap();
oxi::schedule(move |_| {
if message.err {
api::err_writeln(message.message.as_str());
Expand All @@ -97,7 +97,7 @@ fn start(config: Config) -> oxi::Result<()> {
})?;

std::thread::spawn(move || {
start_grpc_client(config.rpc_port, reciever, message_sender, handle)
start_grpc_client(config.rpc_port, receiver, message_sender, handle)
});

Ok(())
Expand All @@ -106,7 +106,7 @@ fn start(config: Config) -> oxi::Result<()> {
#[tokio::main]
async fn start_grpc_client(
port: u16,
mut reciever: UnboundedReceiver<BufInfo>,
mut receiver: UnboundedReceiver<BufInfo>,
message_sender: UnboundedSender<MessageEvent>,
message_handle: AsyncHandle,
) {
Expand All @@ -128,7 +128,7 @@ async fn start_grpc_client(
message_sender.send("Client connected".into()).unwrap();
message_handle.send().unwrap();

while let Some(buf_info) = reciever.recv().await {
while let Some(buf_info) = receiver.recv().await {
let request: ReportCursorMovementRequest = buf_info.into();
let _ = client.report_cursor_movement(request).await.unwrap();
}
Expand Down

0 comments on commit 6143689

Please sign in to comment.