Skip to content

Commit

Permalink
adds rust checks
Browse files Browse the repository at this point in the history
  • Loading branch information
reederc42 committed Apr 3, 2024
1 parent 798d47f commit f56595b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ jobs:

container:
image: rust:1.77.0
user: 1000:1000
volumes:
- /var/run/docker.sock
env:
BUILD_ID: ${{ github.job }}-${{ github.run_id }}
HOST_WORKDIR: ${{ github.workspace }}

steps:
- uses: actions/checkout@v4
Expand All @@ -88,4 +90,5 @@ jobs:
apt-get install -y docker-ce-cli
- name: Run CI
run: cargo run --bin ci -- --all
run:
cargo run --bin ci -- --all;
6 changes: 5 additions & 1 deletion ci/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn cmd(args: Cli) {
let all_stages: Vec<Box<dyn Stage>> = vec![
Box::new(stages::build_images::BuildImages{}),
Box::new(stages::nodejs_checks::NodeJSChecks{}),
Box::new(stages::rust_checks::RustChecks{}),
];

if args.list {
Expand All @@ -42,7 +43,9 @@ pub fn cmd(args: Cli) {

let context = Rc::new(Context {
id: std::env::var("BUILD_ID").unwrap_or(String::from("local")),
cwd: String::from(std::env::current_dir().unwrap().to_str().unwrap()),
cwd: std::env::var("HOST_WORKDIR").unwrap_or(
String::from(std::env::current_dir().unwrap().to_str().unwrap())
),
});
let docker = Rc::new(Docker{
context: context.clone(),
Expand Down Expand Up @@ -131,6 +134,7 @@ impl Runner for Docker {
let cmd = Command::new("docker")
.args([
"run",
"--rm",
"-v",
&format!("{}:{}", self.context.cwd, self.context.cwd),
"-w",
Expand Down
1 change: 1 addition & 0 deletions ci/src/stages.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod build_images;
pub mod nodejs_checks;
pub mod rust_checks;
2 changes: 2 additions & 0 deletions ci/src/stages/nodejs_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ impl Stage for NodeJSChecks {
// run runs unit tests and linters for Node.js source
fn run(&self, _context: &Context, config: &Config) -> Error {
config.runner.run("build", r"
id
ls -lh
ln -s /ci/node_modules ./ui/node_modules || true
cd ui
npm run lint
Expand Down
17 changes: 17 additions & 0 deletions ci/src/stages/rust_checks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::*;

pub struct RustChecks {}

impl Stage for RustChecks {
fn name(&self) -> String {
String::from("rust_checks")
}

// run runs unit tests and linters for Rust
fn run(&self, _context: &Context, config: &Config) -> Error {
config.runner.run("build", r"
cargo clippy --all-targets --all-features
cargo test --all-targets --all-features
")
}
}
2 changes: 1 addition & 1 deletion images/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM node:${NODE_VERSION}
ARG NPM_VERSION="10.5.0"
ARG RUST_VERSION="1.77.0"

RUN npm install -g npm@${NPM_VERSION}
RUN npm install --verbose -g npm@${NPM_VERSION}

USER 1000:1000

Expand Down

0 comments on commit f56595b

Please sign in to comment.