Skip to content

Commit

Permalink
[chore] Account for Apple Silicon in development (#519)
Browse files Browse the repository at this point in the history
- Check for Apple Silicon in dotnet setup script
- Clarify Apple Silicon compatibility for unit tests
  • Loading branch information
nwithan8 authored Sep 20, 2023
1 parent 330c055 commit 457aa5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions scripts/unix/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 457aa5e

Please sign in to comment.