Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# base development image on .NET 7.0
FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0-bullseye AS build

# fetch the .NET 6.0 SDK for use in testing
COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 /usr/share/dotnet/shared /usr/share/dotnet/shared
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "NRedisStack (.NET)",

"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-dotnettools.vscodeintellicode-csharp"
]
}
}
}
39 changes: 39 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: "3.8"
services:
devcontainer:
build:
context: .
dockerfile: Dockerfile
volumes:
- ../..:/workspaces:cached
networks:
- redis
command: sleep infinity
environment:
REDIS: "redis-stack-edge:6379" # default targeted Redis version
REDIS__7_2_0: "redis-stack-7.2.0:6379"
REDIS__6_2_6: "redis-stack-6.2.6:6379"
REDIS__edge: "redis-stack-edge:6379"

redis-stack-7.2.0:
image: redis/redis-stack-server:7.2.0-RC3
restart: unless-stopped
networks:
- redis

redis-stack-6.2.6:
image: redis/redis-stack-server:6.2.6-v9
restart: unless-stopped
networks:
- redis

redis-stack-edge:
image: redis/redis-stack-server:edge
restart: unless-stopped
networks:
- redis

networks:
# defines shared network for communicating with Redis
redis:
2 changes: 2 additions & 0 deletions .github/wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cli
codecov
Codecov
Dev
DevContainer
dotnet
firsttimersonly
github
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info",
"dotnet-test-explorer.testProjectPath": "**/*NRedisStack.Tests.csproj"
"dotnet-test-explorer.testProjectPath": "**/*NRedisStack.Tests.csproj",
"dotnet.defaultSolution": "NRedisStack.sln"
}
55 changes: 54 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@
"problemMatcher": "$msCompile"
},
{
"label": "test",
"label": "test 6.2.6",
"dependsOn": [],
"options": {
"env": {
"REDIS": "${env:REDIS__6_2_6}"
}
},
"command": "dotnet",
"type": "process",
"args": [
Expand All @@ -49,6 +54,54 @@
"/p:CoverletOutputFormat=lcov",
"/p:CoverletOutput=./lcov.info"
],
"problemMatcher": "$msCompile"
},
{
"label": "test 7.2.0",
"dependsOn": [],
"options": {
"env": {
"REDIS": "${env:REDIS__7_2_0}"
}
},
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/tests/NRedisStack.Tests/NRedisStack.Tests.csproj",
"/p:CollectCoverage=true",
"/p:CoverletOutputFormat=lcov",
"/p:CoverletOutput=./lcov.info"
],
"problemMatcher": "$msCompile"
},
{
"label": "test edge",
"dependsOn": [],
"options": {
"env": {
"REDIS": "${env:REDIS__edge}"
}
},
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/tests/NRedisStack.Tests/NRedisStack.Tests.csproj",
"/p:CollectCoverage=true",
"/p:CoverletOutputFormat=lcov",
"/p:CoverletOutput=./lcov.info"
],
"problemMatcher": "$msCompile"
},
{
"label": "test all",
"dependsOrder": "sequence",
"dependsOn": [
"test 6.2.6",
"test 7.2.0",
"test edge"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "test",
Expand Down
60 changes: 58 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,67 @@ Here's how to get started with your code contribution:
2. Do the changes in your fork
3. Write your tests

4. Use the `docker run -p 6379:6379 -it redis/redis-stack-server:edge` as your local environment for running the functional tests.
5. Make sure your tests pass using `dotnet test'
4. Use the `docker run -p 6379:6379 -it redis/redis-stack-server:edge` as your local environment for running the functional tests. You can also use Development Container as described below.
5. Make sure your tests pass using `dotnet test`
6. Push your changes to GitHub
7. Open a pull request

## Development Container

Development Containers are an easy way to define and setup a reproducible development environment by using containers.
NRedisStack provides a [development container environment](https://containers.dev/) that can be used to get running relatively fast without focusing on the different Redis deployments.

The development container comes packed with .NET 6 and 7, required by the testing suite, as well as the currently supported Redis versions that are run as part of the CI pipeline.

Development containers are supported in a few [editors](https://containers.dev/supporting#editors) or by using the [`devcontainer-cli` tool](https://github.com/devcontainers/cli).

This guide explains how to use the existing development container setup for this project.

### Prerequisites

Before you start, make sure you have the following installed:

- [Visual Studio Code](https://code.visualstudio.com/)
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code

### Steps to Use the Existing Development Container Setup

1. **Clone the Project:** Start by cloning the project's repository to your local machine using Git.

2. **Install Prerequisites:** Ensure you have Visual Studio Code and the Dev Containers extension installed.

3. **Open in Development Container:**

a. Open the cloned project directory using Visual Studio Code.

b. VS Code should detect the `.devcontainer` folder and the associated configuration files.

c. You will likely see a notification suggesting reopening the project in a development container:
![devcontainer notification](./docs/devcontainerNotification.png)

Click on this notification or press `Ctrl + Shift + P` (or `Cmd + Shift + P` on Mac) and type _"Dev Containers: Reopen in Container"_. Select the suggestion that appears.

d. Visual Studio Code will build the Docker image according to the configuration and start a container using the specified setup.

4. **Develop Inside the DevContainer:**

You're now working within the development container environment. Access extensions, dependencies, and settings specified in `devcontainer.json`. Edit code, use the integrated terminal, and run commands as usual.

5. **Save and Commit:**

Changes made within the development container will be saved to your local repository. Use Git within the container to manage changes, create branches, commit, and push code.

6. **Stop the DevContainer:**

Close the development container by clicking the "Close Remote Connection" button in the bottom-left corner of the VS Code window. This stops the container while preserving changes.

7. **Resume Work:**

Reopen the project in the development container to work on it again using the same steps.

By using the existing `.devcontainer` setup, you benefit from a consistent development environment tailored to the project's requirements. For specific configuration details or issues, consult the project documentation or ask maintainers for assistance.


## Testing

Call `dotnet test` to run all tests
Expand Down
Binary file added docs/devcontainerNotification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions tests/NRedisStack.Tests/RedisFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ namespace NRedisStack.Tests
{
public class RedisFixture : IDisposable
{


// Set the enviroment variable to specify your own alternet host and port:
string redis = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379";
public RedisFixture() => Redis = ConnectionMultiplexer.Connect($"{redis}");
public RedisFixture()
{
// Set the enviroment variable to specify your own alternet host and port:
var redisConnectionString = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379";
Redis = ConnectionMultiplexer.Connect(redisConnectionString);
}

public void Dispose()
{
Redis.Close();
}

public ConnectionMultiplexer Redis { get; private set; }
public ConnectionMultiplexer Redis { get; }
}
}