Skip to content

Commit

Permalink
Run CI in a docker container (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-k-bo committed Aug 5, 2023
1 parent 8af48a0 commit ca59362
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .github/actions/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM rust:slim-bookworm

RUN apt-get update && apt-get install -y libclang-dev libopusenc-dev
RUN rustup component add clippy rustfmt

ENTRYPOINT ["sh", "-c"]
13 changes: 13 additions & 0 deletions .github/actions/container/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Run in Rust/Opusenc container
description: Executes a command in a container that has the rust toolchain and libopusenc installed

inputs:
run:
description: the command to run
required: true

runs:
using: docker
image: Dockerfile
args:
- ${{ inputs.run }}
22 changes: 8 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/container
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --all -- --check
run: cargo fmt --all -- --check

clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/container
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
- name: Install libopusenc
run: sudo apt install libopusenc-dev
- run: cargo clippy --all-features
- run: cargo clippy --no-default-features
run: cargo clippy --all-features && cargo clippy --no-default-features

test:
name: cargo test
runs-on: ubuntu-latest
container:
image: rust:bookworm
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/container
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
- name: Install libopusenc
run: sudo apt install libopusenc-dev
- run: cargo test
run: cargo test
27 changes: 27 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
branches:
- main
pull_request:

name: Build & Deploy API Reference

jobs:
doc:
name: cargo doc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/container
with:
run: cargo doc --workspace --no-deps
- name: Make docs directory writable
run: sudo chmod -R 777 ./target/doc
- name: Create redirect to opusenc crate docs
run: echo "<meta http-equiv=\"refresh\" content=\"0; url=build_wheel\">" > target/doc/index.html
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::{
fmt::Display,
};

use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive, TryFromPrimitiveError};
use num_enum::{FromPrimitive, IntoPrimitive};
#[cfg(feature = "encoder-options")]
use num_enum::{TryFromPrimitive, TryFromPrimitiveError};

pub type Result<T> = std::result::Result<T, Error>;

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//! # Example
//!
//! ```
//! # use std::io::Read;//!
//! # use opusenc::{Comments, Encoder, MappingFamily, RecommendedTag};//!
//! # use std::io::Read;
//! # use opusenc::{Comments, Encoder, MappingFamily, RecommendedTag};
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let audio_data: Vec<i16> = {
//! let mut file = std::fs::File::open("/dev/urandom")?;
Expand Down

0 comments on commit ca59362

Please sign in to comment.