From 457aa5ef70b0d6a67b0decf6ac427e12f2febebf Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 20 Sep 2023 14:16:14 -0600 Subject: [PATCH] [chore] Account for Apple Silicon in development (#519) - Check for Apple Silicon in dotnet setup script - Clarify Apple Silicon compatibility for unit tests --- README.md | 19 ++++++++++++++----- scripts/unix/setup.sh | 7 +++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f927a3ea0..d4d448cd2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ namespace example static async Task Main() { Client client = new Client(new ClientConfiguration(Environment.GetEnvironmentVariable("EASYPOST_API_KEY"))); - + Parameters.Shipment.Create createParameters = new() { ToAddress = new Parameters.Address.Create { Name = "Dr. Steve Brule", @@ -67,9 +67,9 @@ namespace example } Shipment shipment = await client.Shipment.Create(parameters); - + Rate rate = shipment.LowestRate(); - + Paramaters.Shipment.Buy buyParameters = new(rate); Shipment purchasedShipment = await client.Shipment.Buy(shipment.Id, buyParameters); @@ -191,12 +191,12 @@ void OnRequestExecutingHandler(object? sender, OnRequestExecutingEventArgs args) // Interact with details about the HttpRequestMessage here via args System.Console.WriteLine($"Making HTTP call to {args.RequestUri}"); } - + void OnRequestResponseReceivedHandler(object? sender, OnRequestResponseReceivedEventArgs args) { // Interact with details about the HttpResponseMessage here via args System.Console.WriteLine($"Received HTTP response with status code {args.ResponseStatusCode}"); } - + Client client = new Client(new ClientConfiguration("EASYPOST_API_KEY") { Hooks = new Hooks { @@ -303,6 +303,15 @@ otherwise): Some tests may require a user with a particular set of enabled features such as a `Partner` user when creating referrals. We have attempted to call out these functions in their respective docstrings. +**NOTE** .NET Framework/.NET Standard unit tests cannot currently be run on Apple Silicon (M1, M2, etc.). Instead, run +unit tests in one framework at a time with, e.g `make unit-test fw=net7.0`. Valid frameworks: + +- `net462` (.NET Framework 4.6.2, will not run on Apple Silicon) +- `netcoreapp3.1` (.NET Core 3.1) +- `net5.0` (.NET 5.0) +- `net6.0` (.NET 6.0) +- `net7.0` (.NET 7.0) + #### Test Coverage Unit test coverage reports can be generated by running the `generate_test_reports.sh` Bash script from the root of this diff --git a/scripts/unix/setup.sh b/scripts/unix/setup.sh index b6bbf6099..6cfecaa9e 100644 --- a/scripts/unix/setup.sh +++ b/scripts/unix/setup.sh @@ -2,6 +2,13 @@ # This script is used to download and install the required .NET versions +# If running Apple Silicon, use brew instead +if [[ $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]; then + echo "Apple Silicon detected, using brew to install .NET..." + brew install dotnet + exit 0 +fi + # .NET versions we want to install declare -a NetVersions=("Current" "7.0" "6.0" "5.0" "3.1")