From eead47aec822695f2b4322afc2e660f3239f6d19 Mon Sep 17 00:00:00 2001 From: James Hodgkinson Date: Mon, 16 Oct 2023 15:15:53 +1000 Subject: [PATCH] Fixing dependabot and its mistakes (#2232) * updating to utoipa 4.0.0 * hi dependabot --- .github/dependabot.yml | 170 ++++++++++++++++++++++++-- .github/workflows/rust_build.yml | 16 +++ Cargo.lock | 34 +----- Cargo.toml | 3 +- scripts/dependabot_automerge_check.sh | 25 ++-- server/core/Cargo.toml | 2 +- server/core/src/https/apidocs/mod.rs | 11 +- server/testkit/tests/apidocs.rs | 21 ++++ 8 files changed, 225 insertions(+), 57 deletions(-) create mode 100644 server/testkit/tests/apidocs.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 481ac300a..e9dcb35c8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,10 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: pip directory: "/pykanidm" schedule: @@ -15,6 +19,10 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo directory: "/" schedule: @@ -22,20 +30,32 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/kanidm_client" + directory: "/libs/client" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/kanidm_proto" + directory: "/proto" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo directory: "/server/core" schedule: @@ -43,13 +63,65 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/server/score" + directory: "/server/testkit" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/server/testkit-macros" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/libs/crypto" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/server/lib" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/server/lib-macros" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo directory: "/server/daemon" schedule: @@ -57,6 +129,10 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo directory: "/tools/cli" schedule: @@ -64,6 +140,10 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo directory: "/server/web_ui" schedule: @@ -71,47 +151,115 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/kanidm_unix_int" + directory: "/unix_integration" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane - package-ecosystem: cargo - directory: "/kanidm_unix_int/nss_kanidm" + directory: "/unix_integration/nss_kanidm" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/kanidm_unix_int/pam_kanidm" + directory: "/unix_integration/pam_kanidm" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/kanidm_unix_int/pam_tester" + directory: "/tools/orca" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/orca" + directory: "/libs/file_permissions" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" - package-ecosystem: cargo - directory: "/profiles" + directory: "/libs/profiles" schedule: interval: weekly time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/libs/sketching" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/libs/user" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/tools/iam_migrations/ldap" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" + - package-ecosystem: cargo + directory: "/tools/iam_migrations/freeipa" + schedule: + interval: weekly + time: "06:00" + timezone: Australia/Brisbane + open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" # Maintain dependencies for GitHub Actions - package-ecosystem: "github-actions" directory: "/" @@ -120,3 +268,7 @@ updates: time: "06:00" timezone: Australia/Brisbane open-pull-requests-limit: 99 + groups: + all: # group all the things + patterns: + - "*" diff --git a/.github/workflows/rust_build.yml b/.github/workflows/rust_build.yml index a8beab7e2..c87f5b759 100644 --- a/.github/workflows/rust_build.yml +++ b/.github/workflows/rust_build.yml @@ -17,6 +17,11 @@ concurrency: jobs: rust_build: runs-on: ubuntu-latest + env: + SCCACHE_GHA_ENABLED: true + RUSTC_WRAPPER: sccache + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - name: Install Rust @@ -38,10 +43,21 @@ jobs: run: cargo build --workspace - name: "Build the idv-tui feature kanidm binary" run: cargo build --bin kanidm --features idv-tui + - name: "Check disk space and size of target, then clean it" + run: | + df -h + du -sh target/ + rm -rf target/* + - name: "Run cargo test" run: cargo test run_release: runs-on: ubuntu-latest + env: + SCCACHE_GHA_ENABLED: true + RUSTC_WRAPPER: sccache + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - name: Install Rust diff --git a/Cargo.lock b/Cargo.lock index 27205358e..52a69a461 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2952,7 +2952,7 @@ dependencies = [ "tracing", "url", "urlencoding", - "utoipa 3.5.0", + "utoipa", "uuid", "webauthn-rs-proto", ] @@ -3082,7 +3082,7 @@ dependencies = [ "tracing-subscriber", "url", "urlencoding", - "utoipa 3.5.0", + "utoipa", "utoipa-swagger-ui", "uuid", "walkdir", @@ -5712,18 +5712,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "utoipa" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82b1bc5417102a73e8464c686eef947bdfb99fcdfc0a4f228e81afa9526470a" -dependencies = [ - "indexmap 2.0.2", - "serde", - "serde_json", - "utoipa-gen 3.5.0", -] - [[package]] name = "utoipa" version = "4.0.0" @@ -5733,20 +5721,7 @@ dependencies = [ "indexmap 2.0.2", "serde", "serde_json", - "utoipa-gen 4.0.0", -] - -[[package]] -name = "utoipa-gen" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d96dcd6fc96f3df9b3280ef480770af1b7c5d14bc55192baa9b067976d920c" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "regex", - "syn 2.0.38", + "utoipa-gen", ] [[package]] @@ -5758,6 +5733,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", + "regex", "syn 2.0.38", ] @@ -5773,7 +5749,7 @@ dependencies = [ "rust-embed", "serde", "serde_json", - "utoipa 4.0.0", + "utoipa", "zip", ] diff --git a/Cargo.toml b/Cargo.toml index 5d1c4b82c..9a49ea637 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -207,7 +207,8 @@ tss-esapi = "^7.4.0" url = "^2.4.1" urlencoding = "2.1.3" users = "^0.11.0" -utoipa = "3.5.0" +utoipa = "4.0.0" +utoipa-swagger-ui = "4.0.0" uuid = "^1.4.1" wasm-bindgen = "^0.2.86" diff --git a/scripts/dependabot_automerge_check.sh b/scripts/dependabot_automerge_check.sh index 1d56d4d89..241c0bdef 100755 --- a/scripts/dependabot_automerge_check.sh +++ b/scripts/dependabot_automerge_check.sh @@ -7,20 +7,27 @@ fi PR_URL="$1" -# are we good? -CONCLUSIONS="$(gh pr status --json statusCheckRollup | jq '.currentBranch | .[] | .[] | select(.conclusion != "SUCCESS") | select(.conclusion != "NEUTRAL")| {status: .status, workfFlowName: .workFlowName, conclusion: .conclusion}')" -# check approval -APPROVED="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" - # sets the upstream metadata for `gh pr status` gh pr checkout "$PR_URL" -if [ "${APPROVED}" != "APPROVED" ]; then - echo "PR not approved!" - exit 1 -fi + + +# are we good? +echo "Checking Conclusions" +CONCLUSIONS="$(gh pr status --json statusCheckRollup | jq '.currentBranch | .[] | .[] | select(.conclusion != "SUCCESS") | select(.conclusion != "NEUTRAL")| {status: .status, workfFlowName: .workFlowName, conclusion: .conclusion}')" + + if [ "$(echo "${CONCLUSIONS}" | wc -l)" -eq 0 ]; then gh pr review --approve "$PR_URL" else echo "Already running or failed: ${CONCLUSIONS}"; fi + +if [ "${APPROVED}" != "APPROVED" ]; then + echo "PR isn't approved!" + exit 0 +fi + +# check approval +echo "Checking if already approved...." +APPROVED="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" \ No newline at end of file diff --git a/server/core/Cargo.toml b/server/core/Cargo.toml index caf2bb954..34a6168f0 100644 --- a/server/core/Cargo.toml +++ b/server/core/Cargo.toml @@ -67,7 +67,7 @@ utoipa = { workspace = true, features = [ "openapi_extensions", "preserve_order", # Preserve order of properties when serializing the schema for a component. ] } -utoipa-swagger-ui = { version = "4.0.0", features = ["axum"] } +utoipa-swagger-ui = { workspace = true, features = ["axum"] } [dev-dependencies] walkdir = { workspace = true } diff --git a/server/core/src/https/apidocs/mod.rs b/server/core/src/https/apidocs/mod.rs index 5b6c76527..807483c7c 100644 --- a/server/core/src/https/apidocs/mod.rs +++ b/server/core/src/https/apidocs/mod.rs @@ -238,12 +238,7 @@ pub(crate) struct ApiDoc; pub(crate) fn router() -> Router { Router::new() - .route("/docs", get(Redirect::temporary("/docs/swagger-ui"))) - .route("/docs/", get(Redirect::temporary("/docs/swagger-ui"))) - .merge( - SwaggerUi::new("/docs/swagger-ui").url( - "/docs/v1/openapi.json", - ::openapi(), - ) - ) + .route("/docs", get(Redirect::temporary("/docs/swagger-ui"))) + .route("/docs/", get(Redirect::temporary("/docs/swagger-ui"))) + .merge(SwaggerUi::new("/docs/swagger-ui").url("/docs/v1/openapi.json", ApiDoc::openapi())) } diff --git a/server/testkit/tests/apidocs.rs b/server/testkit/tests/apidocs.rs new file mode 100644 index 000000000..e6603231f --- /dev/null +++ b/server/testkit/tests/apidocs.rs @@ -0,0 +1,21 @@ +use serde::{Deserialize, Serialize}; +use tracing::info; + +#[kanidmd_testkit::test] +async fn check_that_the_swagger_api_loads(rsclient: kanidm_client::KanidmClient) { + #[derive(Serialize, Deserialize, Debug)] + struct OpenAPIResponse { + pub openapi: String, + } + + rsclient.set_token("".into()).await; + info!("Running test: check_that_the_swagger_api_loads"); + let url = rsclient.make_url("/docs/v1/openapi.json"); + let foo: OpenAPIResponse = reqwest::get(url) + .await + .expect("Failed to get openapi.json") + .json() + .await + .unwrap(); + assert!(foo.openapi != "1.2.3"); +}