Windows automagical buildingtons (#798)

* windows build automation
* making fmt happy, fixing windows-related bug
* disabled cargo_incremental when using `sccache`, added build options ARG to Dockerfile, limit docker build to one job
This commit is contained in:
James Hodgkinson 2022-05-31 14:13:21 +10:00 committed by GitHub
parent 48e0fd7d21
commit 7d27612174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 10 deletions

View file

@ -35,7 +35,7 @@ jobs:
default: true default: true
components: cargo components: cargo
- name: Run cargo test - name: Run cargo test
run: cargo test --workspace run: cargo test -j1
kanidm_build: kanidm_build:
needs: test needs: test
@ -70,6 +70,7 @@ jobs:
build-args: | build-args: |
"KANIDM_BUILD_PROFILE=developer" "KANIDM_BUILD_PROFILE=developer"
"KANIDM_FEATURES=" "KANIDM_FEATURES="
"KANIDM_BUILD_OPTIONS=-j1"
file: kanidmd/Dockerfile file: kanidmd/Dockerfile
radius_build: radius_build:
needs: test needs: test

50
.github/workflows/windows_build.yml vendored Normal file
View file

@ -0,0 +1,50 @@
---
name: Windows Build and Test
# at the moment this only builds the kanidm client
# because @yaleman got tired but it's enough to prove
# it builds and be able to administer Kanidm from
# Windows-land
"on":
push:
jobs:
windows_build_kanidm:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: ensure openssl and vcpkg is good
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows-static-md
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
components: cargo
- name: build
uses: actions-rs/cargo@v1
with:
command: build
args: --release -p kanidm_client -p kanidm_tools -p orca
windows_test_kanidm:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: ensure openssl and vcpkg is good
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows-static-md
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
components: cargo
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -p kanidm_client -p kanidm_tools -p orca

View file

@ -14,6 +14,8 @@ Kanidm currently supports the following Linux distributions:
* Fedora 34/35 * Fedora 34/35
* CentOS Stream 9 * CentOS Stream 9
The `kanidm` client has been built and tested from Windows, but is not (yet) packaged routinely.
### OpenSUSE Tumbleweed ### OpenSUSE Tumbleweed
Kanidm has been part of OpenSUSE Tumbleweed since October 2020. You can install Kanidm has been part of OpenSUSE Tumbleweed since October 2020. You can install

View file

@ -18,11 +18,13 @@ use serde::de::DeserializeOwned;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use serde_json::error::Error as SerdeJsonError; use serde_json::error::Error as SerdeJsonError;
use std::fs::{metadata, File, Metadata}; use std::fs::File;
#[cfg(target_family = "unix")] // not needed for windows builds
use std::fs::{metadata, Metadata};
use std::io::ErrorKind; use std::io::ErrorKind;
use std::io::Read; use std::io::Read;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")] // not needed for windows builds
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -89,6 +91,7 @@ pub struct KanidmClient {
pub(crate) auth_session_id: RwLock<Option<String>>, pub(crate) auth_session_id: RwLock<Option<String>>,
} }
#[cfg(target_family = "unix")]
fn read_file_metadata<P: AsRef<Path>>(path: &P) -> Result<Metadata, ()> { fn read_file_metadata<P: AsRef<Path>>(path: &P) -> Result<Metadata, ()> {
metadata(path).map_err(|e| { metadata(path).map_err(|e| {
error!( error!(

View file

@ -25,6 +25,7 @@ WORKDIR /usr/src/kanidm/kanidmd/daemon
ARG SCCACHE_REDIS="" ARG SCCACHE_REDIS=""
ARG KANIDM_FEATURES ARG KANIDM_FEATURES
ARG KANIDM_BUILD_PROFILE ARG KANIDM_BUILD_PROFILE
ARG KANIDM_BUILD_OPTIONS=""
RUN mkdir /scratch RUN mkdir /scratch
RUN echo $KANIDM_BUILD_PROFILE RUN echo $KANIDM_BUILD_PROFILE
@ -36,12 +37,13 @@ ENV CARGO_HOME=/scratch/.cargo
RUN if [ "${SCCACHE_REDIS}" != "" ]; \ RUN if [ "${SCCACHE_REDIS}" != "" ]; \
then \ then \
export CC="/usr/bin/sccache /usr/bin/clang" && \ export CC="/usr/bin/sccache /usr/bin/clang" && \
export CARGO_INCREMENTAL=false && \
export RUSTC_WRAPPER=sccache && \ export RUSTC_WRAPPER=sccache && \
sccache --start-server; \ sccache --start-server; \
else \ else \
export CC="/usr/bin/clang"; \ export CC="/usr/bin/clang"; \
fi && \ fi && \
cargo build \ cargo build ${KANIDM_BUILD_OPTIONS} \
--features=${KANIDM_FEATURES} \ --features=${KANIDM_FEATURES} \
--target-dir=/usr/src/kanidm/target/ \ --target-dir=/usr/src/kanidm/target/ \
--release && \ --release && \

View file

@ -22,10 +22,12 @@ score = { path = "../score" }
structopt = { version = "^0.3.26", default-features = false } structopt = { version = "^0.3.26", default-features = false }
users = "^0.11.0" users = "^0.11.0"
serde = { version = "^1.0.137", features = ["derive"] } serde = { version = "^1.0.137", features = ["derive"] }
tikv-jemallocator = "0.5.0"
tokio = { version = "^1.18.0", features = ["rt-multi-thread", "macros", "signal"] } tokio = { version = "^1.18.0", features = ["rt-multi-thread", "macros", "signal"] }
toml = "0.5.9" toml = "0.5.9"
[target.'cfg(not(target_family = "windows"))'.dependencies]
tikv-jemallocator = "0.5"
[build-dependencies] [build-dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
structopt = { version = "0.3", default-features = false } structopt = { version = "0.3", default-features = false }

View file

@ -10,6 +10,7 @@
#![deny(clippy::needless_pass_by_value)] #![deny(clippy::needless_pass_by_value)]
#![deny(clippy::trivially_copy_pass_by_ref)] #![deny(clippy::trivially_copy_pass_by_ref)]
#[cfg(not(target_family = "windows"))]
#[global_allocator] #[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

View file

@ -14,7 +14,7 @@
#![deny(clippy::needless_pass_by_value)] #![deny(clippy::needless_pass_by_value)]
#![deny(clippy::trivially_copy_pass_by_ref)] #![deny(clippy::trivially_copy_pass_by_ref)]
#[cfg(all(jemallocator, test))] #[cfg(all(jemallocator, test, not(target_family = "windows")))]
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

View file

@ -11,8 +11,8 @@ use kanidm::prelude::*;
use kanidm::status::StatusActor; use kanidm::status::StatusActor;
use serde::Serialize; use serde::Serialize;
use std::path::PathBuf;
use std::fs::canonicalize; use std::fs::canonicalize;
use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use uuid::Uuid; use uuid::Uuid;
@ -366,7 +366,6 @@ pub fn create_https_server(
qe_w_ref: &'static QueryServerWriteV1, qe_w_ref: &'static QueryServerWriteV1,
qe_r_ref: &'static QueryServerReadV1, qe_r_ref: &'static QueryServerReadV1,
) -> Result<(), ()> { ) -> Result<(), ()> {
let jws_validator = jws_signer.get_validator().map_err(|e| { let jws_validator = jws_signer.get_validator().map_err(|e| {
error!(?e, "Failed to get jws validator"); error!(?e, "Failed to get jws validator");
})?; })?;
@ -401,7 +400,6 @@ pub fn create_https_server(
// If we are no-ui, we remove this. // If we are no-ui, we remove this.
if !matches!(role, ServerRole::WriteReplicaNoUI) { if !matches!(role, ServerRole::WriteReplicaNoUI) {
let pkg_path = PathBuf::from(env!("KANIDM_WEB_UI_PKG_PATH")); let pkg_path = PathBuf::from(env!("KANIDM_WEB_UI_PKG_PATH"));
if !pkg_path.exists() { if !pkg_path.exists() {
eprintln!( eprintln!(

View file

@ -15,7 +15,7 @@ name = "orca"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
tikv-jemallocator = "0.5.0"
tracing = "^0.1.34" tracing = "^0.1.34"
tracing-subscriber = "^0.3.11" tracing-subscriber = "^0.3.11"
@ -46,5 +46,9 @@ mathru = "^0.12.0"
dialoguer = "0.10.1" dialoguer = "0.10.1"
[target.'cfg(not(target_family = "windows"))'.dependencies]
tikv-jemallocator = "0.5"
[build-dependencies] [build-dependencies]
profiles = { path = "../profiles" } profiles = { path = "../profiles" }

View file

@ -8,6 +8,7 @@
#![deny(clippy::needless_pass_by_value)] #![deny(clippy::needless_pass_by_value)]
#![deny(clippy::trivially_copy_pass_by_ref)] #![deny(clippy::trivially_copy_pass_by_ref)]
#[cfg(not(target_family = "windows"))]
#[global_allocator] #[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;