Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axum = { version = "0.8", features = ["macros"] }
axum = { version = "0.8", features = ["macros", "query"] }
axum-extra = { version = "0.10", features = ["typed-header"] }
axum-server = { version = "0.7", features = ["tls-rustls"] }
askama = "0.13"
chrono = { version = "0.4.38", features = ["clock"] }
dotenvy = "0.15"
octocrab = "0.44"
octocrab = { version = "0.46", features = ["stream"] }
regex = "1"
semver = "1"
lenient_semver = "0.4"
Expand All @@ -36,8 +36,10 @@ bson = { version = "2", features = ["chrono-0_4"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sequoia-openpgp = "2.0.0"
futures-util = "0.3"

[dev-dependencies]
axum-test = "18"
insta = { version = "1", features = ["filters"] }
testcontainers-modules = { version = "0.11", features = ["mongo"] }

Expand Down
5 changes: 0 additions & 5 deletions infratest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ version = "0.1.0"
edition = "2024"

[dependencies]
bollard = "0.19"
tokio = { version = "1.0", features = ["full"] }
futures-util = "0.3"
anyhow = "1.0"
reqwest = { version = "0.12", features = ["stream", "rustls-tls"] }
tar = "0.4"
testcontainers-modules = { version = "0.13", features = ["mongo"] }
pretty_env_logger = "0.4"
testcontainers = { git = "https://github.com/mominul/testcontainers-rs.git", branch = "platform_config", features = ["http_wait"] }

[patch.crates-io]
testcontainers = { git = "https://github.com/mominul/testcontainers-rs.git", branch = "platform_config" }
54 changes: 54 additions & 0 deletions infratest/scripts/check_apt_pre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

apt update
apt install sudo wget -y

echo
echo "Running the package key and repository setup script"

wget -qO- http://localhost:3000/sh/ubuntu/github/mominul/pack-exp-pre?prerelease=true | sh
return_value=$?

if [ $return_value -ne 0 ]; then
echo "The script failed with exit code $return_value"
# Handle error case here
exit $return_value
else
echo "Package key and repository setup script ran successfully."
fi

output=$(apt search openbangla 2>&1)
status=$?

# Print the output of the apt command
echo "$output"

# Check if the apt command was successful
if [ $status -ne 0 ]; then
echo "Error: apt search command failed." >&2
exit $status
fi

if echo "$output" | grep -q "openbangla-keyboard"; then
echo
echo "Package found successfully."
else
echo "Error: package not found." >&2
exit 1
fi

# check if apt can install the package
apt_out=$(apt install openbangla-keyboard -y 2>&1)
apt_status=$?

# Print the output of the apt command
echo "$apt_out"

# Check if the apt command was successful
if [ $apt_status -ne 0 ]; then
echo "Error: apt install command failed." >&2
exit $apt_status
fi

echo "Package installed successfully."
exit 0
53 changes: 53 additions & 0 deletions infratest/scripts/check_dnf_pre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

yes | dnf install wget sudo

echo
echo "Running the package key and repository setup script"

wget -qO- http://localhost:3000/sh/yum/github/mominul/pack-exp-pre?prerelease=true | sh
return_value=$?

if [ $return_value -ne 0 ]; then
echo "The script failed with exit code $return_value"
# Handle error case here
exit $return_value
else
echo "Package key and repository setup script ran successfully."
fi

output=$(yes | dnf search openbangla 2>&1)
status=$?

# Print the output of the dnf command
echo "$output"

# Check if the dnf command was successful
if [ $status -ne 0 ]; then
echo "Error: dnf search command failed." >&2
exit $status
fi

if echo "$output" | grep -q "openbangla-keyboard"; then
echo
echo "Package found successfully."
else
echo "Error: package not found." >&2
exit 1
fi

# check if dnf can install the package
dnf_out=$(yes | dnf install openbangla-keyboard 2>&1)
dnf_status=$?

# Print the output of the dnf command
echo "$dnf_out"

# Check if the dnf command was successful
if [ $dnf_status -ne 0 ]; then
echo "Error: dnf install command failed." >&2
exit $dnf_status
fi

echo "Package installed successfully."
exit 0
53 changes: 53 additions & 0 deletions infratest/scripts/check_dnf_v1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

yes | dnf install wget sudo

echo
echo "Running the package key and repository setup script"

wget -qO- http://localhost:3000/sh/yum/github/mominul/pack-exp3?ver=v1 | sh
return_value=$?

if [ $return_value -ne 0 ]; then
echo "The script failed with exit code $return_value"
# Handle error case here
exit $return_value
else
echo "Package key and repository setup script ran successfully."
fi

output=$(yes | dnf search openbangla 2>&1)
status=$?

# Print the output of the dnf command
echo "$output"

# Check if the dnf command was successful
if [ $status -ne 0 ]; then
echo "Error: dnf search command failed." >&2
exit $status
fi

if echo "$output" | grep -q "openbangla-keyboard"; then
echo
echo "Package found successfully."
else
echo "Error: package not found." >&2
exit 1
fi

# check if dnf can install the package
dnf_out=$(yes | dnf install openbangla-keyboard 2>&1)
dnf_status=$?

# Print the output of the dnf command
echo "$dnf_out"

# Check if the dnf command was successful
if [ $dnf_status -ne 0 ]; then
echo "Error: dnf install command failed." >&2
exit $dnf_status
fi

echo "Package installed successfully."
exit 0
6 changes: 4 additions & 2 deletions infratest/src/infra.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use anyhow::{Result, bail};
use testcontainers::{ContainerAsync, GenericImage};
use testcontainers_modules::mongo::Mongo;
use testcontainers_modules::{
mongo::Mongo,
testcontainers::{ContainerAsync, GenericImage},
};
use tokio::task::{JoinHandle, JoinSet};

use crate::{
Expand Down
26 changes: 26 additions & 0 deletions infratest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ async fn main() -> Result<()> {
None,
));

// Pre-release support tests
infra.add_distro(Distro::new(
"pre-release-pkg",
"ubuntu",
"25.04",
"check_apt_pre.sh",
None,
));

infra.add_distro(Distro::new(
"pre-release-pkg",
"fedora",
"42",
"check_dnf_pre.sh",
None,
));

// Test rpm v1 support
infra.add_distro(Distro::new(
"v1-rpm",
"fedora",
"42",
"check_dnf_v1.sh",
None,
));

infra.run_distros().await?;

Ok(())
Expand Down
25 changes: 12 additions & 13 deletions src/apt/index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, io::Write};
use std::{collections::BTreeMap, io::Write};

use anyhow::Result;
use askama::Template;
Expand All @@ -11,20 +11,20 @@ use sha2::{Sha256, Sha512};
use crate::{
apt::deb::DebianPackage,
package::Package,
utils::{Arch, hashsum},
utils::{Arch, ReleaseChannel, hashsum},
};

#[derive(Debug)]
pub struct AptIndices {
packages: HashMap<Arch, Vec<DebianPackage>>,
packages: BTreeMap<Arch, Vec<DebianPackage>>,
date: DateTime<Utc>,
}

#[derive(Template)]
#[template(path = "Release")]
struct ReleaseIndex<'a> {
origin: &'a str,
label: &'a str,
channel: &'a ReleaseChannel,
arch: Vec<String>,
date: String,
files: Vec<Files>,
}
Expand All @@ -46,7 +46,7 @@ struct Files {

impl AptIndices {
pub fn new(packages: &[Package]) -> Result<AptIndices> {
let mut debian: HashMap<Arch, Vec<DebianPackage>> = HashMap::new();
let mut debian: BTreeMap<Arch, Vec<DebianPackage>> = BTreeMap::new();
// Find the latest date from the list of packages
let mut date = DateTime::UNIX_EPOCH;
for package in packages {
Expand Down Expand Up @@ -85,8 +85,7 @@ impl AptIndices {
index.render().unwrap().trim().to_owned()
}

pub fn get_release_index(&self) -> String {
let name = ". stable";
pub fn get_release_index(&self, channel: &ReleaseChannel) -> String {
let date = self.date.to_rfc2822();

let mut files = vec![];
Expand Down Expand Up @@ -122,8 +121,8 @@ impl AptIndices {
let index = ReleaseIndex {
date,
files,
origin: name,
label: name,
channel,
arch: self.packages.keys().map(|s| s.to_string()).collect(),
};

index.render().unwrap()
Expand Down Expand Up @@ -166,7 +165,7 @@ mod tests {
assert_snapshot!(packages);

// Release
let release = indices.get_release_index();
let release = indices.get_release_index(&ReleaseChannel::Stable);
assert_snapshot!(release);
}

Expand All @@ -192,7 +191,7 @@ mod tests {
assert_eq!(packages_gz.len(), 1105);

// Release
let release = indices.get_release_index();
let release = indices.get_release_index(&ReleaseChannel::Stable);
assert_snapshot!(release);
}

Expand Down Expand Up @@ -233,7 +232,7 @@ mod tests {
let indices = AptIndices::new(&packages).unwrap();

// Release
let release = indices.get_release_index();
let release = indices.get_release_index(&ReleaseChannel::Stable);
assert_snapshot!(release);
}
}
Loading
Loading