From 3f560317952e8d4f008c25dd06238677aa7c642c Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 7 Nov 2022 11:35:06 +0100 Subject: [PATCH] Automate schema updates --- .github/workflows/ci.yaml | 46 +++++++++++++++++++ crates/config/Cargo.toml | 4 ++ crates/email/Cargo.toml | 4 ++ crates/graphql/Cargo.toml | 4 ++ .../http/src/layers/otel/make_span_builder.rs | 2 +- misc/update-schemas.sh | 13 ++++++ misc/wasmtime-config.toml | 9 ---- 7 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 misc/update-schemas.sh delete mode 100644 misc/wasmtime-config.toml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e249f9b1..28e7b44a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -73,6 +73,33 @@ jobs: - name: Check style run: cargo fmt --all -- --check + + check-schema: + name: Check schema + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Install toolchain + run: | + rustup toolchain install stable + rustup default stable + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Update the schemas + run: sh ./misc/update-schemas.sh + + - name: Check that the workspace is clean + run: | + [[ -z $(git status -s) ]] + clippy: name: Run Clippy @@ -362,3 +389,22 @@ jobs: env: TAGS: "${{ steps.meta.outputs.tags }} ${{ steps.meta-debug.outputs.tags }}" COSIGN_EXPERIMENTAL: 1 + + + tests-done: + name: Tests done + if: ${{ always() }} + needs: + - opa-lint + - rustfmt + - clippy + - check-schema + - test + - coverage + - build-image + runs-on: ubuntu-latest + + steps: + - uses: matrix-org/done-action@v2 + with: + needs: ${{ toJSON(needs) }} diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index ddaf3db9..01e854ee 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -37,5 +37,9 @@ mas-keystore = { path = "../keystore" } mas-iana = { path = "../iana" } mas-email = { path = "../email" } +[features] +native-roots = ["mas-email/native-roots"] +webpki-roots = ["mas-email/webpki-roots"] + [[bin]] name = "schema" diff --git a/crates/email/Cargo.toml b/crates/email/Cargo.toml index ae38a7c1..3034c305 100644 --- a/crates/email/Cargo.toml +++ b/crates/email/Cargo.toml @@ -23,3 +23,7 @@ mas-http = { path = "../http", features = ["aws-sdk", "client"] } version = "0.10.1" default-features = false features = ["tokio1-rustls-tls", "hostname", "builder", "tracing", "pool", "smtp-transport", "sendmail-transport"] + +[features] +native-roots = ["mas-http/native-roots"] +webpki-roots = ["mas-http/webpki-roots"] diff --git a/crates/graphql/Cargo.toml b/crates/graphql/Cargo.toml index a65972f0..ddab414b 100644 --- a/crates/graphql/Cargo.toml +++ b/crates/graphql/Cargo.toml @@ -13,5 +13,9 @@ tokio-stream = "0.1.11" mas-axum-utils = { path = "../axum-utils" } +[features] +native-roots = ["mas-axum-utils/native-roots"] +webpki-roots = ["mas-axum-utils/webpki-roots"] + [[bin]] name = "schema" diff --git a/crates/http/src/layers/otel/make_span_builder.rs b/crates/http/src/layers/otel/make_span_builder.rs index b5eeb209..5e057321 100644 --- a/crates/http/src/layers/otel/make_span_builder.rs +++ b/crates/http/src/layers/otel/make_span_builder.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(feature = "axum")] +#[cfg(any(feature = "axum", feature = "aws-sdk"))] use std::borrow::Cow; #[cfg(feature = "axum")] diff --git a/misc/update-schemas.sh b/misc/update-schemas.sh new file mode 100644 index 00000000..f9a2665b --- /dev/null +++ b/misc/update-schemas.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -eu + +export SQLX_OFFLINE=1 +BASE_DIR="$(dirname "$0")/.." +CONFIG_SCHEMA="${BASE_DIR}/docs/config.schema.json" +GRAPHQL_SCHEMA="${BASE_DIR}/crates/graphql/schema.graphql" + +set -x +# XXX: we shouldn't have to specify this feature +cargo run -p mas-config --features webpki-roots > "${CONFIG_SCHEMA}" +cargo run -p mas-graphql --features webpki-roots > "${GRAPHQL_SCHEMA}" diff --git a/misc/wasmtime-config.toml b/misc/wasmtime-config.toml deleted file mode 100644 index a6d293ce..00000000 --- a/misc/wasmtime-config.toml +++ /dev/null @@ -1,9 +0,0 @@ -# Disable wasmtime cache by default in the Docker image, because the rootfs is likely to be read-only - -[cache] -enabled = false - -# A directory which exists *must* be specified even though the cache is -# disabled, else wasmtime will try to create it, which might fail if the rootfs -# is mounted as read-only -directory = "/tmp"