From bcc6b00bd35c039f13b30aa06b86358972613517 Mon Sep 17 00:00:00 2001 From: Avi Fenesh <55848801+avifenesh@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:44:16 +0300 Subject: [PATCH] CI - Minimal and full CI matrix impl (#2051) * CI - Minimal and full CI matrix impl Signed-off-by: avifenesh * Fix mypy failing (#2453) --------- Signed-off-by: Shoham Elias Signed-off-by: avifenesh * Python: adds JSON.ARRLEN command (#2403) --------- Signed-off-by: Shoham Elias Signed-off-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com> Signed-off-by: avifenesh --------- Signed-off-by: avifenesh Signed-off-by: Shoham Elias Signed-off-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com> Co-authored-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com> --- .github/DEVELOPER.md | 132 ++++++++++ .github/ISSUE_TEMPLATE/bug-report.yml | 236 +++++++++--------- .github/ISSUE_TEMPLATE/feature-request.yml | 100 ++++---- .github/json_matrices/build-matrix.json | 20 +- .github/json_matrices/engine-matrix.json | 26 +- .../supported-languages-versions.json | 17 ++ .github/pull_request_template.md | 14 +- .../workflows/build-node-wrapper/action.yml | 14 +- .github/workflows/codeql.yml | 24 +- .../workflows/create-test-matrices/action.yml | 54 ++++ .github/workflows/csharp.yml | 23 +- .github/workflows/go.yml | 50 ++-- .github/workflows/install-redis/action.yml | 2 +- .../install-rust-and-protoc/action.yml | 1 - .../install-shared-dependencies/action.yml | 13 +- .github/workflows/install-valkey/action.yml | 72 +++--- .github/workflows/java-cd.yml | 19 +- .github/workflows/java.yml | 64 +++-- .github/workflows/lint-rust/action.yml | 4 +- .github/workflows/lint-ts/action.yml | 2 +- .../node-create-package-file/action.yml | 2 +- .github/workflows/node.yml | 125 ++++------ .github/workflows/npm-cd.yml | 110 ++++---- .github/workflows/ort.yml | 187 +++++++------- .github/workflows/pypi-cd.yml | 3 +- .github/workflows/python.yml | 225 ++++++++--------- .github/workflows/run-ort-tools/action.yml | 16 +- .github/workflows/rust.yml | 22 +- .github/workflows/semgrep.yml | 56 ++--- .../workflows/setup-musl-on-linux/action.yml | 18 +- .../start-self-hosted-runner/action.yml | 6 +- .prettierignore | 1 + .vscode/settings.json | 2 +- CHANGELOG.md | 1 + node/tests/GlideClient.test.ts | 48 +++- node/tests/GlideClusterClient.test.ts | 32 ++- .../async_commands/server_modules/json.py | 54 ++++ python/python/tests/test_async_client.py | 4 +- .../tests/tests_server_modules/test_json.py | 36 +++ 39 files changed, 1072 insertions(+), 763 deletions(-) create mode 100644 .github/DEVELOPER.md create mode 100644 .github/json_matrices/supported-languages-versions.json create mode 100644 .github/workflows/create-test-matrices/action.yml create mode 100644 .prettierignore diff --git a/.github/DEVELOPER.md b/.github/DEVELOPER.md new file mode 100644 index 0000000000..710bd08dca --- /dev/null +++ b/.github/DEVELOPER.md @@ -0,0 +1,132 @@ +# CI/CD Workflow Guide + +TODO: Add a description of the CI/CD workflow and its components. + +### Overview + +Our CI/CD pipeline tests and builds our project across multiple languages, versions, and environments. This guide outlines the key components and processes of our workflow. + +### Workflow Triggers + +- Push to `main` branch +- Pull requests +- Scheduled runs (daily) +- Manual trigger (workflow_dispatch) + +### Language-Specific Workflows + +Each language has its own workflow file with similar structure but language-specific steps, for example python.yml for Python, or java.yml for Java. + +### Shared Components + +#### Matrix Files + +While workflows are language-specific, the matrix files are shared across all workflows. +Workflows are starting by loading the matrix files from the `.github/json_matrices` directory. + +- `engine-matrix.json`: Defines the versions of Valkey engine to test against. +- `build-matrix.json`: Defines the host environments for testing. +- `supported-languages-version.json`: Defines the supported versions of languages. + +All matrices have a `run` like field which specifies if the configuration should be tested on every workflow run. +This allows for flexible control over which configurations are tested in different scenarios, optimizing CI/CD performance and resource usage. + +#### Engine Matrix (engine-matrix.json) + +Defines the versions of Valkey engine to test against: + +```json +[{ "type": "valkey", "version": "7.2.5", "run": "always" }] +``` + +- `type`: The type of engine (e.g., Valkey, Redis). +- `version`: The version of the engine. +- `run`: Specifies if the engine version should be tested on every workflow. + +#### Build Matrix (build-matrix.json) + +Defines the host environments for testing: + +```json +[ + { + "OS": "ubuntu", + "RUNNER": "ubuntu-latest", + "TARGET": "x86_64-unknown-linux-gnu", + "run": ["always", "python", "node", "java"] + } + // ... other configurations +] +``` + +- `OS`: The operating system of the host. +- `RUNNER`: The GitHub runner to use. +- `TARGET`: The target environment. +- `run`: Specifies which language workflows should use this host configuration, always means run on each workflow trigger. + +#### Supported Languages Version (supported-languages-version.json) + +Defines the supported versions of languages: + +```json +[ + { + "language": "java", + "versions": ["11", "17"], + "always-run-versions": ["17"] + } + // ... other configurations +] +``` + +- `language`: The language for which the version is supported. +- `versions`: The full versions supported of the language which will test against scheduled. +- `always-run-versions`: The versions which will be tested in every workflow run. + +#### Triggering Workflows + +Push to main or create a pull request to run workflows automatically. +Use workflow_dispatch for manual triggers, accepting inputs of full-matrix which is a boolean value to run all configurations. +Scheduled runs are triggered daily to ensure regular testing of all configurations. + +### Mutual vs. Language-Specific Components + +#### Mutual + +`Matrix files` - `.github/json_matrices` +`Shared dependencies installation` - `.github/workflows/install-shared-dependencies/action.yml` +`Linting Rust` - `.github/workflows/lint-rust/action.yml` + +#### Language-Specific + +`Package manager commands` +`Testing frameworks` +`Build processes` + +### Customizing Workflows + +Modify `[language].yml` files to adjust language-specific steps. +Update matrix files to change tested versions or environments. +Adjust cron schedules in workflow files for different timing of scheduled runs. + +### Workflow Matrices + +We use dynamic matrices for our CI/CD workflows, which are created using the `create-test-matrices` action. This action is defined in `.github/workflows/create-test-matrices/action.yml`. + +#### How it works + +1. The action is called with a `language-name` input and `dispatch-run-full-matrix` input. +2. It reads the `engine-matrix.json`, `build-matrix.json`, and `supported-languages-version.json` files. +3. It filters the matrices based on the inputs and the event type. +4. It generates three matrices: + - Engine matrix: Defines the types and versions of the engine to test against, for example Valkey 7.2.5. + - Host matrix: Defines the host platforms to run the tests on, for example Ubuntu on ARM64. + - Language-version matrix: Defines the supported versions of languages, for example python 3.8. + +#### Outputs + +- `engine-matrix-output`: The generated engine matrix. +- `host-matrix-output`: The generated host matrix. +- `language-version-matrix-output`: The generated language version matrix. + +This dynamic matrix generation allows for flexible and efficient CI/CD workflows, adapting the test configurations based on the type of change and the specific language being tested. diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 5f63253d51..98a018219c 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -5,134 +5,134 @@ title: "(topic): (short issue description)" labels: [bug, needs-triage] assignees: [] body: - - type: textarea - id: description - attributes: - label: Describe the bug - description: What is the problem? A clear and concise description of the bug. - validations: - required: true + - type: textarea + id: description + attributes: + label: Describe the bug + description: What is the problem? A clear and concise description of the bug. + validations: + required: true - - type: textarea - id: expected - attributes: - label: Expected Behavior - description: | - What did you expect to happen? - validations: - required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: | + What did you expect to happen? + validations: + required: true - - type: textarea - id: current - attributes: - label: Current Behavior - description: | - What actually happened? - - Please include full errors, uncaught exceptions, stack traces, and relevant logs. - If service responses are relevant, please include wire logs. - validations: - required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: | + What actually happened? - - type: textarea - id: reproduction - attributes: - label: Reproduction Steps - description: | - Provide a self-contained, concise snippet of code that can be used to reproduce the issue. - For more complex issues provide a repo with the smallest sample that reproduces the bug. - - Avoid including business logic or unrelated code, it makes diagnosis more difficult. - The code sample should be an SSCCE. See http://sscce.org/ for details. In short, please provide a code sample that we can copy/paste, run and reproduce. - validations: - required: true + Please include full errors, uncaught exceptions, stack traces, and relevant logs. + If service responses are relevant, please include wire logs. + validations: + required: true - - type: textarea - id: solution - attributes: - label: Possible Solution - description: | - Suggest a fix/reason for the bug - validations: - required: false + - type: textarea + id: reproduction + attributes: + label: Reproduction Steps + description: | + Provide a self-contained, concise snippet of code that can be used to reproduce the issue. + For more complex issues provide a repo with the smallest sample that reproduces the bug. - - type: textarea - id: context - attributes: - label: Additional Information/Context - description: | - Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world. - validations: - required: false + Avoid including business logic or unrelated code, it makes diagnosis more difficult. + The code sample should be an SSCCE. See http://sscce.org/ for details. In short, please provide a code sample that we can copy/paste, run and reproduce. + validations: + required: true - - type: input - id: client-version - attributes: - label: Client version used - validations: - required: true + - type: textarea + id: solution + attributes: + label: Possible Solution + description: | + Suggest a fix/reason for the bug + validations: + required: false - - type: input - id: engine-version - attributes: - label: Engine type and version - description: E.g. Valkey 7.0 - validations: - required: true + - type: textarea + id: context + attributes: + label: Additional Information/Context + description: | + Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world. + validations: + required: false - - type: input - id: operating-system - attributes: - label: OS - validations: - required: true + - type: input + id: client-version + attributes: + label: Client version used + validations: + required: true - - type: dropdown - id: language - attributes: - label: Language - multiple: true - options: - - TypeScript - - Python - - Java - - Rust - - Go - - .Net - validations: - required: true + - type: input + id: engine-version + attributes: + label: Engine type and version + description: E.g. Valkey 7.0 + validations: + required: true - - type: input - id: language-version - attributes: - label: Language Version - description: E.g. TypeScript (5.2.2) | Python (3.9) - validations: - required: true + - type: input + id: operating-system + attributes: + label: OS + validations: + required: true - - type: textarea - id: cluster-info - attributes: - label: Cluster information - description: | - Cluster information, cluster topology, number of shards, number of replicas, used data types. - validations: - required: false + - type: dropdown + id: language + attributes: + label: Language + multiple: true + options: + - TypeScript + - Python + - Java + - Rust + - Go + - .Net + validations: + required: true - - type: textarea - id: logs - attributes: - label: Logs - description: | - Client and/or server logs. - validations: - required: false + - type: input + id: language-version + attributes: + label: Language Version + description: E.g. TypeScript (5.2.2) | Python (3.9) + validations: + required: true - - type: textarea - id: other - attributes: - label: Other information - description: | - e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, etc - validations: - required: false + - type: textarea + id: cluster-info + attributes: + label: Cluster information + description: | + Cluster information, cluster topology, number of shards, number of replicas, used data types. + validations: + required: false + + - type: textarea + id: logs + attributes: + label: Logs + description: | + Client and/or server logs. + validations: + required: false + + - type: textarea + id: other + attributes: + label: Other information + description: | + e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, etc + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index 64684f1d1c..a7607565aa 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -5,55 +5,55 @@ title: "(topic): (short issue description)" labels: [feature-request, needs-triage] assignees: [] body: - - type: textarea - id: description - attributes: - label: Describe the feature - description: A clear and concise description of the feature you are proposing. - validations: - required: true - - type: textarea - id: use-case - attributes: - label: Use Case - description: | - Why do you need this feature? - validations: - required: true - - type: textarea - id: solution - attributes: - label: Proposed Solution - description: | - Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation. - validations: - required: false - - type: textarea - id: other - attributes: - label: Other Information - description: | - Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc. - validations: - required: false - - type: checkboxes - id: ack - attributes: - label: Acknowledgements - options: - - label: I may be able to implement this feature request + - type: textarea + id: description + attributes: + label: Describe the feature + description: A clear and concise description of the feature you are proposing. + validations: + required: true + - type: textarea + id: use-case + attributes: + label: Use Case + description: | + Why do you need this feature? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Proposed Solution + description: | + Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation. + validations: required: false - - label: This feature might incur a breaking change + - type: textarea + id: other + attributes: + label: Other Information + description: | + Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc. + validations: required: false - - type: input - id: client-version - attributes: - label: Client version used - validations: - required: true - - type: input - id: environment - attributes: - label: Environment details (OS name and version, etc.) - validations: - required: true + - type: checkboxes + id: ack + attributes: + label: Acknowledgements + options: + - label: I may be able to implement this feature request + required: false + - label: This feature might incur a breaking change + required: false + - type: input + id: client-version + attributes: + label: Client version used + validations: + required: true + - type: input + id: environment + attributes: + label: Environment details (OS name and version, etc.) + validations: + required: true diff --git a/.github/json_matrices/build-matrix.json b/.github/json_matrices/build-matrix.json index 45ac7a57f3..f776ad3c64 100644 --- a/.github/json_matrices/build-matrix.json +++ b/.github/json_matrices/build-matrix.json @@ -5,7 +5,8 @@ "RUNNER": "ubuntu-latest", "ARCH": "x64", "TARGET": "x86_64-unknown-linux-gnu", - "PACKAGE_MANAGERS": ["pypi", "npm", "maven"] + "PACKAGE_MANAGERS": ["pypi", "npm"], + "run": ["always", "python", "node", "java"] }, { "OS": "ubuntu", @@ -13,8 +14,9 @@ "RUNNER": ["self-hosted", "Linux", "ARM64"], "ARCH": "arm64", "TARGET": "aarch64-unknown-linux-gnu", - "PACKAGE_MANAGERS": ["pypi", "npm", "maven"], - "CONTAINER": "2_28" + "PACKAGE_MANAGERS": ["pypi", "npm"], + "CONTAINER": "2_28", + "run": ["python", "node", "java"] }, { "OS": "macos", @@ -22,7 +24,8 @@ "RUNNER": "macos-12", "ARCH": "x64", "TARGET": "x86_64-apple-darwin", - "PACKAGE_MANAGERS": ["pypi", "npm", "maven"] + "PACKAGE_MANAGERS": ["pypi", "npm"], + "run": ["python", "node", "java"] }, { "OS": "macos", @@ -30,7 +33,8 @@ "RUNNER": "macos-latest", "ARCH": "arm64", "TARGET": "aarch64-apple-darwin", - "PACKAGE_MANAGERS": ["pypi", "npm", "maven"] + "PACKAGE_MANAGERS": ["pypi", "npm"], + "run": ["python", "node", "java"] }, { "OS": "ubuntu", @@ -40,7 +44,8 @@ "RUNNER": ["self-hosted", "Linux", "ARM64"], "IMAGE": "node:alpine", "CONTAINER_OPTIONS": "--user root --privileged --rm", - "PACKAGE_MANAGERS": ["npm"] + "PACKAGE_MANAGERS": ["npm"], + "run": ["node"] }, { "OS": "ubuntu", @@ -50,6 +55,7 @@ "RUNNER": "ubuntu-latest", "IMAGE": "node:alpine", "CONTAINER_OPTIONS": "--user root --privileged", - "PACKAGE_MANAGERS": ["npm"] + "PACKAGE_MANAGERS": ["npm"], + "run": ["node"] } ] diff --git a/.github/json_matrices/engine-matrix.json b/.github/json_matrices/engine-matrix.json index 464aedf31a..149f6f1080 100644 --- a/.github/json_matrices/engine-matrix.json +++ b/.github/json_matrices/engine-matrix.json @@ -1,10 +1,20 @@ [ - { - "type": "valkey", - "version": "7.2.5" - }, - { - "type": "valkey", - "version": "8.0.0" - } + { + "type": "valkey", + "version": "8.0.0", + "run": "always" + }, + { + "type": "valkey", + "version": "7.2.5" + }, + { + "type": "redis", + "version": "7.0" + }, + { + "type": "redis", + "version": "6.2", + "run": "always" + } ] diff --git a/.github/json_matrices/supported-languages-versions.json b/.github/json_matrices/supported-languages-versions.json new file mode 100644 index 0000000000..bc6fd5f472 --- /dev/null +++ b/.github/json_matrices/supported-languages-versions.json @@ -0,0 +1,17 @@ +[ + { + "language": "java", + "versions": ["11", "17"], + "always-run-versions": ["17"] + }, + { + "language": "python", + "versions": ["3.8", "3.9", "3.10", "3.11", "3.12"], + "always-run-versions": ["3.8", "3.12"] + }, + { + "language": "node", + "full-versions": ["16.x", "17.x", "18.x", "19.x", "20.x"], + "always-run-versions": ["16.x", "20.x"] + } +] diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8e6d8dd2b3..ff120235e3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,16 +7,16 @@ here](https://github.com/valkey-io/valkey-glide/blob/main/CONTRIBUTING.md) --> ### Issue link + This Pull Request is linked to issue (URL): [REPLACE ME] ### Checklist Before submitting the PR make sure the following are checked: -* [ ] This Pull Request is related to one issue. -* [ ] Commit message has a detailed description of what changed and why. -* [ ] Tests are added or updated. -* [ ] CHANGELOG.md and documentation files are updated. -* [ ] Destination branch is correct - main or release -* [ ] Commits will be squashed upon merging. - +- [ ] This Pull Request is related to one issue. +- [ ] Commit message has a detailed description of what changed and why. +- [ ] Tests are added or updated. +- [ ] CHANGELOG.md and documentation files are updated. +- [ ] Destination branch is correct - main or release +- [ ] Commits will be squashed upon merging. diff --git a/.github/workflows/build-node-wrapper/action.yml b/.github/workflows/build-node-wrapper/action.yml index 98246df22f..0b06460f2d 100644 --- a/.github/workflows/build-node-wrapper/action.yml +++ b/.github/workflows/build-node-wrapper/action.yml @@ -65,13 +65,13 @@ runs: - name: Create package.json file uses: ./.github/workflows/node-create-package-file with: - release_version: ${{ env.RELEASE_VERSION }} - os: ${{ inputs.os }} - named_os: ${{ inputs.named_os }} - arch: ${{ inputs.arch }} - npm_scope: ${{ inputs.npm_scope }} - target: ${{ inputs.target }} - + release_version: ${{ env.RELEASE_VERSION }} + os: ${{ inputs.os }} + named_os: ${{ inputs.named_os }} + arch: ${{ inputs.arch }} + npm_scope: ${{ inputs.npm_scope }} + target: ${{ inputs.target }} + - name: npm install shell: bash working-directory: ./node diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1a2b90083d..a24c04af12 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,19 +2,19 @@ name: "CodeQL" on: push: - branches: - - "main" - - "v.?[0-9]+.[0-9]+.[0-9]+" - - "v.?[0-9]+.[0-9]+" - - "v?[0-9]+.[0-9]+.[0-9]+" - - "v?[0-9]+.[0-9]+" + branches: + - "main" + - "v.?[0-9]+.[0-9]+.[0-9]+" + - "v.?[0-9]+.[0-9]+" + - "v?[0-9]+.[0-9]+.[0-9]+" + - "v?[0-9]+.[0-9]+" pull_request: - branches: - - "main" - - "v.?[0-9]+.[0-9]+.[0-9]+" - - "v.?[0-9]+.[0-9]+" - - "v?[0-9]+.[0-9]+.[0-9]+" - - "v?[0-9]+.[0-9]+" + branches: + - "main" + - "v.?[0-9]+.[0-9]+.[0-9]+" + - "v.?[0-9]+.[0-9]+" + - "v?[0-9]+.[0-9]+.[0-9]+" + - "v?[0-9]+.[0-9]+" schedule: - cron: "37 18 * * 6" diff --git a/.github/workflows/create-test-matrices/action.yml b/.github/workflows/create-test-matrices/action.yml new file mode 100644 index 0000000000..61516b1cc9 --- /dev/null +++ b/.github/workflows/create-test-matrices/action.yml @@ -0,0 +1,54 @@ +inputs: + language-name: + description: "Language name" + required: true + dispatch-run-full-matrix: + description: "Run the full matrix" + required: false + default: "false" +outputs: + engine-matrix-output: + description: "Engine matrix" + value: ${{ steps.load-engine-matrix.outputs.engine-matrix }} + host-matrix-output: + description: "Host matrix" + value: ${{ steps.load-host-matrix.outputs.host-matrix }} + version-matrix-output: + description: "Version matrix" + value: ${{ steps.create-version-matrix.outputs.version-matrix }} + +runs: + using: "composite" + steps: + - name: Load engine matrix + id: load-engine-matrix + shell: bash + run: | + if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "push" || "${{inputs.dispatch-run-full-matrix}}" == "false" ]]; then + echo "engine-matrix=$(jq -c '[.[] | select(.run == "always")]' < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + else + echo "engine-matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + fi + echo "engine-matrix=$(cat $GITHUB_OUTPUT)" + + - name: Load host matrix + id: load-host-matrix + shell: bash + run: | + if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "push" || "${{inputs.dispatch-run-full-matrix}}" == "false" ]]; then + echo 'host-matrix={"include":'"$(jq -c '[.[] | select(.run | type == "array" and contains(["always"]))]' .github/json_matrices/build-matrix.json)"'}' >> $GITHUB_OUTPUT + else + echo 'host-matrix={"include":'"$(jq -c '[.[] | select(.run | type == "array" and contains(["${{ inputs.language-name }}"]))]' .github/json_matrices/build-matrix.json)"'}' >> $GITHUB_OUTPUT + fi + echo "host-matrix=$(cat $GITHUB_OUTPUT)" + + - name: Create version matrix + id: create-version-matrix + shell: bash + run: | + if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "push" || "${{inputs.dispatch-run-full-matrix}}" == "false" ]]; then + echo 'version-matrix={"include":'"$(jq -c '[.[] | select(.language == "${{ inputs.language-name }}") | .["always-run-versions"] | map({version: .})]' .github/json_matrices/supported-languages-versions.json)"'}' >> $GITHUB_OUTPUT + else + echo 'version-matrix={"include":'"$(jq -c '[.[] | select(.language == "${{ inputs.language-name }}") | (.versions // .["full-versions"]) | map({version: .})]' .github/json_matrices/supported-languages-versions.json)"'}' >> $GITHUB_OUTPUT + fi + echo "version-matrix=$(cat $GITHUB_OUTPUT)" diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 36b380c3e0..fa1bb6d4e3 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -37,16 +37,16 @@ jobs: load-engine-matrix: runs-on: ubuntu-latest outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} + matrix: ${{ steps.load-engine-matrix.outputs.matrix }} steps: - name: Checkout uses: actions/checkout@v4 - + - name: Load the engine matrix id: load-engine-matrix shell: bash run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT - + run-tests: needs: load-engine-matrix timeout-minutes: 25 @@ -56,19 +56,19 @@ jobs: engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} dotnet: # - '6.0' - - '8.0' + - "8.0" host: - { - OS: ubuntu, - RUNNER: ubuntu-latest, - TARGET: x86_64-unknown-linux-gnu - } + OS: ubuntu, + RUNNER: ubuntu-latest, + TARGET: x86_64-unknown-linux-gnu, + } # - { # OS: macos, # RUNNER: macos-latest, # TARGET: aarch64-apple-darwin # } - + runs-on: ${{ matrix.host.RUNNER }} steps: @@ -80,7 +80,7 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ matrix.dotnet }} - + - name: Install shared software dependencies uses: ./.github/workflows/install-shared-dependencies with: @@ -112,7 +112,7 @@ jobs: benchmarks/results/* utils/clusters/** -# TODO Add amazonlinux + # TODO Add amazonlinux lint-rust: timeout-minutes: 10 @@ -125,3 +125,4 @@ jobs: - uses: ./.github/workflows/lint-rust with: cargo-toml-folder: ./csharp/lib + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7cdfedef59..69254a8cd5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,7 +2,7 @@ name: Go CI on: push: - branches: [ "main" ] + branches: ["main"] paths: - glide-core/src/** - submodules/** @@ -32,17 +32,17 @@ concurrency: jobs: load-engine-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Load the engine matrix - id: load-engine-matrix - shell: bash - run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.load-engine-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Load the engine matrix + id: load-engine-matrix + shell: bash + run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT build-and-test-go-client: needs: load-engine-matrix @@ -52,19 +52,19 @@ jobs: fail-fast: false matrix: go: - - '1.22.0' + - "1.22.0" engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} host: - - { - OS: ubuntu, - RUNNER: ubuntu-latest, - TARGET: x86_64-unknown-linux-gnu - } - # - { - # OS: macos, - # RUNNER: macos-latest, - # TARGET: aarch64-apple-darwin - # } + - { + OS: ubuntu, + RUNNER: ubuntu-latest, + TARGET: x86_64-unknown-linux-gnu, + } + # - { + # OS: macos, + # RUNNER: macos-latest, + # TARGET: aarch64-apple-darwin + # } runs-on: ${{ matrix.host.RUNNER }} @@ -106,7 +106,7 @@ jobs: - name: Run tests working-directory: ./go run: | - make test + make test - uses: ./.github/workflows/test-benchmark with: @@ -185,7 +185,7 @@ jobs: - name: Run tests working-directory: ./go run: | - make test + make test - name: Upload cluster manager logs if: always() diff --git a/.github/workflows/install-redis/action.yml b/.github/workflows/install-redis/action.yml index f4a7491d04..1cdb0cd7cf 100644 --- a/.github/workflows/install-redis/action.yml +++ b/.github/workflows/install-redis/action.yml @@ -36,7 +36,7 @@ runs: wget https://github.com/redis/redis/archive/${{ inputs.redis-version }}.tar.gz; tar -xzvf ${{ inputs.redis-version }}.tar.gz; pushd redis-${{ inputs.redis-version }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli ~/redis-binaries/${{ inputs.redis-version }} && popd; - + - name: Remove the source package shell: bash if: steps.cache-redis.outputs.cache-hit != 'true' diff --git a/.github/workflows/install-rust-and-protoc/action.yml b/.github/workflows/install-rust-and-protoc/action.yml index e1222ffd9d..31987ba04a 100644 --- a/.github/workflows/install-rust-and-protoc/action.yml +++ b/.github/workflows/install-rust-and-protoc/action.yml @@ -16,7 +16,6 @@ inputs: type: string required: true - runs: using: "composite" steps: diff --git a/.github/workflows/install-shared-dependencies/action.yml b/.github/workflows/install-shared-dependencies/action.yml index abca1966cd..616e21c944 100644 --- a/.github/workflows/install-shared-dependencies/action.yml +++ b/.github/workflows/install-shared-dependencies/action.yml @@ -22,16 +22,15 @@ inputs: - aarch64-unknown-linux-musl - x86_64-unknown-linux-musl engine-version: - description: "Engine version to install" - required: true - type: string + description: "Engine version to install" + required: true + type: string github-token: description: "GITHUB_TOKEN, GitHub App installation access token" required: true type: string - runs: using: "composite" steps: @@ -48,7 +47,7 @@ runs: run: | sudo apt update -y sudo apt install -y git gcc pkg-config openssl libssl-dev - + - name: Install software dependencies for Ubuntu MUSL shell: bash if: "${{ contains(inputs.target, 'musl') }}" @@ -68,8 +67,8 @@ runs: if: "${{ !contains(inputs.target, 'musl') }}" uses: ./.github/workflows/install-rust-and-protoc with: - target: ${{ inputs.target }} - github-token: ${{ inputs.github-token }} + target: ${{ inputs.target }} + github-token: ${{ inputs.github-token }} - name: Install Valkey uses: ./.github/workflows/install-valkey diff --git a/.github/workflows/install-valkey/action.yml b/.github/workflows/install-valkey/action.yml index 74c75572a4..36da82f93b 100644 --- a/.github/workflows/install-valkey/action.yml +++ b/.github/workflows/install-valkey/action.yml @@ -25,55 +25,55 @@ runs: using: "composite" steps: - - name: Cache Valkey - # TODO: remove the musl ARM64 limitation when https://github.com/actions/runner/issues/801 is resolved + - name: + Cache Valkey + # TODO: remove the musl ARM64 limitation when https://github.com/actions/runner/issues/801 is resolved if: ${{ inputs.target != 'aarch64-unknown-linux-musl' }} uses: actions/cache@v4 id: cache-valkey with: - path: | - ~/valkey - key: valkey-${{ inputs.engine-version }}-${{ inputs.target }} + path: | + ~/valkey + key: valkey-${{ inputs.engine-version }}-${{ inputs.target }} - name: Build Valkey if: ${{ steps.cache-valkey.outputs.cache-hit != 'true' }} shell: bash - run: | - echo "Building valkey ${{ inputs.engine-version }}" - cd ~ - rm -rf valkey - git clone https://github.com/valkey-io/valkey.git - cd valkey - git checkout ${{ inputs.engine-version }} - make BUILD_TLS=yes + run: | + echo "Building valkey ${{ inputs.engine-version }}" + cd ~ + rm -rf valkey + git clone https://github.com/valkey-io/valkey.git + cd valkey + git checkout ${{ inputs.engine-version }} + make BUILD_TLS=yes - name: Install Valkey shell: bash run: | - cd ~/valkey - if command -v sudo &> /dev/null - then - echo "sudo command exists" - sudo make install - else - echo "sudo command does not exist" - make install - fi - echo 'export PATH=/usr/local/bin:$PATH' >>~/.bash_profile + cd ~/valkey + if command -v sudo &> /dev/null + then + echo "sudo command exists" + sudo make install + else + echo "sudo command does not exist" + make install + fi + echo 'export PATH=/usr/local/bin:$PATH' >>~/.bash_profile - name: Verify Valkey installation and symlinks if: ${{ !contains(inputs.engine-version, '-rc') }} shell: bash - run: | - # In Valkey releases, the engine is built with symlinks from valkey-server and valkey-cli - # to redis-server and redis-cli. This step ensures that the engine is properly installed - # with the expected version and that Valkey symlinks are correctly created. - EXPECTED_VERSION=`echo ${{ inputs.engine-version }} | sed -e "s/^redis-//"` - INSTALLED_VER=$(redis-server -v) - if [[ $INSTALLED_VER != *"${EXPECTED_VERSION}"* ]]; then - echo "Wrong version has been installed. Expected: $EXPECTED_VERSION, Installed: $INSTALLED_VER" - exit 1 - else - echo "Successfully installed the server: $INSTALLED_VER" - fi - + run: | + # In Valkey releases, the engine is built with symlinks from valkey-server and valkey-cli + # to redis-server and redis-cli. This step ensures that the engine is properly installed + # with the expected version and that Valkey symlinks are correctly created. + EXPECTED_VERSION=`echo ${{ inputs.engine-version }} | sed -e "s/^redis-//"` + INSTALLED_VER=$(redis-server -v) + if [[ $INSTALLED_VER != *"${EXPECTED_VERSION}"* ]]; then + echo "Wrong version has been installed. Expected: $EXPECTED_VERSION, Installed: $INSTALLED_VER" + exit 1 + else + echo "Successfully installed the server: $INSTALLED_VER" + fi diff --git a/.github/workflows/java-cd.yml b/.github/workflows/java-cd.yml index e9df283c50..422aef97be 100644 --- a/.github/workflows/java-cd.yml +++ b/.github/workflows/java-cd.yml @@ -212,7 +212,12 @@ jobs: exit 1 test-deployment-on-all-architectures: - needs: [set-release-version, load-platform-matrix, publish-to-maven-central-deployment] + needs: + [ + set-release-version, + load-platform-matrix, + publish-to-maven-central-deployment, + ] env: JAVA_VERSION: "11" RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} @@ -267,7 +272,11 @@ jobs: publish-release-to-maven: if: ${{ inputs.maven_publish == true || github.event_name == 'push' }} - needs: [publish-to-maven-central-deployment, test-deployment-on-all-architectures] + needs: + [ + publish-to-maven-central-deployment, + test-deployment-on-all-architectures, + ] runs-on: ubuntu-latest environment: AWS_ACTIONS env: @@ -281,7 +290,11 @@ jobs: drop-deployment-if-validation-fails: if: ${{ failure() }} - needs: [publish-to-maven-central-deployment, test-deployment-on-all-architectures] + needs: + [ + publish-to-maven-central-deployment, + test-deployment-on-all-architectures, + ] runs-on: ubuntu-latest env: DEPLOYMENT_ID: ${{ needs.publish-to-maven-central-deployment.outputs.DEPLOYMENT_ID }} diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index d5d0697abb..ed8522a9c0 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -25,48 +25,46 @@ on: - .github/workflows/install-valkey/action.yml - .github/json_matrices/build-matrix.json workflow_dispatch: + inputs: + full-matrix: + description: "Run the full matrix" + required: false + default: "false" + + schedule: + - cron: "0 0 * * *" concurrency: group: java-${{ github.head_ref || github.ref }} cancel-in-progress: true jobs: - load-engine-matrix: + get-matrices: runs-on: ubuntu-latest + # Avoid running on schedule for forks + if: (github.repository_owner == 'valkey-io' || github.event_name != 'schedule') outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} + engine-matrix-output: ${{ steps.get-matrices.outputs.engine-matrix-output }} + host-matrix-output: ${{ steps.get-matrices.outputs.host-matrix-output }} + version-matrix-output: ${{ steps.get-matrices.outputs.version-matrix-output }} steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Load the engine matrix - id: load-engine-matrix - shell: bash - run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + - uses: actions/checkout@v4 + - id: get-matrices + uses: ./.github/workflows/create-test-matrices + with: + language-name: java + dispatch-run-full-matrix: ${{ github.event.inputs.full-matrix || 'false' }} - build-and-test-java-client: - needs: load-engine-matrix + test-java: + needs: get-matrices timeout-minutes: 35 strategy: # Run all jobs fail-fast: false matrix: - java: - # - 11 - - 17 - engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} - host: - - { - OS: ubuntu, - RUNNER: ubuntu-latest, - TARGET: x86_64-unknown-linux-gnu, - } - # - { - # OS: macos, - # RUNNER: macos-latest, - # TARGET: aarch64-apple-darwin - # } - + java: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }} + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} + host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output).include }} runs-on: ${{ matrix.host.RUNNER }} steps: @@ -122,14 +120,14 @@ jobs: java/client/build/reports/spotbugs/** build-amazonlinux-latest: - if: github.repository_owner == 'valkey-io' + if: (github.repository_owner == 'valkey-io' && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && github.event.inputs.full-matrix == 'true') + needs: get-matrices strategy: # Run all jobs fail-fast: false matrix: - java: - # - 11 - - 17 + java: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }} + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} runs-on: ubuntu-latest container: amazonlinux:latest timeout-minutes: 35 @@ -156,7 +154,7 @@ jobs: os: "amazon-linux" target: "x86_64-unknown-linux-gnu" github-token: ${{ secrets.GITHUB_TOKEN }} - engine-version: "7.2.5" + engine-version: ${{ matrix.engine.version }} - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 @@ -177,7 +175,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: test-reports-${{ matrix.java }}-amazon-linux + name: test-reports-${{ matrix.java }}-${{ matrix.engine }}-amazon-linux path: | java/client/build/reports/** java/integTest/build/reports/** diff --git a/.github/workflows/lint-rust/action.yml b/.github/workflows/lint-rust/action.yml index 11ca944f71..d01ea92575 100644 --- a/.github/workflows/lint-rust/action.yml +++ b/.github/workflows/lint-rust/action.yml @@ -24,8 +24,6 @@ runs: github-token: ${{ inputs.github-token }} - uses: Swatinem/rust-cache@v2 - with: - github-token: ${{ inputs.github-token }} - run: cargo fmt --all -- --check working-directory: ${{ inputs.cargo-toml-folder }} @@ -38,7 +36,7 @@ runs: # We run clippy without features - run: cargo clippy --all-targets -- -D warnings working-directory: ${{ inputs.cargo-toml-folder }} - shell: bash + shell: bash - run: | cargo update diff --git a/.github/workflows/lint-ts/action.yml b/.github/workflows/lint-ts/action.yml index 834e3d7ec9..2f4b47e358 100644 --- a/.github/workflows/lint-ts/action.yml +++ b/.github/workflows/lint-ts/action.yml @@ -12,7 +12,7 @@ runs: steps: - uses: actions/checkout@v4 - - run: cp eslint.config.mjs ${{ inputs.package-folder }} + - run: cp eslint.config.mjs ${{ inputs.package-folder }} shell: bash - run: | diff --git a/.github/workflows/node-create-package-file/action.yml b/.github/workflows/node-create-package-file/action.yml index 1da7510aab..8c9cc9d2f2 100644 --- a/.github/workflows/node-create-package-file/action.yml +++ b/.github/workflows/node-create-package-file/action.yml @@ -84,4 +84,4 @@ runs: mv package.json package.json.tmpl envsubst < package.json.tmpl > "package.json" cat package.json - echo $(ls *json*) + echo $(ls *json*) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 32db45e5c5..1ae1973838 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -29,6 +29,14 @@ on: - .github/workflows/install-valkey/action.yml - .github/json_matrices/build-matrix.json workflow_dispatch: + inputs: + full-matrix: + description: "Run the full matrix" + required: false + default: "false" + + schedule: + - cron: "0 1 * * *" concurrency: group: node-${{ github.head_ref || github.ref }} @@ -38,43 +46,50 @@ env: CARGO_TERM_COLOR: always jobs: - load-engine-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} - steps: - - name: Checkout - uses: actions/checkout@v4 + get-matrices: + runs-on: ubuntu-latest + # Avoid running on schedule for forks + if: (github.repository_owner == 'valkey-io' || github.event_name != 'schedule') + outputs: + engine-matrix-output: ${{ steps.get-matrices.outputs.engine-matrix-output }} + host-matrix-output: ${{ steps.get-matrices.outputs.host-matrix-output }} + version-matrix-output: ${{ steps.get-matrices.outputs.version-matrix-output }} - - name: Load the engine matrix - id: load-engine-matrix - shell: bash - run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + steps: + - uses: actions/checkout@v4 + - id: get-matrices + uses: ./.github/workflows/create-test-matrices + with: + language-name: node + dispatch-run-full-matrix: ${{ github.event.inputs.full-matrix || 'false' }} - test-ubuntu-latest: + test-node: runs-on: ubuntu-latest - needs: load-engine-matrix + needs: [get-matrices] timeout-minutes: 25 strategy: fail-fast: false matrix: - engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} - + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} + host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output) }} + node: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output)}} steps: - uses: actions/checkout@v4 with: submodules: recursive - - name: Use Node.js 16.x - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v4 + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true with: - node-version: 16.x + node-version: ${{ matrix.node }} - name: Build Node wrapper uses: ./.github/workflows/build-node-wrapper with: - os: "ubuntu" - target: "x86_64-unknown-linux-gnu" + os: ${{ matrix.host.OS }} + target: ${{ matrix.host.TARGET }} github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: ${{ matrix.engine.version }} @@ -84,18 +99,18 @@ jobs: - name: test hybrid node modules - commonjs run: | - npm install --package-lock-only - npm ci - npm run build-and-test + npm install --package-lock-only + npm ci + npm run build-and-test working-directory: ./node/hybrid-node-tests/commonjs-test env: JEST_HTML_REPORTER_OUTPUT_PATH: test-report-commonjs.html - name: test hybrid node modules - ecma run: | - npm install --package-lock-only - npm ci - npm run build-and-test + npm install --package-lock-only + npm ci + npm run build-and-test working-directory: ./node/hybrid-node-tests/ecmascript-test env: JEST_HTML_REPORTER_OUTPUT_PATH: test-report-ecma.html @@ -109,7 +124,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: test-report-node-${{ matrix.engine.type }}-${{ matrix.engine.version }}-ubuntu + name: test-report-node-${{ matrix.engine.type }}-${{ matrix.engine.version }}-${{ matrix.node }}-ubuntu path: | node/test-report*.html utils/clusters/** @@ -128,52 +143,8 @@ jobs: cargo-toml-folder: ./node/rust-client name: lint node rust - # build-macos-latest: - # runs-on: macos-latest - # timeout-minutes: 25 - # steps: - # - uses: actions/checkout@v4 - # with: - # submodules: recursive - # - name: Set up Homebrew - # uses: Homebrew/actions/setup-homebrew@master - - # - name: Install NodeJS - # run: | - # brew update - # brew upgrade || true - # brew install node - - # - name: Downgrade npm major version to 8 - # run: | - # npm i -g npm@8 - - # - name: Build Node wrapper - # uses: ./.github/workflows/build-node-wrapper - # with: - # os: "macos" - # named_os: "darwin" - # arch: "arm64" - # target: "aarch64-apple-darwin" - # github-token: ${{ secrets.GITHUB_TOKEN }} - # engine-version: "7.2.5" - - # - name: Test compatibility - # run: npm test -- -t "set and get flow works" - # working-directory: ./node - - # - name: Upload test reports - # if: always() - # continue-on-error: true - # uses: actions/upload-artifact@v4 - # with: - # name: test-report-node-${{ matrix.engine.type }}-${{ matrix.engine.version }}-macos - # path: | - # node/test-report*.html - # utils/clusters/** - # benchmarks/results/** - build-amazonlinux-latest: + if: (github.repository_owner == 'valkey-io' && github.event_name == 'schedule') runs-on: ubuntu-latest container: amazonlinux:latest timeout-minutes: 15 @@ -205,8 +176,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: "7.2.5" - - name: Test compatibility - run: npm test -- -t "set and get flow works" + - name: test + run: npm test working-directory: ./node - name: Upload test reports @@ -221,6 +192,7 @@ jobs: benchmarks/results/** build-and-test-linux-musl-on-x86: + if: (github.repository_owner == 'valkey-io' && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && github.event.inputs.full-matrix == 'true') name: Build and test Node wrapper on Linux musl runs-on: ubuntu-latest container: @@ -254,9 +226,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: "7.2.5" - - name: Test compatibility - shell: bash - run: npm test -- -t "set and get flow works" + - name: test + run: npm test working-directory: ./node - name: Upload test reports diff --git a/.github/workflows/npm-cd.yml b/.github/workflows/npm-cd.yml index 3788d87e04..af814b7df1 100644 --- a/.github/workflows/npm-cd.yml +++ b/.github/workflows/npm-cd.yml @@ -4,29 +4,29 @@ name: NPM - Continuous Deployment on: pull_request: - paths: - - .github/workflows/npm-cd.yml - - .github/workflows/build-node-wrapper/action.yml - - .github/workflows/start-self-hosted-runner/action.yml - - .github/workflows/install-rust-and-protoc/action.yml - - .github/workflows/install-shared-dependencies/action.yml - - .github/workflows/install-valkey/action.yml - - .github/json_matrices/build-matrix.json + paths: + - .github/workflows/npm-cd.yml + - .github/workflows/build-node-wrapper/action.yml + - .github/workflows/start-self-hosted-runner/action.yml + - .github/workflows/install-rust-and-protoc/action.yml + - .github/workflows/install-shared-dependencies/action.yml + - .github/workflows/install-valkey/action.yml + - .github/json_matrices/build-matrix.json push: tags: - "v*.*" workflow_dispatch: - inputs: - version: - description: 'The release version of GLIDE, formatted as *.*.* or *.*.*-rc*' - required: true + inputs: + version: + description: "The release version of GLIDE, formatted as *.*.* or *.*.*-rc*" + required: true concurrency: group: npm-${{ github.head_ref || github.ref }} cancel-in-progress: true permissions: - id-token: write + id-token: write jobs: start-self-hosted-runner: @@ -34,17 +34,17 @@ jobs: runs-on: ubuntu-latest environment: AWS_ACTIONS steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Start self hosted EC2 runner - uses: ./.github/workflows/start-self-hosted-runner - with: - role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} - aws-region: ${{ secrets.AWS_REGION }} - ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Start self hosted EC2 runner + uses: ./.github/workflows/start-self-hosted-runner + with: + role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }} load-platform-matrix: runs-on: ubuntu-latest @@ -58,9 +58,9 @@ jobs: id: load-platform-matrix shell: bash run: | - # Get the matrix from the matrix.json file, without the object that has the IMAGE key - export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["npm"])))' < .github/json_matrices/build-matrix.json | jq -c .)" - echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT + # Get the matrix from the matrix.json file, without the object that has the IMAGE key + export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["npm"])))' < .github/json_matrices/build-matrix.json | jq -c .)" + echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT publish-binaries: needs: [start-self-hosted-runner, load-platform-matrix] @@ -73,7 +73,7 @@ jobs: strategy: fail-fast: false matrix: - build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} + build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} steps: - name: Setup self-hosted runner access if: ${{ contains(matrix.build.RUNNER, 'self-hosted') && matrix.build.TARGET != 'aarch64-unknown-linux-musl' }} @@ -85,7 +85,7 @@ jobs: run: | apk update apk add git - + - name: Checkout if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl' }} uses: actions/checkout@v4 @@ -100,7 +100,7 @@ jobs: workspace: $GITHUB_WORKSPACE npm-scope: ${{ vars.NPM_SCOPE }} npm-auth-token: ${{ secrets.NPM_AUTH_TOKEN }} - arch: ${{ matrix.build.ARCH }} + arch: ${{ matrix.build.ARCH }} - name: Set the release version shell: bash @@ -115,8 +115,8 @@ jobs: fi echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_ENV env: - EVENT_NAME: ${{ github.event_name }} - INPUT_VERSION: ${{ github.event.inputs.version }} + EVENT_NAME: ${{ github.event_name }} + INPUT_VERSION: ${{ github.event.inputs.version }} - name: Setup node if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl' }} @@ -128,15 +128,15 @@ jobs: scope: "${{ vars.NPM_SCOPE }}" always-auth: true token: ${{ secrets.NPM_AUTH_TOKEN }} - + - name: Setup node for publishing if: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-musl' }} working-directory: ./node run: | - npm config set registry https://registry.npmjs.org/ - npm config set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_AUTH_TOKEN }} - npm config set scope ${{ vars.NPM_SCOPE }} - + npm config set registry https://registry.npmjs.org/ + npm config set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_AUTH_TOKEN }} + npm config set scope ${{ vars.NPM_SCOPE }} + - name: Update package version in config.toml uses: ./.github/workflows/update-glide-version with: @@ -154,7 +154,7 @@ jobs: publish: "true" github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: "7.2.5" - + - name: Check if RC and set a distribution tag for the package shell: bash run: | @@ -171,9 +171,9 @@ jobs: - name: Check that the release version dont have typo init if: ${{ github.event_name != 'pull_request' && contains(env.RELEASE_VERSION, '-') && !contains(env.RELEASE_VERSION, 'rc') }} run: | - echo "The release version "${GITHUB_REF:11}" contains a typo, please fix it" - echo "The release version should be in the format v{major-version}.{minor-version}.{patch-version}-rc{release-candidate-number} when it a release candidate or v{major-version}.{minor-version}.{patch-version} in a stable release." - exit 1 + echo "The release version "${GITHUB_REF:11}" contains a typo, please fix it" + echo "The release version should be in the format v{major-version}.{minor-version}.{patch-version}-rc{release-candidate-number} when it a release candidate or v{major-version}.{minor-version}.{patch-version} in a stable release." + exit 1 - name: Publish to NPM if: github.event_name != 'pull_request' @@ -203,8 +203,8 @@ jobs: if: ${{ matrix.build.ARCH == 'arm64' }} shell: bash run: | - git reset --hard - git clean -xdf + git reset --hard + git clean -xdf publish-base-to-npm: if: github.event_name != 'pull_request' @@ -258,7 +258,7 @@ jobs: target: "x86_64-unknown-linux-gnu" github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: "7.2.5" - + - name: Check if RC and set a distribution tag for the package shell: bash run: | @@ -271,7 +271,7 @@ jobs: export npm_tag="latest" fi echo "NPM_TAG=${npm_tag}" >> $GITHUB_ENV - + - name: Publish the base package if: github.event_name != 'pull_request' shell: bash @@ -296,7 +296,7 @@ jobs: strategy: fail-fast: false matrix: - build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} + build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} steps: - name: Setup self-hosted runner access if: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' }} @@ -305,20 +305,20 @@ jobs: - name: install Redis and git for alpine if: ${{ contains(matrix.build.TARGET, 'musl') }} run: | - apk update - apk add redis git - node -v - + apk update + apk add redis git + node -v + - name: install Redis and Python for ubuntu if: ${{ contains(matrix.build.TARGET, 'linux-gnu') }} run: | - sudo apt-get update - sudo apt-get install redis-server python3 + sudo apt-get update + sudo apt-get install redis-server python3 - name: install Redis, Python for macos if: ${{ contains(matrix.build.RUNNER, 'mac') }} run: | - brew install redis python3 + brew install redis python3 - name: Checkout if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl'}} @@ -381,5 +381,5 @@ jobs: if: ${{ contains(matrix.build.RUNNER, 'self-hosted') }} shell: bash run: | - git reset --hard - git clean -xdf + git reset --hard + git clean -xdf diff --git a/.github/workflows/ort.yml b/.github/workflows/ort.yml index fcea61ee6b..2eff2a3f1a 100644 --- a/.github/workflows/ort.yml +++ b/.github/workflows/ort.yml @@ -1,34 +1,33 @@ - name: The OSS Review Toolkit (ORT) on: schedule: - - cron: "0 0 * * *" + - cron: "0 0 * * *" pull_request: - paths: - - .github/workflows/ort.yml - - .github/workflows/run-ort-tools/action.yml - - utils/get_licenses_from_ort.py + paths: + - .github/workflows/ort.yml + - .github/workflows/run-ort-tools/action.yml + - utils/get_licenses_from_ort.py workflow_dispatch: - inputs: - branch: - description: 'The branch to run against the ORT tool' - required: true - version: - description: 'The release version of GLIDE' - required: true + inputs: + branch: + description: "The branch to run against the ORT tool" + required: true + version: + description: "The release version of GLIDE" + required: true jobs: run-ort: if: github.repository_owner == 'valkey-io' name: Create attribution files runs-on: ubuntu-latest strategy: - fail-fast: false - env: - PYTHON_ATTRIBUTIONS: "python/THIRD_PARTY_LICENSES_PYTHON" - NODE_ATTRIBUTIONS: "node/THIRD_PARTY_LICENSES_NODE" - RUST_ATTRIBUTIONS: "glide-core/THIRD_PARTY_LICENSES_RUST" - JAVA_ATTRIBUTIONS: "java/THIRD_PARTY_LICENSES_JAVA" + fail-fast: false + env: + PYTHON_ATTRIBUTIONS: "python/THIRD_PARTY_LICENSES_PYTHON" + NODE_ATTRIBUTIONS: "node/THIRD_PARTY_LICENSES_NODE" + RUST_ATTRIBUTIONS: "glide-core/THIRD_PARTY_LICENSES_RUST" + JAVA_ATTRIBUTIONS: "java/THIRD_PARTY_LICENSES_JAVA" steps: - name: Set the release version shell: bash @@ -36,17 +35,17 @@ jobs: export version=`if [ "$EVENT_NAME" == 'schedule' ] || [ "$EVENT_NAME" == 'pull_request' ]; then echo '255.255.255'; else echo "$INPUT_VERSION"; fi` echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV env: - EVENT_NAME: ${{ github.event_name }} - INPUT_VERSION: ${{ github.event.inputs.version }} - + EVENT_NAME: ${{ github.event_name }} + INPUT_VERSION: ${{ github.event.inputs.version }} + - name: Set the base branch run: | - export BASE_BRANCH=`if [ "$EVENT_NAME" == 'schedule' ]; then echo 'main'; elif [ "$EVENT_NAME" == 'workflow_dispatch' ]; then echo "$INPUT_BRANCH"; else echo ""; fi` - echo "Base branch is: ${BASE_BRANCH}" - echo "BASE_BRANCH=${BASE_BRANCH}" >> $GITHUB_ENV + export BASE_BRANCH=`if [ "$EVENT_NAME" == 'schedule' ]; then echo 'main'; elif [ "$EVENT_NAME" == 'workflow_dispatch' ]; then echo "$INPUT_BRANCH"; else echo ""; fi` + echo "Base branch is: ${BASE_BRANCH}" + echo "BASE_BRANCH=${BASE_BRANCH}" >> $GITHUB_ENV env: - EVENT_NAME: ${{ github.event_name }} - INPUT_BRANCH: ${{ github.event.inputs.branch }} + EVENT_NAME: ${{ github.event_name }} + INPUT_BRANCH: ${{ github.event.inputs.branch }} - name: Checkout uses: actions/checkout@v4 @@ -64,73 +63,73 @@ jobs: uses: actions/cache@v4 id: cache-ort with: - path: | - ./ort - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-ort + path: | + ./ort + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-ort - name: Checkout ORT Repository if: steps.cache-ort.outputs.cache-hit != 'true' uses: actions/checkout@v4 - with: + with: repository: "oss-review-toolkit/ort" path: "./ort" ref: "26.0.0" submodules: recursive - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@1.78 + uses: dtolnay/rust-toolchain@1.78 - name: Install ORT if: steps.cache-ort.outputs.cache-hit != 'true' working-directory: ./ort/ run: | - export JAVA_OPTS="$JAVA_OPTS -Xmx8g" - ./gradlew installDist + export JAVA_OPTS="$JAVA_OPTS -Xmx8g" + ./gradlew installDist - name: Create ORT config file run: | - mkdir -p ~/.ort/config - cat << EOF > ~/.ort/config/config.yml - ort: - analyzer: - allowDynamicVersions: true - enabledPackageManagers: [Cargo, NPM, PIP, GradleInspector] - EOF - cat ~/.ort/config/config.yml + mkdir -p ~/.ort/config + cat << EOF > ~/.ort/config/config.yml + ort: + analyzer: + allowDynamicVersions: true + enabledPackageManagers: [Cargo, NPM, PIP, GradleInspector] + EOF + cat ~/.ort/config/config.yml - ### NodeJS ### + ### NodeJS ### - name: Set up Node.js 16.x uses: actions/setup-node@v4 with: node-version: 16.x - - name: Create package.json file for the Node wrapper + - name: Create package.json file for the Node wrapper uses: ./.github/workflows/node-create-package-file with: - release_version: ${{ env.RELEASE_VERSION }} - os: "ubuntu-latest" + release_version: ${{ env.RELEASE_VERSION }} + os: "ubuntu-latest" - name: Fix Node base NPM package.json file for ORT working-directory: ./node/npm/glide run: | - # Remove the glide-rs dependency to avoid duplication - sed -i '/ "glide-rs":/d' ../../package.json - export pkg_name=valkey-glide-base - export package_version="${{ env.RELEASE_VERSION }}" - export scope=`if [ "$NPM_SCOPE" != '' ]; then echo "$NPM_SCOPE/"; fi` - mv package.json package.json.tmpl - envsubst < package.json.tmpl > "package.json" - cat package.json - + # Remove the glide-rs dependency to avoid duplication + sed -i '/ "glide-rs":/d' ../../package.json + export pkg_name=valkey-glide-base + export package_version="${{ env.RELEASE_VERSION }}" + export scope=`if [ "$NPM_SCOPE" != '' ]; then echo "$NPM_SCOPE/"; fi` + mv package.json package.json.tmpl + envsubst < package.json.tmpl > "package.json" + cat package.json + - name: Run ORT tools for Node uses: ./.github/workflows/run-ort-tools with: - folder_path: "${{ github.workspace }}/node" - - ### Python ### + folder_path: "${{ github.workspace }}/node" + + ### Python ### - name: Set up Python 3.10 uses: actions/setup-python@v5 @@ -146,14 +145,14 @@ jobs: - name: Run ORT tools for Python uses: ./.github/workflows/run-ort-tools with: - folder_path: "${{ github.workspace }}/python" + folder_path: "${{ github.workspace }}/python" ### Rust ### - name: Run ORT tools for Rust uses: ./.github/workflows/run-ort-tools with: - folder_path: "${{ github.workspace }}/glide-core" + folder_path: "${{ github.workspace }}/glide-core" ### Java ### @@ -163,60 +162,60 @@ jobs: distribution: "temurin" java-version: 11 - - name: Run ORT tools for Java + - name: Run ORT tools for Java uses: ./.github/workflows/run-ort-tools with: - folder_path: "${{ github.workspace }}/java" + folder_path: "${{ github.workspace }}/java" ### Process results ### - name: Check for diff run: | - cp python/ort_results/NOTICE_DEFAULT $PYTHON_ATTRIBUTIONS - cp node/ort_results/NOTICE_DEFAULT $NODE_ATTRIBUTIONS - cp glide-core/ort_results/NOTICE_DEFAULT $RUST_ATTRIBUTIONS - cp java/ort_results/NOTICE_DEFAULT $JAVA_ATTRIBUTIONS - GIT_DIFF=`git diff $PYTHON_ATTRIBUTIONS $NODE_ATTRIBUTIONS $RUST_ATTRIBUTIONS $JAVA_ATTRIBUTIONS` - if [ -n "$GIT_DIFF" ]; then - echo "FOUND_DIFF=true" >> $GITHUB_ENV - else - echo "FOUND_DIFF=false" >> $GITHUB_ENV - fi + cp python/ort_results/NOTICE_DEFAULT $PYTHON_ATTRIBUTIONS + cp node/ort_results/NOTICE_DEFAULT $NODE_ATTRIBUTIONS + cp glide-core/ort_results/NOTICE_DEFAULT $RUST_ATTRIBUTIONS + cp java/ort_results/NOTICE_DEFAULT $JAVA_ATTRIBUTIONS + GIT_DIFF=`git diff $PYTHON_ATTRIBUTIONS $NODE_ATTRIBUTIONS $RUST_ATTRIBUTIONS $JAVA_ATTRIBUTIONS` + if [ -n "$GIT_DIFF" ]; then + echo "FOUND_DIFF=true" >> $GITHUB_ENV + else + echo "FOUND_DIFF=false" >> $GITHUB_ENV + fi - name: Retrieve licenses list working-directory: ./utils run: | - { - echo 'LICENSES_LIST<> "$GITHUB_ENV" + { + echo 'LICENSES_LIST<> "$GITHUB_ENV" ### Create PR ### - name: Create pull request if: ${{ env.FOUND_DIFF == 'true' && github.event_name != 'pull_request' }} run: | - export BRANCH_NAME=`if [ "$EVENT_NAME" == 'schedule' ] || [ "$EVENT_NAME" == 'pull_request' ]; then echo 'scheduled-ort'; else echo "ort-v$INPUT_VERSION"; fi` - echo "Creating pull request from branch ${BRANCH_NAME} to branch ${{ env.BASE_BRANCH }}" - git config --global user.email "valkey-glide@lists.valkey.io" - git config --global user.name "ort-bot" - git checkout -b ${BRANCH_NAME} - git add $PYTHON_ATTRIBUTIONS $NODE_ATTRIBUTIONS $RUST_ATTRIBUTIONS $JAVA_ATTRIBUTIONS - git commit -m "Updated attribution files" -s - git push --set-upstream origin ${BRANCH_NAME} -f - title="Updated attribution files for ${BRANCH_NAME}" - gh pr create -B ${{ env.BASE_BRANCH }} -H ${BRANCH_NAME} --title "${title}" --body 'Created by Github action.\n${{ env.LICENSES_LIST }}' + export BRANCH_NAME=`if [ "$EVENT_NAME" == 'schedule' ] || [ "$EVENT_NAME" == 'pull_request' ]; then echo 'scheduled-ort'; else echo "ort-v$INPUT_VERSION"; fi` + echo "Creating pull request from branch ${BRANCH_NAME} to branch ${{ env.BASE_BRANCH }}" + git config --global user.email "valkey-glide@lists.valkey.io" + git config --global user.name "ort-bot" + git checkout -b ${BRANCH_NAME} + git add $PYTHON_ATTRIBUTIONS $NODE_ATTRIBUTIONS $RUST_ATTRIBUTIONS $JAVA_ATTRIBUTIONS + git commit -m "Updated attribution files" -s + git push --set-upstream origin ${BRANCH_NAME} -f + title="Updated attribution files for ${BRANCH_NAME}" + gh pr create -B ${{ env.BASE_BRANCH }} -H ${BRANCH_NAME} --title "${title}" --body 'Created by Github action.\n${{ env.LICENSES_LIST }}' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - EVENT_NAME: ${{ github.event_name }} - INPUT_VERSION: ${{ github.event.inputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EVENT_NAME: ${{ github.event_name }} + INPUT_VERSION: ${{ github.event.inputs.version }} - name: Get current date id: date run: | - CURR_DATE=$(date +'%Y-%m-%d-%H') - echo "date=${CURR_DATE}" >> $GITHUB_OUTPUT + CURR_DATE=$(date +'%Y-%m-%d-%H') + echo "date=${CURR_DATE}" >> $GITHUB_OUTPUT - name: Upload the final package list continue-on-error: true diff --git a/.github/workflows/pypi-cd.yml b/.github/workflows/pypi-cd.yml index e69343f234..3805bc014f 100644 --- a/.github/workflows/pypi-cd.yml +++ b/.github/workflows/pypi-cd.yml @@ -118,7 +118,8 @@ jobs: if: startsWith(matrix.build.NAMED_OS, 'darwin') run: | brew update - brew install python@3.8 python@3.9 + brew install python@3.9 + - name: Setup Python for self-hosted Ubuntu runners if: contains(matrix.build.OS, 'ubuntu') && contains(matrix.build.RUNNER, 'self-hosted') diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a1b5a16721..a90e2d3fcc 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -34,6 +34,14 @@ on: - .github/json_matrices/engine-matrix.json - .github/workflows/start-self-hosted-runner/action.yml workflow_dispatch: + inputs: + full-matrix: + description: "Run the full matrix" + required: false + default: "false" + + schedule: + - cron: "0 2 * * *" concurrency: group: python-${{ github.head_ref || github.ref }} @@ -45,52 +53,39 @@ permissions: id-token: write jobs: - load-engine-matrix: + get-matrices: runs-on: ubuntu-latest + # Avoid running on schedule for forks + if: (github.repository_owner == 'valkey-io' || github.event_name != 'schedule') outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} + engine-matrix-output: ${{ steps.get-matrices.outputs.engine-matrix-output }} + host-matrix-output: ${{ steps.get-matrices.outputs.host-matrix-output }} + version-matrix-output: ${{ steps.get-matrices.outputs.version-matrix-output}} steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Load the engine matrix - id: load-engine-matrix - shell: bash - run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT - - test: + - uses: actions/checkout@v4 + - id: get-matrices + uses: ./.github/workflows/create-test-matrices + with: + language-name: python + dispatch-run-full-matrix: ${{ github.event.inputs.full-matrix || 'false' }} + + test-python: runs-on: ${{ matrix.host.RUNNER }} - needs: load-engine-matrix + needs: get-matrices timeout-minutes: 35 strategy: fail-fast: false matrix: - engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} - python: - # - "3.8" - # - "3.9" - # - "3.10" - # - "3.11" - - "3.12" - host: - - { - OS: ubuntu, - RUNNER: ubuntu-latest, - TARGET: x86_64-unknown-linux-gnu - } - # - { - # OS: macos, - # RUNNER: macos-latest, - # TARGET: aarch64-apple-darwin - # } - + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} + python: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }} + host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output).include }} steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -140,43 +135,26 @@ jobs: python/python/tests/pytest_report.html utils/clusters/** benchmarks/results/** - - test-pubsub: + test-pubsub-python: runs-on: ${{ matrix.host.RUNNER }} - needs: load-engine-matrix + needs: get-matrices timeout-minutes: 35 strategy: fail-fast: false matrix: - engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} - python: - # - "3.8" - # - "3.9" - # - "3.10" - # - "3.11" - - "3.12" - host: - - { - OS: ubuntu, - RUNNER: ubuntu-latest, - TARGET: x86_64-unknown-linux-gnu - } - # - { - # OS: macos, - # RUNNER: macos-latest, - # TARGET: aarch64-apple-darwin - # } - + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} + python: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }} + host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output).include }} steps: - uses: actions/checkout@v4 with: submodules: recursive - + - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - + - name: Build Python wrapper uses: ./.github/workflows/build-python-wrapper with: @@ -184,14 +162,14 @@ jobs: target: ${{ matrix.host.TARGET }} github-token: ${{ secrets.GITHUB_TOKEN }} engine-version: ${{ matrix.engine.version }} - + - name: Test pubsub with pytest working-directory: ./python run: | source .env/bin/activate cd python/tests/ pytest --asyncio-mode=auto -k test_pubsub --html=pytest_report.html --self-contained-html - + - name: Upload test reports if: always() continue-on-error: true @@ -241,8 +219,8 @@ jobs: working-directory: ./python run: | black --check --diff . - build-amazonlinux-latest: + if: (github.repository_owner == 'valkey-io' && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && github.event.inputs.full-matrix == 'true') runs-on: ubuntu-latest container: amazonlinux:latest timeout-minutes: 15 @@ -288,76 +266,69 @@ jobs: name: smoke-test-report-amazon-linux path: | python/python/tests/pytest_report.html - + start-self-hosted-runner: - if: github.event.pull_request.head.repo.owner.login == 'valkey-io' - runs-on: ubuntu-latest - environment: AWS_ACTIONS - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Start self hosted EC2 runner - uses: ./.github/workflows/start-self-hosted-runner - with: - role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} - aws-region: ${{ secrets.AWS_REGION }} - ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }} + if: github.event.pull_request.head.repo.owner.login == 'valkey-io' + runs-on: ubuntu-latest + environment: AWS_ACTIONS + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Start self hosted EC2 runner + uses: ./.github/workflows/start-self-hosted-runner + with: + role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }} test-modules: - needs: [start-self-hosted-runner, load-engine-matrix] - name: Running Module Tests - runs-on: ${{ matrix.host.RUNNER }} - timeout-minutes: 35 - strategy: - fail-fast: false - matrix: - engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }} - python: - - "3.12" - host: - - { - OS: "ubuntu", - NAMED_OS: "linux", - RUNNER: ["self-hosted", "Linux", "ARM64"], - TARGET: "aarch64-unknown-linux-gnu", - } - - steps: - - name: Setup self-hosted runner access - if: ${{ contains(matrix.host.RUNNER, 'self-hosted') }} - run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/valkey-glide - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Setup Python for self-hosted Ubuntu runners - run: | + needs: [start-self-hosted-runner, get-matrices] + name: Running Module Tests + runs-on: ${{ matrix.host.RUNNER }} + timeout-minutes: 35 + strategy: + fail-fast: false + matrix: + engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }} + python: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }} + host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output).include }} + + steps: + - name: Setup self-hosted runner access + if: ${{ contains(matrix.host.RUNNER, 'self-hosted') }} + run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/valkey-glide + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Python for self-hosted Ubuntu runners + run: | sudo apt update -y sudo apt upgrade -y sudo apt install python3 python3-venv python3-pip -y - - - name: Build Python wrapper - uses: ./.github/workflows/build-python-wrapper - with: - os: ${{ matrix.host.OS }} - target: ${{ matrix.host.TARGET }} - github-token: ${{ secrets.GITHUB_TOKEN }} - engine-version: ${{ matrix.engine.version }} - - - name: Test with pytest - working-directory: ./python - run: | - source .env/bin/activate - cd python/tests/ - pytest --asyncio-mode=auto --tls --cluster-endpoints=${{ secrets.MEMDB_MODULES_ENDPOINT }} -k server_modules --html=pytest_report.html --self-contained-html - - - name: Upload test reports - if: always() - continue-on-error: true - uses: actions/upload-artifact@v4 - with: - name: modules-test-report-${{ matrix.host.TARGET }}-python-${{ matrix.python }}-server-${{ matrix.engine.version }} - path: | - python/python/tests/pytest_report.html + + - name: Build Python wrapper + uses: ./.github/workflows/build-python-wrapper + with: + os: ${{ matrix.host.OS }} + target: ${{ matrix.host.TARGET }} + github-token: ${{ secrets.GITHUB_TOKEN }} + engine-version: ${{ matrix.engine.version }} + + - name: Test with pytest + working-directory: ./python + run: | + source .env/bin/activate + cd python/tests/ + pytest --asyncio-mode=auto --tls --cluster-endpoints=${{ secrets.MEMDB_MODULES_ENDPOINT }} -k server_modules --html=pytest_report.html --self-contained-html + + - name: Upload test reports + if: always() + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: modules-test-report-${{ matrix.host.TARGET }}-python-${{ matrix.python }}-server-${{ matrix.engine.version }} + path: | + python/python/tests/pytest_report.html diff --git a/.github/workflows/run-ort-tools/action.yml b/.github/workflows/run-ort-tools/action.yml index 5686f21b58..2b55517700 100644 --- a/.github/workflows/run-ort-tools/action.yml +++ b/.github/workflows/run-ort-tools/action.yml @@ -13,11 +13,11 @@ runs: working-directory: ./ort/ shell: bash run: | - echo "Running ORT tools for ${{ inputs.folder_path }}" - FOLDER=${{ inputs.folder_path }} - mkdir $FOLDER/ort_results - # Analyzer (analyzer-result.json) - ./gradlew cli:run --args="analyze -i $FOLDER -o $FOLDER/ort_results -f JSON" - - # NOTICE DEFAULT - ./gradlew cli:run --args="report -i $FOLDER/ort_results/analyzer-result.json -o $FOLDER/ort_results/ -f PlainTextTemplate" + echo "Running ORT tools for ${{ inputs.folder_path }}" + FOLDER=${{ inputs.folder_path }} + mkdir $FOLDER/ort_results + # Analyzer (analyzer-result.json) + ./gradlew cli:run --args="analyze -i $FOLDER -o $FOLDER/ort_results -f JSON" + + # NOTICE DEFAULT + ./gradlew cli:run --args="report -i $FOLDER/ort_results/analyzer-result.json -o $FOLDER/ort_results/ -f PlainTextTemplate" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c022e3e419..613448f1d3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -37,17 +37,17 @@ env: jobs: load-engine-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.load-engine-matrix.outputs.matrix }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Load the engine matrix - id: load-engine-matrix - shell: bash - run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.load-engine-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Load the engine matrix + id: load-engine-matrix + shell: bash + run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT build: runs-on: ubuntu-latest diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 6e4235abdb..df9889c7f4 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -1,36 +1,36 @@ name: Semgrep on: - # Scan changed files in PRs (diff-aware scanning): - pull_request: {} - # Scan on-demand through GitHub Actions interface: - workflow_dispatch: - inputs: - branch: - description: 'The branch to run against the semgrep tool' - required: true - push: - branches: ["main"] - # Schedule the CI job (this method uses cron syntax): - schedule: - - cron: '0 8 * * *' # Sets Semgrep to scan every day at 08:00 UTC. + # Scan changed files in PRs (diff-aware scanning): + pull_request: {} + # Scan on-demand through GitHub Actions interface: + workflow_dispatch: + inputs: + branch: + description: "The branch to run against the semgrep tool" + required: true + push: + branches: ["main"] + # Schedule the CI job (this method uses cron syntax): + schedule: + - cron: "0 8 * * *" # Sets Semgrep to scan every day at 08:00 UTC. jobs: - semgrep: - # User definable name of this GitHub Actions job. - name: semgrep/ci - # If you are self-hosting, change the following `runs-on` value: - runs-on: ubuntu-latest + semgrep: + # User definable name of this GitHub Actions job. + name: semgrep/ci + # If you are self-hosting, change the following `runs-on` value: + runs-on: ubuntu-latest - container: - # A Docker image with Semgrep installed. Do not change this. - image: semgrep/semgrep + container: + # A Docker image with Semgrep installed. Do not change this. + image: semgrep/semgrep - # Skip any PR created by dependabot to avoid permission issues: - if: (github.actor != 'dependabot[bot]') + # Skip any PR created by dependabot to avoid permission issues: + if: (github.actor != 'dependabot[bot]') - steps: - # Fetch project source with GitHub Actions Checkout. - - uses: actions/checkout@v3 - # Run the "semgrep ci" command on the command line of the docker image. - - run: semgrep ci --config auto --no-suppress-errors + steps: + # Fetch project source with GitHub Actions Checkout. + - uses: actions/checkout@v3 + # Run the "semgrep ci" command on the command line of the docker image. + - run: semgrep ci --config auto --no-suppress-errors diff --git a/.github/workflows/setup-musl-on-linux/action.yml b/.github/workflows/setup-musl-on-linux/action.yml index ed4677b74a..a8388c84be 100644 --- a/.github/workflows/setup-musl-on-linux/action.yml +++ b/.github/workflows/setup-musl-on-linux/action.yml @@ -30,28 +30,28 @@ runs: run: | apk update apk add bash git sed python3 - + - name: Skip all steps if not on ARM64 shell: bash if: ${{ inputs.arch != 'arm64' }} run: exit 0 - # Currently "Checkout" action is not supported for musl on ARM64, so the checkout is happening on the runner and + # Currently "Checkout" action is not supported for musl on ARM64, so the checkout is happening on the runner and # here we just making sure we getting the clean repo - name: Clean repository for musl on ARM64 shell: bash run: | - git config --global --add safe.directory "${{ inputs.workspace }}" - git clean -xdf - git reset --hard - git submodule sync - git submodule update --init --recursive - + git config --global --add safe.directory "${{ inputs.workspace }}" + git clean -xdf + git reset --hard + git submodule sync + git submodule update --init --recursive + - name: Set up access for musl on ARM shell: bash run: | chown -R $(whoami):$(whoami) $GITHUB_WORKSPACE - + - name: Setup node shell: bash working-directory: ./node diff --git a/.github/workflows/start-self-hosted-runner/action.yml b/.github/workflows/start-self-hosted-runner/action.yml index 2e99795c67..7b2255ead5 100644 --- a/.github/workflows/start-self-hosted-runner/action.yml +++ b/.github/workflows/start-self-hosted-runner/action.yml @@ -19,14 +19,14 @@ runs: with: role-to-assume: ${{ inputs.role-to-assume }} aws-region: ${{ inputs.aws-region }} - + - name: Start EC2 self hosted runner shell: bash run: | sudo apt update sudo apt install awscli -y command_id=$(aws ssm send-command --instance-ids ${{ inputs.ec2-instance-id }} --document-name StartGithubSelfHostedRunner --query Command.CommandId --output text) - + while [[ "$invoke_status" != "Success" && "$invoke_status" != "Failed" ]]; do invoke_status=$(aws ssm list-command-invocations --command-id $command_id --query 'CommandInvocations[0].Status' --output text) echo "Current Status: $invoke_status" @@ -41,4 +41,4 @@ runs: fi done - echo "Final Command Status: $invoke_status" + echo "Final Command Status: $invoke_status" diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..dd449725e1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.md diff --git a/.vscode/settings.json b/.vscode/settings.json index ef488543df..0ff2c47feb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,7 +27,7 @@ "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "[github-actions-workflow]": { - "editor.defaultFormatter": "redhat.vscode-yaml" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 72d205fefb..8ee5dda24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ #### Changes +* Python: Add JSON.ARRLEN command ([#2403](https://github.com/valkey-io/valkey-glide/pull/2403)) #### Breaking Changes diff --git a/node/tests/GlideClient.test.ts b/node/tests/GlideClient.test.ts index 4e3a31d195..6fe08b6acf 100644 --- a/node/tests/GlideClient.test.ts +++ b/node/tests/GlideClient.test.ts @@ -40,7 +40,6 @@ import { flushAndCloseClient, generateLuaLibCode, getClientConfigurationOption, - getServerVersion, parseCommandLineArgs, parseEndpoints, transactionTest, @@ -59,12 +58,10 @@ describe("GlideClient", () => { const standaloneAddresses = parseCommandLineArgs()["standalone-endpoints"]; cluster = standaloneAddresses - ? await ValkeyCluster.initFromExistingCluster( - false, + ? await RedisCluster.initFromExistingCluster( parseEndpoints(standaloneAddresses), - getServerVersion, ) - : await ValkeyCluster.createCluster(false, 1, 1, getServerVersion); + : await RedisCluster.createCluster(false, 1, 1); }, 20000); afterEach(async () => { @@ -135,6 +132,47 @@ describe("GlideClient", () => { }, ); + it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( + "check that blocking commands returns never timeout_%p", + async (protocol) => { + client = await GlideClient.createClient( + getClientConfigurationOption( + cluster.getAddresses(), + protocol, + 300, + ), + ); + + const promiseList = [ + client.blmove( + "source", + "destination", + ListDirection.LEFT, + ListDirection.LEFT, + 0.1, + ), + client.bzpopmax(["key1", "key2"], 0), + client.bzpopmin(["key1", "key2"], 0), + ]; + + try { + for (const promise of promiseList) { + const timeoutPromise = new Promise((resolve) => { + setTimeout(resolve, 500); + }); + await Promise.race([promise, timeoutPromise]); + } + } finally { + for (const promise of promiseList) { + await Promise.resolve([promise]); + } + + client.close(); + } + }, + 5000, + ); + it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( "select dbsize flushdb test %p", async (protocol) => { diff --git a/node/tests/GlideClusterClient.test.ts b/node/tests/GlideClusterClient.test.ts index d21ff1a43a..8d03183898 100644 --- a/node/tests/GlideClusterClient.test.ts +++ b/node/tests/GlideClusterClient.test.ts @@ -46,7 +46,6 @@ import { generateLuaLibCode, getClientConfigurationOption, getFirstResult, - getServerVersion, intoArray, intoString, parseCommandLineArgs, @@ -67,13 +66,17 @@ describe("GlideClusterClient", () => { const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"]; // Connect to cluster or create a new one based on the parsed addresses cluster = clusterAddresses - ? await ValkeyCluster.initFromExistingCluster( - true, + ? (await RedisCluster.initFromExistingCluster( parseEndpoints(clusterAddresses), - getServerVersion, - ) - : // setting replicaCount to 1 to facilitate tests routed to replicas - await ValkeyCluster.createCluster(true, 3, 1, getServerVersion); + )) + ? await ValkeyCluster.initFromExistingCluster( + true, + parseEndpoints(clusterAddresses), + getServerVersion, + ) + : // setting replicaCount to 1 to facilitate tests routed to replicas + await RedisCluster.createCluster(true, 3, 1) + : await ValkeyCluster.createCluster(true, 3, 1, getServerVersion); }, 20000); afterEach(async () => { @@ -369,6 +372,16 @@ describe("GlideClusterClient", () => { const client = await GlideClusterClient.createClient( getClientConfigurationOption(cluster.getAddresses(), protocol), ); + const lmpopArr = []; + + if (!cluster.checkIfServerVersionLessThan("7.0.0")) { + lmpopArr.push( + client.lmpop(["abc", "def"], ListDirection.LEFT, 1), + ); + lmpopArr.push( + client.blmpop(["abc", "def"], ListDirection.RIGHT, 0.1, 1), + ); + } const promises: Promise[] = [ client.blpop(["abc", "zxy", "lkn"], 0.1), @@ -390,10 +403,7 @@ describe("GlideClusterClient", () => { client.sdiffstore("abc", ["zxy", "lkn"]), client.sortStore("abc", "zyx"), client.sortStore("abc", "zyx", { isAlpha: true }), - client.lmpop(["abc", "def"], ListDirection.LEFT, { count: 1 }), - client.blmpop(["abc", "def"], ListDirection.RIGHT, 0.1, { - count: 1, - }), + ...lmpopArr, client.bzpopmax(["abc", "def"], 0.5), client.bzpopmin(["abc", "def"], 0.5), client.xread({ abc: "0-0", zxy: "0-0", lkn: "0-0" }), diff --git a/python/python/glide/async_commands/server_modules/json.py b/python/python/glide/async_commands/server_modules/json.py index 40d7709646..d1709806bc 100644 --- a/python/python/glide/async_commands/server_modules/json.py +++ b/python/python/glide/async_commands/server_modules/json.py @@ -139,6 +139,60 @@ async def get( return cast(bytes, await client.custom_command(args)) +async def arrlen( + client: TGlideClient, + key: TEncodable, + path: Optional[TEncodable] = None, +) -> Optional[TJsonResponse[int]]: + """ + Retrieves the length of the array at the specified `path` within the JSON document stored at `key`. + + Args: + client (TGlideClient): The client to execute the command. + key (TEncodable): The key of the JSON document. + path (Optional[TEncodable]): The path within the JSON document. Defaults to None. + + Returns: + Optional[TJsonResponse[int]]: + For JSONPath (`path` starts with `$`): + Returns a list of integer replies for every possible path, indicating the length of the array, + or None for JSON values matching the path that are not an array. + If `path` doesn't exist, an empty array will be returned. + For legacy path (`path` doesn't starts with `$`): + Returns the length of the array at `path`. + If multiple paths match, the length of the first array match is returned. + If the JSON value at `path` is not a array or if `path` doesn't exist, an error is raised. + If `key` doesn't exist, None is returned. + + Examples: + >>> from glide import json + >>> await json.set(client, "doc", "$", '{"a": [1, 2, 3], "b": {"a": [1, 2], "c": {"a": 42}}}') + b'OK' # JSON is successfully set for doc + >>> await json.arrlen(client, "doc", "$") + [None] # No array at the root path. + >>> await json.arrlen(client, "doc", "$.a") + [3] # Retrieves the length of the array at path $.a. + >>> await json.arrlen(client, "doc", "$..a") + [3, 2, None] # Retrieves lengths of arrays found at all levels of the path `..a`. + >>> await json.arrlen(client, "doc", "..a") + 3 # Legacy path retrieves the first array match at path `..a`. + >>> await json.arrlen(client, "non_existing_key", "$.a") + None # Returns None because the key does not exist. + + >>> await json.set(client, "doc", "$", '[1, 2, 3, 4]') + b'OK' # JSON is successfully set for doc + >>> await json.arrlen(client, "doc") + 4 # Retrieves lengths of arrays in root. + """ + args = ["JSON.ARRLEN", key] + if path: + args.append(path) + return cast( + Optional[TJsonResponse[int]], + await client.custom_command(args), + ) + + async def delete( client: TGlideClient, key: TEncodable, diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index 62d66801c6..7566194dcc 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -9725,7 +9725,7 @@ async def cluster_route_custom_command_slot_route( route_class = SlotKeyRoute if is_slot_key else SlotIdRoute route_second_arg = "foo" if is_slot_key else 4000 primary_res = await glide_client.custom_command( - ["CLUSTER", "NODES"], route_class(SlotType.PRIMARY, route_second_arg) + ["CLUSTER", "NODES"], route_class(SlotType.PRIMARY, route_second_arg) # type: ignore ) assert isinstance(primary_res, bytes) primary_res = primary_res.decode() @@ -9738,7 +9738,7 @@ async def cluster_route_custom_command_slot_route( expected_primary_node_id = node_line.split(" ")[0] replica_res = await glide_client.custom_command( - ["CLUSTER", "NODES"], route_class(SlotType.REPLICA, route_second_arg) + ["CLUSTER", "NODES"], route_class(SlotType.REPLICA, route_second_arg) # type: ignore ) assert isinstance(replica_res, bytes) replica_res = replica_res.decode() diff --git a/python/python/tests/tests_server_modules/test_json.py b/python/python/tests/tests_server_modules/test_json.py index 67c8c7a112..a69c3010e2 100644 --- a/python/python/tests/tests_server_modules/test_json.py +++ b/python/python/tests/tests_server_modules/test_json.py @@ -276,3 +276,39 @@ async def test_json_type(self, glide_client: TGlideClient): # Check for all types in the JSON document using legacy path result = await json.type(glide_client, key, "[*]") assert result == b"string" # Expecting only the first type (string for key1) + + @pytest.mark.parametrize("cluster_mode", [True, False]) + @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) + async def test_json_arrlen(self, glide_client: TGlideClient): + key = get_random_string(5) + + json_value = '{"a": [1, 2, 3], "b": {"a": [1, 2], "c": {"a": 42}}}' + assert await json.set(glide_client, key, "$", json_value) == OK + + assert await json.arrlen(glide_client, key, "$.a") == [3] + + assert await json.arrlen(glide_client, key, "$..a") == [3, 2, None] + + # Legacy path retrieves the first array match at ..a + assert await json.arrlen(glide_client, key, "..a") == 3 + + # Value at path is not an array + assert await json.arrlen(glide_client, key, "$") == [None] + with pytest.raises(RequestError): + assert await json.arrlen(glide_client, key, ".") + + # Path doesn't exist + assert await json.arrlen(glide_client, key, "$.non_existing_path") == [] + with pytest.raises(RequestError): + assert await json.arrlen(glide_client, key, "non_existing_path") + + # Non-existing key + assert await json.arrlen(glide_client, "non_existing_key", "$.a") is None + assert await json.arrlen(glide_client, "non_existing_key", ".a") is None + + # No path + with pytest.raises(RequestError): + assert await json.arrlen(glide_client, key) + + assert await json.set(glide_client, key, "$", "[1, 2, 3, 4]") == OK + assert await json.arrlen(glide_client, key) == 4