-
Notifications
You must be signed in to change notification settings - Fork 74
123 lines (120 loc) · 5.34 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: CI
on:
push:
branches: [ master ]
pull_request: ~
workflow_dispatch: ~
jobs:
lint:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: Set up dotnet tools
run: make install-tools
- name: Check dotnet Style
run: make lint
security:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: Set up dotnet tools
run: make install-tools
- name: Run security analysis
run: make scan
# TODO: In the future, we can collect the output logs by enabling Code Scanning and using the pre-built GitHub Action: https://github.com/marketplace/actions/securitycodescan
# https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github#uploading-a-code-scanning-analysis-with-github-actions
NET_Tests:
# derived from https://dev.to/felipetofoli/github-actions-for-net-full-framework-build-and-test-299h
runs-on: windows-2022
env:
EASYPOST_TEST_API_KEY: "123"
EASYPOST_PROD_API_KEY: "123"
strategy:
matrix:
name: [ 'NetStandard20', 'NetCore31', 'Net50', 'Net60' ]
include:
- name: NetStandard20
# can't run tests on .NET Standard, it's just a bridge between .NET Framework and .NET.
# So we'll target .NET Framework 4.6.2
# More notes at the bottom of this file
framework: net462
- name: NetCore31
framework: netcoreapp3.1
- name: Net50
framework: net5.0
- name: Net60
framework: net6.0
steps:
- uses: actions/checkout@v3
with:
submodules: true
# install MSBuild, used to build the test project
- name: Setup MSBuild
uses: microsoft/[email protected]
# install NuGet.exe to restore required NuGet packages
- name: Setup Nuget
uses: NuGet/[email protected]
# Load NuGet package cache
- name: Load NuGet package cache
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ matrix.framework }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
# Restore required NuGet packages
- name: Restore NuGet Packages
run: make restore
# Run the framework-specific tests
- name: Run Tests
run: make test-fw fw=${{ matrix.framework }}
Compatibility_Tests:
runs-on: windows-2022
strategy:
matrix:
lang: [ 'VB', 'FSharp' ]
include:
- lang: VB
ext: vbproj
- lang: FSharp
ext: fsproj
steps:
- uses: actions/checkout@v3
with:
submodules: true
# Set the project name, based on platform version currently selected
- name: Set up variables
id: test_project
run: echo "::set-output name=test_file::EasyPost.Tests.${{ matrix.lang }}"
# install MSBuild, used to build the test project
- name: Setup MSBuild
uses: microsoft/[email protected]
# install NuGet.exe to restore required NuGet packages
- name: Setup Nuget
uses: NuGet/[email protected]
# install Visual Studio's console test application, to execute tests
- name: Setup VSTest
uses: darenm/Setup-VSTest@v1
# Load NuGet package cache
- name: Load NuGet package cache
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ matrix.framework }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
# Restore required NuGet packages
- name: Restore NuGet Packages
run: make restore
# Build the test project
- name: Build Solution
run: msbuild ${{ steps.test_project.outputs.test_file }}\${{ steps.test_project.outputs.test_file }}.${{ matrix.ext }} /p:platform="Any CPU" /p:configuration="Debug" /p:outputPath="bin/Test" /p:target="Rebuild" -restore
# .NET Standard notes:
# - NET Standard 2.0 is compatible with minimum .NET Framework 4.6.1: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
# - NET Framework 4.6.1 is EOL after April 26, 2022, due to its security concerns (was affected by the SHA-1 crack): https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-framework
# - GitHub's Windows 2022 runner only supports minimum .NET Framework 4.6.2 anyway: https://github.com/actions/virtual-environments/issues/5055#issuecomment-1040757930
# - .NET Standard is not a framework, but a set of shared APIs between the old .NET Framework and new .NET/.NET Core
# - `EasyPost` targets .NET Standard 2.0, meaning it is compatible with specific versions of both .NET and .NET Framework: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
# - When you want to actually run code, however, you can't run it in .NET Standard. You have to run it in either .NET or .NET Framework: https://stackoverflow.com/a/48885500/13343799
# - So, while `EasyPost` targets .NET Standard 2.0, `EasyPost.Tests`, the code we're actually executing, targets .NET Framework 4.6.2
# - By extension, this is ensuring we are testing that the `EasyPost` source code can run in a .NET Framework environment