From 156b676636d85d738ff9a8cb993bef49d0e23f06 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Fri, 6 Jun 2025 13:43:39 +0200 Subject: [PATCH] chore: Prepare interop job --- .github/workflows/benchmark.yml | 51 +------ ...nchmark_run.yml => benchmark_fork_run.yml} | 3 +- ...ark_track.yml => benchmark_fork_track.yml} | 9 +- .github/workflows/benchmark_pr.yml | 57 ++++++++ .github/workflows/functional.yml | 134 ++++++++++++++++++ .github/workflows/integration.yml | 49 ------- Cargo.lock | 60 ++++---- Cargo.toml | 7 +- tests/interop/main.rs | 16 +++ 9 files changed, 251 insertions(+), 135 deletions(-) rename .github/workflows/{fork_pr_benchmark_run.yml => benchmark_fork_run.yml} (91%) rename .github/workflows/{fork_pr_benchmark_track.yml => benchmark_fork_track.yml} (88%) create mode 100644 .github/workflows/benchmark_pr.yml create mode 100644 .github/workflows/functional.yml delete mode 100644 .github/workflows/integration.yml create mode 100644 tests/interop/main.rs diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 20ef5edb..29f84dab 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -5,16 +5,13 @@ permissions: on: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + branches: "main" env: CARGO_TERM_COLOR: always jobs: bench_main: - if: github.event_name == 'push' permissions: checks: write strategy: @@ -58,49 +55,3 @@ jobs: --github-actions '${{ secrets.GITHUB_TOKEN }}' \ --adapter rust_criterion \ cargo bench - - bench_pr: - # DO NOT REMOVE: For handling Fork PRs see Pull Requests from Forks - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - permissions: - pull-requests: write - strategy: - matrix: - include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - runs-on: ${{ matrix.os }} - - steps: - - name: Harden Runner - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Install Rust - uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1 # stable - with: - toolchain: stable - targets: ${{ matrix.target }} - - - name: Rust Cache - uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 - - - uses: bencherdev/bencher@main - - - name: Track base branch benchmarks with Bencher - run: | - bencher run \ - --project keystone \ - --token '${{ secrets.BENCHER_API_TOKEN }}' \ - --branch "$GITHUB_HEAD_REF" \ - --start-point "$GITHUB_BASE_REF" \ - --start-point-hash '${{ github.event.pull_request.base.sha }}' \ - --start-point-clone-thresholds \ - --start-point-reset \ - --testbed ${{ matrix.os }} \ - --github-actions '${{ secrets.GITHUB_TOKEN }}' \ - --adapter rust_criterion \ - cargo bench diff --git a/.github/workflows/fork_pr_benchmark_run.yml b/.github/workflows/benchmark_fork_run.yml similarity index 91% rename from .github/workflows/fork_pr_benchmark_run.yml rename to .github/workflows/benchmark_fork_run.yml index e1a21fd2..f8035495 100644 --- a/.github/workflows/fork_pr_benchmark_run.yml +++ b/.github/workflows/benchmark_fork_run.yml @@ -1,4 +1,4 @@ -name: Run Benchmarks +name: "Run Benchmarks" on: pull_request: @@ -6,6 +6,7 @@ on: jobs: benchmark_fork_pr_branch: + if: "github.event.pull_request.head.repo.full_name != github.repository" name: Run Fork PR Benchmarks runs-on: ubuntu-latest steps: diff --git a/.github/workflows/fork_pr_benchmark_track.yml b/.github/workflows/benchmark_fork_track.yml similarity index 88% rename from .github/workflows/fork_pr_benchmark_track.yml rename to .github/workflows/benchmark_fork_track.yml index 85cd52a3..aef3837b 100644 --- a/.github/workflows/fork_pr_benchmark_track.yml +++ b/.github/workflows/benchmark_fork_track.yml @@ -1,13 +1,14 @@ -name: Track Benchmarks with Bencher +name: "Benchmarks" on: workflow_run: - workflows: [Run Benchmarks] - types: [completed] + workflows: ["Run Benchmarks"] + types: ["completed"] jobs: track_fork_pr_branch: - if: github.event.workflow_run.conclusion == 'success' + if: "github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && github.event.workflow_run.conclusion == 'success'" + runs-on: ubuntu-latest env: BENCHMARK_RESULTS: benchmark_results.log diff --git a/.github/workflows/benchmark_pr.yml b/.github/workflows/benchmark_pr.yml new file mode 100644 index 00000000..e07c66d9 --- /dev/null +++ b/.github/workflows/benchmark_pr.yml @@ -0,0 +1,57 @@ +name: Benchmarks + +permissions: + contents: read + +on: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + bench_pr_branch: + # DO NOT REMOVE: For handling Fork PRs see Pull Requests from Forks + if: "github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'" + permissions: + pull-requests: write + strategy: + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + runs-on: ${{ matrix.os }} + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install Rust + uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1 # stable + with: + toolchain: stable + targets: ${{ matrix.target }} + + - name: Rust Cache + uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 + + - uses: bencherdev/bencher@main + + - name: Track base branch benchmarks with Bencher + run: | + bencher run \ + --project keystone \ + --token '${{ secrets.BENCHER_API_TOKEN }}' \ + --branch "$GITHUB_HEAD_REF" \ + --start-point "$GITHUB_BASE_REF" \ + --start-point-hash '${{ github.event.pull_request.base.sha }}' \ + --start-point-clone-thresholds \ + --start-point-reset \ + --testbed ${{ matrix.os }} \ + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ + --adapter rust_criterion \ + cargo bench diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml new file mode 100644 index 00000000..962de352 --- /dev/null +++ b/.github/workflows/functional.yml @@ -0,0 +1,134 @@ +--- +name: Functional and interoperability testing + +on: + workflow_dispatch: + pull_request: + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/functional.yml' + - 'tests/' + - 'src/' + +jobs: + test: + name: interop + runs-on: ubuntu-latest + services: + postgres: + image: postgres:17 + env: + POSTGRES_USER: keystone + POSTGRES_PASSWORD: '1234' + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Enable cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/pip + ~/.cargo + key: ${{ runner.os }}-integration + + - name: Rust Cache + uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Rust + uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1 # stable + with: + toolchain: stable + + - name: Install necessary python packages + run: pip install keystone uwsgi psycopg2 + + - name: Install osc + run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/gtema/openstack/releases/latest/download/openstack_cli-installer.sh | sh + + - name: Prepare keystone config file + run: | + mkdir -p etc + echo "[database]" >> etc/keystone.conf + echo "connection = postgresql://keystone:1234@127.0.0.1:5432/keystone" >> etc/keystone.conf + echo "[fernet_receipts]" >> etc/keystone.conf + echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf + echo "[fernet_tokens]" >> etc/keystone.conf + echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf + cat etc/keystone.conf + + - name: Init keystone + env: + OS_KEYSTONE_CONFIG_DIR: ${{ github.workspace }}/etc + run: | + mkdir -p etc/fernet + keystone-manage --config-file etc/keystone.conf db_sync + keystone-manage --config-file etc/keystone.conf fernet_setup + keystone-manage --config-file etc/keystone.conf bootstrap --bootstrap-password password + + - name: Prepare clouds.yaml + run: | + mkdir -p ~/.config/openstack + cat < ~/.config/openstack/clouds.yaml + clouds: + admin: + auth: + auth_url: http://localhost:5001 + username: admin + password: password + project_name: admin + user_domain_name: default + project_domain_name: default + interface: public + + admin-rust: + auth: + auth_url: http://localhost:8080 + username: admin + password: password + project_name: admin + user_domain_name: default + project_domain_name: default + interface: internal + EOF + + - name: Run python keystone + env: + OS_KEYSTONE_CONFIG_DIR: ${{ github.workspace }}/etc + run: | + uwsgi --module "keystone.server.wsgi:initialize_public_application()" --http-socket :5001 -b 65535 --http-keepalive --so-keepalive --logformat "Request %(uri):%(method) returned %(status) in %(msecs)ms" > python.log 2>&1 & + + - name: Build and install Rust keystone + run: cargo install --path . + + - name: Run rust keystone + run: | + keystone -c ${{ github.workspace }}/etc/keystone.conf -vv > rust.log 2>&1 & + + - name: Test python keystone + run: | + curl http://localhost:5001/v3 + + - name: Test rust keystone + run: | + curl http://localhost:8080/v3 + + - name: Run interop tests + run: cargo test --test interop + + - name: Dump python keystone log + if: failure() + run: | + cat python.log + + - name: Dump rust keystone log + if: failure() + run: | + cat rust.log diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml deleted file mode 100644 index 3990834f..00000000 --- a/.github/workflows/integration.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Integration - -on: - workflow_dispatch: - pull_request: - -jobs: - test: - name: Integration - runs-on: ubuntu-latest - services: - postgres: - image: postgres:17 - env: - POSTGRES_USER: keystone - POSTGRES_PASSWORD: '1234' - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install necessary python packages - run: pip install keystone uwsgi psycopg2 - - - name: Prepare keystone config file - env: - store_id: ${{ steps.store.outputs.store_id }} - model_id: ${{ steps.store.outputs.model_id }} - run: | - mkdir -p etc - echo "[database]" >> etc/keystone.conf - echo "connection = postgresql://keystone:1234@127.0.0.1:5432/keystone" >> etc/keystone.conf - echo "[fernet_receipts]" >> etc/keystone.conf - echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf - echo "[fernet_tokens]" >> etc/keystone.conf - echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf - cat etc/keystone.conf - - - name: Init keystone - run: | - mkdir -p etc/fernet - keystone-manage --config-file etc/keystone.conf db_sync - keystone-manage --config-file etc/keystone.conf fernet_setup - keystone-manage --config-file etc/keystone.conf bootstrap --bootstrap-password password diff --git a/Cargo.lock b/Cargo.lock index d3b29a98..5ae2c8a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,9 +87,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" dependencies = [ "anstyle", "anstyle-parse", @@ -102,33 +102,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.8" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", "once_cell_polyfill", @@ -488,9 +488,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" [[package]] name = "bytecheck" @@ -534,9 +534,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.25" +version = "1.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" +checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" dependencies = [ "jobserver", "libc", @@ -676,9 +676,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "compact_jwt" @@ -1611,9 +1611,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.6" +version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a01595e11bdcec50946522c32dde3fc6914743000a68b93000965f2f02406d" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ "http", "hyper", @@ -1628,9 +1628,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c293b6b3d21eca78250dc7dbebd6b9210ec5530e038cbfe0661b5c47ab06e8" +checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb" dependencies = [ "base64 0.22.1", "bytes", @@ -1945,9 +1945,9 @@ dependencies = [ [[package]] name = "libz-rs-sys" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a" +checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221" dependencies = [ "zlib-rs", ] @@ -4143,9 +4143,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] @@ -4229,9 +4229,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662" dependencies = [ "proc-macro2", "quote", @@ -4240,9 +4240,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -5148,9 +5148,9 @@ dependencies = [ [[package]] name = "zlib-rs" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8" +checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a" [[package]] name = "zopfli" diff --git a/Cargo.toml b/Cargo.toml index f5856469..a7790267 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ serde_bytes = { version = "0.11" } serde_json = { version = "1.0" } thiserror = { version = "2.0" } tokio = { version = "1.45", features = ["fs", "macros", "signal", "rt-multi-thread"] } -tokio-util = "0.7.15" +tokio-util = { version = "0.7" } tower = { version = "0.5" } tower-http = { version = "0.6", features = ["compression-full", "request-id", "sensitive-headers", "trace", "util"] } tracing = { version = "0.1" } @@ -65,3 +65,8 @@ opt-level = 3 strip = true debug = false lto = true + +[[test]] +name = "interop" +path = "tests/interop/main.rs" +test = false diff --git a/tests/interop/main.rs b/tests/interop/main.rs new file mode 100644 index 00000000..37f83a74 --- /dev/null +++ b/tests/interop/main.rs @@ -0,0 +1,16 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + +#[test] +fn main() {}