Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
2 parents ebd0b9d + cf6ce8d commit 23d111a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 57 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
target-framework: [net6.0]
grpc-web: [false, true]
include:
- os: windows-latest
target-framework: net462
grpc-web: false
- os: windows-latest
target-framework: net462
grpc-web: true
runs-on: ${{ matrix.os }}
env:
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
Expand Down Expand Up @@ -50,13 +42,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: dotnet build ${{ matrix.grpc-web && '-p:DefineConstants=USE_GRPC_WEB' || '' }}
run: make GRPC_WEB=${{ matrix.grpc-web }} build

- name: Unit Test
run: dotnet test --logger "console;verbosity=detailed" -f ${{ matrix.target-framework }} tests/Unit/Momento.Sdk.Tests

- name: Integration Test
run: dotnet test --logger "console;verbosity=detailed" -f ${{ matrix.target-framework }} tests/Integration/Momento.Sdk.Tests
- name: Test
run: make test

build_examples:
runs-on: ubuntu-latest
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/on-push-to-main-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
target-framework: [net6.0]
grpc-web: [false, true]
include:
- os: windows-latest
target-framework: net462
grpc-web: false
- os: windows-latest
target-framework: net462
grpc-web: true
runs-on: ${{ matrix.os }}
env:
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
Expand All @@ -37,13 +29,10 @@ jobs:
dotnet-version: "6.0.x"

- name: Build
run: dotnet build ${{ matrix.grpc-web && '-p:DefineConstants=USE_GRPC_WEB' || '' }}
run: make GRPC_WEB=${{ matrix.grpc-web }} build

- name: Unit Test
run: dotnet test -f ${{ matrix.target-framework }} tests/Unit/Momento.Sdk.Tests

- name: Integration Test
run: dotnet test -f ${{ matrix.target-framework }} tests/Integration/Momento.Sdk.Tests
- name: Test
run: make test

generate_readme:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-push-to-release-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
dotnet-version: "6.0.x"

- name: Build
run: dotnet build
run: make build

- name: Pack and Publish
run: |
Expand All @@ -57,7 +57,7 @@ jobs:
dotnet pack -c Release -p:Version=${VERSION}
dotnet nuget push ./bin/Release/Momento.Sdk.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key=${{secrets.NUGET_API_KEY}}
popd
- name: Build for Unity
run: |
set -x
Expand Down
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Running tests

Unless you are testing older .NET runtimes on Windows, you should run the tests against the newer runtimes as follows:
- https://dotnet.microsoft.com/en-us/download/dotnet/6.0
## Recommended

The Makefile target `test` runs against .NET 6.0 and has additional OS-conditional logic to run .NET Framework tests on Windows. Use this target by default.

## Specifics

You can explicitly run the tests against the newer runtimes as follows:

- https://dotnet.microsoft.com/en-us/download/dotnet/6.0

```
MOMENTO_API_KEY=$your_momento_token make test-net6
MOMENTO_API_KEY=$your_momento_token make test-dotnet6
```

To test against older .NET runtimes run:

```
MOMENTO_API_KEY=$your_momento_token make test-net-framework
MOMENTO_API_KEY=$your_momento_token make test-dotnet-framework
```

To run specific tests:
Expand Down
73 changes: 50 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,88 @@
.PHONY: all
.PHONY: all build build-dotnet6 build-dotnet-framework clean clean-build precommit restore test test-dotnet6 test-dotnet-framework run-examples help

# Determine the operating system
OS := $(shell uname)

# Set the default .NET version to .NET 6.0
DOTNET_VERSION := net6.0
TEST_LOGGER_OPTIONS := --logger "console;verbosity=detailed"

# Windows-specific settings
# This tests if "NT" is in the OS string, which would indicate Windows.
ifneq (,$(findstring NT,$(OS)))
BUILD_TARGETS := build-dotnet6 build-dotnet-framework
TEST_TARGETS := test-dotnet6 test-dotnet-framework
else
BUILD_TARGETS := build-dotnet6
TEST_TARGETS := test-dotnet6
endif

# Enable gRPC-Web if requested
GRPC_WEB_FLAG :=
ifeq ($(GRPC_WEB), true)
GRPC_WEB_FLAG := -p:DefineConstants=USE_GRPC_WEB
endif

## Generate sync unit tests, format, lint, and test
all: precommit


.PHONY: build
## Build project
build:
@dotnet build
## Build the project (conditioned by OS)
build: ${BUILD_TARGETS}


## Build the project for .NET 6.0
build-dotnet6:
@echo "Building the project for .NET 6.0..."
@dotnet build -f ${DOTNET_VERSION} ${GRPC_WEB_FLAG}


## Build the project on .NET Framework
build-dotnet-framework:
@echo "Building the project for .NET Framework 4.62..."
@dotnet build -f net462 ${GRPC_WEB_FLAG}

.PHONY: clean
## Remove build files
clean:
@echo "Cleaning build artifacts..."
@dotnet clean


.PHONY: clean-build
## Build project
clean-build: clean restore build
clean-build: clean restore ${BUILD_TARGETS}


.PHONY: precommit
## Run clean-build and test as a step before committing.
precommit: clean-build test


.PHONY: restore
## Sync dependencies
restore:
@echo "Restoring dependencies..."
@dotnet restore


.PHONY: test
## Run unit and integration tests
test:
@dotnet test
## Run unit and integration tests (conditioned by OS)
test: ${TEST_TARGETS}


.PHONY: test-net6
## Run unit and integration tests on the .NET 6.0 runtime
test-net6:
@dotnet test -f net6.0
test-dotnet6:
@echo "Running tests on .NET 6.0..."
@dotnet test ${TEST_LOGGER_OPTIONS} -f ${DOTNET_VERSION}


.PHONY: test-net-framework
## Run unit and integration tests on the .NET Framework runtime
test-net-framework:
@dotnet test -f net462
## Run unit and integration tests on the .NET Framework runtime (Windows only)
test-dotnet-framework:
@echo "Running tests on .NET Framework 4.62 (Windows only)..."
@dotnet test ${TEST_LOGGER_OPTIONS} -f net462


.PHONY: run-examples
## Run example applications and snippets
run-examples:
@dotnet run --project examples/MomentoApplication
@dotnet run --project examples/DocExampleApis

# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation.
.PHONY: help
help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|LC_ALL='C' sort -f|awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'|more $(shell test $(shell uname) == Darwin && echo '-Xr')

0 comments on commit 23d111a

Please sign in to comment.