#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Error {
GitHubActionsMacOs,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::GitHubActionsMacOs => {
write!(
f,
"GitHub Actions on macOS does not support Docker. Container runtime is not available."
)
}
}
}
}
impl std::error::Error for Error {}
pub fn support() -> Result<(), Error> {
if std::env::consts::OS == "macos" && std::env::var("GITHUB_ACTIONS").is_ok() {
Err(Error::GitHubActionsMacOs)
} else {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_platform_support_consistency() {
let expected = if std::env::consts::OS == "macos" && std::env::var("GITHUB_ACTIONS").is_ok()
{
Err(Error::GitHubActionsMacOs)
} else {
Ok(())
};
assert_eq!(support(), expected);
}
}