Skip to content

Commit 23d111a

Browse files
2 parents ebd0b9d + cf6ce8d commit 23d111a

File tree

5 files changed

+69
-57
lines changed

5 files changed

+69
-57
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
target-framework: [net6.0]
1312
grpc-web: [false, true]
14-
include:
15-
- os: windows-latest
16-
target-framework: net462
17-
grpc-web: false
18-
- os: windows-latest
19-
target-framework: net462
20-
grpc-web: true
2113
runs-on: ${{ matrix.os }}
2214
env:
2315
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
@@ -50,13 +42,10 @@ jobs:
5042
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5143

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

55-
- name: Unit Test
56-
run: dotnet test --logger "console;verbosity=detailed" -f ${{ matrix.target-framework }} tests/Unit/Momento.Sdk.Tests
57-
58-
- name: Integration Test
59-
run: dotnet test --logger "console;verbosity=detailed" -f ${{ matrix.target-framework }} tests/Integration/Momento.Sdk.Tests
47+
- name: Test
48+
run: make test
6049

6150
build_examples:
6251
runs-on: ubuntu-latest

.github/workflows/on-push-to-main-branch.yaml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
target-framework: [net6.0]
1312
grpc-web: [false, true]
14-
include:
15-
- os: windows-latest
16-
target-framework: net462
17-
grpc-web: false
18-
- os: windows-latest
19-
target-framework: net462
20-
grpc-web: true
2113
runs-on: ${{ matrix.os }}
2214
env:
2315
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
@@ -37,13 +29,10 @@ jobs:
3729
dotnet-version: "6.0.x"
3830

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

42-
- name: Unit Test
43-
run: dotnet test -f ${{ matrix.target-framework }} tests/Unit/Momento.Sdk.Tests
44-
45-
- name: Integration Test
46-
run: dotnet test -f ${{ matrix.target-framework }} tests/Integration/Momento.Sdk.Tests
34+
- name: Test
35+
run: make test
4736

4837
generate_readme:
4938
runs-on: ubuntu-latest

.github/workflows/on-push-to-release-branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
dotnet-version: "6.0.x"
4646

4747
- name: Build
48-
run: dotnet build
48+
run: make build
4949

5050
- name: Pack and Publish
5151
run: |
@@ -57,7 +57,7 @@ jobs:
5757
dotnet pack -c Release -p:Version=${VERSION}
5858
dotnet nuget push ./bin/Release/Momento.Sdk.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key=${{secrets.NUGET_API_KEY}}
5959
popd
60-
60+
6161
- name: Build for Unity
6262
run: |
6363
set -x

CONTRIBUTING.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
# Running tests
22

3-
Unless you are testing older .NET runtimes on Windows, you should run the tests against the newer runtimes as follows:
4-
- https://dotnet.microsoft.com/en-us/download/dotnet/6.0
3+
## Recommended
4+
5+
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.
6+
7+
## Specifics
8+
9+
You can explicitly run the tests against the newer runtimes as follows:
10+
11+
- https://dotnet.microsoft.com/en-us/download/dotnet/6.0
512

613
```
7-
MOMENTO_API_KEY=$your_momento_token make test-net6
14+
MOMENTO_API_KEY=$your_momento_token make test-dotnet6
815
```
916

1017
To test against older .NET runtimes run:
1118

1219
```
13-
MOMENTO_API_KEY=$your_momento_token make test-net-framework
20+
MOMENTO_API_KEY=$your_momento_token make test-dotnet-framework
1421
```
1522

1623
To run specific tests:

Makefile

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,88 @@
1-
.PHONY: all
1+
.PHONY: all build build-dotnet6 build-dotnet-framework clean clean-build precommit restore test test-dotnet6 test-dotnet-framework run-examples help
2+
3+
# Determine the operating system
4+
OS := $(shell uname)
5+
6+
# Set the default .NET version to .NET 6.0
7+
DOTNET_VERSION := net6.0
8+
TEST_LOGGER_OPTIONS := --logger "console;verbosity=detailed"
9+
10+
# Windows-specific settings
11+
# This tests if "NT" is in the OS string, which would indicate Windows.
12+
ifneq (,$(findstring NT,$(OS)))
13+
BUILD_TARGETS := build-dotnet6 build-dotnet-framework
14+
TEST_TARGETS := test-dotnet6 test-dotnet-framework
15+
else
16+
BUILD_TARGETS := build-dotnet6
17+
TEST_TARGETS := test-dotnet6
18+
endif
19+
20+
# Enable gRPC-Web if requested
21+
GRPC_WEB_FLAG :=
22+
ifeq ($(GRPC_WEB), true)
23+
GRPC_WEB_FLAG := -p:DefineConstants=USE_GRPC_WEB
24+
endif
25+
226
## Generate sync unit tests, format, lint, and test
327
all: precommit
428

529

6-
.PHONY: build
7-
## Build project
8-
build:
9-
@dotnet build
30+
## Build the project (conditioned by OS)
31+
build: ${BUILD_TARGETS}
32+
33+
34+
## Build the project for .NET 6.0
35+
build-dotnet6:
36+
@echo "Building the project for .NET 6.0..."
37+
@dotnet build -f ${DOTNET_VERSION} ${GRPC_WEB_FLAG}
38+
1039

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

12-
.PHONY: clean
1345
## Remove build files
1446
clean:
47+
@echo "Cleaning build artifacts..."
1548
@dotnet clean
1649

1750

18-
.PHONY: clean-build
1951
## Build project
20-
clean-build: clean restore build
52+
clean-build: clean restore ${BUILD_TARGETS}
2153

2254

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

2758

28-
.PHONY: restore
2959
## Sync dependencies
3060
restore:
61+
@echo "Restoring dependencies..."
3162
@dotnet restore
3263

3364

34-
.PHONY: test
35-
## Run unit and integration tests
36-
test:
37-
@dotnet test
65+
## Run unit and integration tests (conditioned by OS)
66+
test: ${TEST_TARGETS}
3867

3968

40-
.PHONY: test-net6
4169
## Run unit and integration tests on the .NET 6.0 runtime
42-
test-net6:
43-
@dotnet test -f net6.0
70+
test-dotnet6:
71+
@echo "Running tests on .NET 6.0..."
72+
@dotnet test ${TEST_LOGGER_OPTIONS} -f ${DOTNET_VERSION}
4473

4574

46-
.PHONY: test-net-framework
47-
## Run unit and integration tests on the .NET Framework runtime
48-
test-net-framework:
49-
@dotnet test -f net462
75+
## Run unit and integration tests on the .NET Framework runtime (Windows only)
76+
test-dotnet-framework:
77+
@echo "Running tests on .NET Framework 4.62 (Windows only)..."
78+
@dotnet test ${TEST_LOGGER_OPTIONS} -f net462
5079

5180

52-
.PHONY: run-examples
5381
## Run example applications and snippets
5482
run-examples:
5583
@dotnet run --project examples/MomentoApplication
5684
@dotnet run --project examples/DocExampleApis
5785

5886
# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation.
59-
.PHONY: help
6087
help:
6188
@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 commit comments

Comments
 (0)