Compare commits
12 Commits
9be4aedcab
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f0a90a4882 | |||
| d4dc0cbbf7 | |||
| 86f2518b6e | |||
| 1d7e9fe22b | |||
| e4eb26ae5f | |||
| 2dbdc149a2 | |||
| 986ad8f457 | |||
| 2e9b685789 | |||
| 6bc4bd18d7 | |||
| e753fb4d74 | |||
| f51e831c47 | |||
| d0d9af1a56 |
@@ -7,7 +7,8 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: rust:latest
|
image: gitea.tobiasmaier.me/tobimai/devcontainer-rust:2.2
|
||||||
|
options: --user root
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@@ -24,14 +25,10 @@ jobs:
|
|||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install necessary dependencies
|
|
||||||
run: apt update && apt install nodejs pkg-config -y
|
|
||||||
- name: Install docker
|
|
||||||
run: curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
|
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Run migrations
|
- name: Run migrations
|
||||||
run: cargo install sqlx-cli && sqlx migrate run
|
run: sqlx migrate run
|
||||||
- name: Build server binary
|
- name: Build server binary
|
||||||
run: cargo build --release
|
run: cargo build --release
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: rust:latest
|
image: gitea.tobiasmaier.me/tobimai/devcontainer-rust:2.2
|
||||||
|
options: --user root
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@@ -23,12 +24,10 @@ jobs:
|
|||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install necessary dependencies
|
|
||||||
run: apt update && apt install nodejs pkg-config -y
|
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Run migrations
|
- name: Run migrations
|
||||||
run: cargo install sqlx-cli && sqlx migrate run
|
run: sqlx migrate run
|
||||||
- name: Running cargo build
|
- name: Running cargo build
|
||||||
run: cargo build --release
|
run: cargo build --release
|
||||||
- name: Running cargo build
|
- name: Running cargo build
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ async fn serve_firmware(
|
|||||||
) -> impl Responder {
|
) -> impl Responder {
|
||||||
let (service, product, config, version) = path.into_inner();
|
let (service, product, config, version) = path.into_inner();
|
||||||
let version = version.replace(['.', '_'], "-");
|
let version = version.replace(['.', '_'], "-");
|
||||||
|
let service = service.to_lowercase();
|
||||||
|
let config = config.to_lowercase();
|
||||||
let Ok(service) = Services::from_str(&service) else {
|
let Ok(service) = Services::from_str(&service) else {
|
||||||
return HttpResponse::NotFound().finish();
|
return HttpResponse::NotFound().finish();
|
||||||
};
|
};
|
||||||
@@ -101,7 +103,7 @@ async fn serve_firmware(
|
|||||||
Services::Firmware => PathBuf::from(format!("{product}/firmware_{config}_{version}.bin")),
|
Services::Firmware => PathBuf::from(format!("{product}/firmware_{config}_{version}.bin")),
|
||||||
Services::Filesystem => PathBuf::from(format!("{product}/filesystem_{config}_{version}.bin")),
|
Services::Filesystem => PathBuf::from(format!("{product}/filesystem_{config}_{version}.bin")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let file_path = fw_root_path.join(&file_path);
|
let file_path = fw_root_path.join(&file_path);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ pub enum BoardType {
|
|||||||
pub enum BoardConfig {
|
pub enum BoardConfig {
|
||||||
INA226,
|
INA226,
|
||||||
INA233,
|
INA233,
|
||||||
|
INA226REV2,
|
||||||
|
INA233REV2,
|
||||||
Generic,
|
Generic,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/util.rs
11
src/util.rs
@@ -1,6 +1,6 @@
|
|||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{debug, error, info};
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@@ -72,11 +72,18 @@ pub fn get_files(
|
|||||||
.strip_suffix(".bin")
|
.strip_suffix(".bin")
|
||||||
.ok_or(GetFilesError::Extension)?
|
.ok_or(GetFilesError::Extension)?
|
||||||
.replace('-', ".");
|
.replace('-', ".");
|
||||||
|
debug!("Version: {:?}", version);
|
||||||
|
debug!("split_name: {:?}", split_name);
|
||||||
// TODO this is kinda messy
|
// TODO this is kinda messy
|
||||||
let board_config = BoardConfig::from_str(split_name[1])?;
|
let board_config = BoardConfig::from_str(split_name[1])?;
|
||||||
let service = split_name[0];
|
let service = split_name[0];
|
||||||
let board_type = BoardType::from_str(&product_name).unwrap();
|
let board_type = BoardType::from_str(&product_name).unwrap();
|
||||||
let version = Version::parse(&version)?;
|
let version = if version.contains('.') {
|
||||||
|
Version::parse(&version)?
|
||||||
|
} else {
|
||||||
|
// Handle simple version number by adding .0.0
|
||||||
|
Version::parse(&format!("{}.0.0", version))?
|
||||||
|
};
|
||||||
let version_replaced = format!("{}-{}-{}", version.major, version.minor, version.patch);
|
let version_replaced = format!("{}-{}-{}", version.major, version.minor, version.patch);
|
||||||
let fw_url =
|
let fw_url =
|
||||||
format!("{hostname}/{service}/{board_type}/{board_config}/{version_replaced}.bin");
|
format!("{hostname}/{service}/{board_type}/{board_config}/{version_replaced}.bin");
|
||||||
|
|||||||
Reference in New Issue
Block a user