Skip to content

Commit

Permalink
Update build and CI file
Browse files Browse the repository at this point in the history
* Update project.json for unit tests.
* Add tags and icon URL.
* Update appveyor.yml
* Other cleanup from maxmind/GeoIP2-dotnet#68
  • Loading branch information
oschwald committed Jul 14, 2016
1 parent 82b2029 commit 833ac92
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 77 deletions.
83 changes: 48 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,63 @@
---
sudo: false
language: csharp
# dotnet cli require Ubuntu 14.04
sudo: required
dist: trusty

# dotnet cli require OSX 10.10
osx_image: xcode7.1
language: generic

addons:
apt:
packages:
- gettext
- libcurl4-openssl-dev
- libicu-dev
- libssl-dev
- libunwind8

os:
- osx
- linux
- zlib1g

env:
matrix:
- CLI_VERSION: Latest
Configuration: Debug
Framework: netstandard1.6
- CLI_VERSION: Latest
Configuration: Release
Framework: netstandard1.6
global:
- MAXMIND_TEST_BASE_DIR=MaxMind.MinFraud.UnitTest

matrix:
include:
- os: linux
dist: trusty # Ubuntu 14.04
sudo: required
env: CONFIGURATION=Debug
- os: linux
dist: trusty
sudo: required
env: CONFIGURATION=Release
- os: osx
osx_image: xcode7.2 # macOS 10.11
env: CONFIGURATION=Debug
- os: osx
osx_image: xcode7.2
env: CONFIGURATION=Release

before_install:
# Install OpenSSL
# Also set download URLs obtained from https://www.microsoft.com/net/download#core
- if test "$TRAVIS_OS_NAME" == "osx"; then
brew update;
brew install openssl;
brew link --force openssl;
export DOTNET_SDK_URL="https://go.microsoft.com/fwlink/?LinkID=809128";
else
export DOTNET_SDK_URL="https://go.microsoft.com/fwlink/?LinkID=809129";
fi

# Download script to install dotnet cli
- curl -L --create-dirs https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.sh -o ./scripts/install.sh

- export DOTNET_INSTALL_DIR="$PWD/.dotnetcli"

# Install the latest versio of dotnet CLI
- bash ./scripts/install.sh --version "$CLI_VERSION" --install-dir "$DOTNET_INSTALL_DIR" --no-path
# Install .NET CLI
- mkdir $DOTNET_INSTALL_DIR
- curl -L $DOTNET_SDK_URL -o dotnet_package
- tar -xvzf dotnet_package -C $DOTNET_INSTALL_DIR

# Add dotnet to PATH
- export PATH="$DOTNET_INSTALL_DIR:$PATH"

install:
# Update submodules
- git submodule update --init --recursive

install:
# Display dotnet version info
- which dotnet;
if [ $? -eq 0 ]; then
echo "Using dotnet:";
Expand All @@ -56,19 +67,21 @@ install:
exit 1;
fi

# Restore dependencies
- dotnet restore
# Hack for: https://github.com/dotnet/cli/issues/3658
- if test "$TRAVIS_OS_NAME" == "linux"; then
nvm install stable && nvm use stable;
fi

- FrameworkLibsMoniker="netstandard1.4"
# Restore Packages
- dotnet restore

# Build projects
- dotnet build -c $Configuration -f $FrameworkLibsMoniker ./MaxMind.MinFraud
- dotnet build -c $Configuration -f $Framework ./MaxMind.MinFraud.UnitTest
# Build Projects
- dotnet build -c $CONFIGURATION -f netstandard1.4 ./MaxMind.MinFraud
- dotnet build -c $CONFIGURATION -f netcoreapp1.0 ./MaxMind.MinFraud.UnitTest

script:
# Run tests
- cd ./MaxMind.MinFraud.UnitTest
- dotnet test -f $Framework -c $Configuration
# Run Unit Tests
- dotnet test -f netcoreapp1.0 -c $CONFIGURATION MaxMind.MinFraud.UnitTest

notifications:
email:
Expand Down
27 changes: 23 additions & 4 deletions MaxMind.MinFraud.UnitTest/Request/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,32 @@ public static Transaction CreateFullRequest()
);
}

public static string CurrentDirectory =>
Directory.GetCurrentDirectory();
private static string GetTestDirectory()
{
// check if environment variable MAXMIND_TEST_BASE_DIR is set
string dbPath = Environment.GetEnvironmentVariable("MAXMIND_TEST_BASE_DIR");

if (!string.IsNullOrEmpty(dbPath))
{
if (!Directory.Exists(dbPath))
{
throw new ArgumentException("Path set as environment variable MAXMIND_TEST_BASE_DIR does not exist!");
}

return dbPath;
}

#if !NETCOREAPP1_0
return Environment.CurrentDirectory;
#else
return Directory.GetCurrentDirectory();
#endif
}

public static string ReadJsonFile(string name)
{
return
File.ReadAllText(Path.Combine(CurrentDirectory, "TestData",
File.ReadAllText(Path.Combine(GetTestDirectory(), "TestData",
$"{name}.json"));
}

Expand All @@ -137,4 +156,4 @@ public static bool VerifyRequestFor(string service, HttpRequestMessage message)
return JToken.DeepEquals(expectedRequest, request);
}
}
}
}
12 changes: 3 additions & 9 deletions MaxMind.MinFraud.UnitTest/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,18 @@
},
"dotnet-test-nunit": "3.4.0-beta-1",
"MockHttpSigned": "1.3.0-netstandard-alpha3",
"NETStandard.Library": "1.6.0",
"NUnit": "3.2.1"
},
"testRunner": "nunit",
"frameworks": {
"net451": {},
"netstandard1.6": {
"imports": [
"dnxcore50",
"netcoreapp1.0",
"portable-net45+win8"
],
"netcoreapp1.0": {
"imports": "portable-net45+win8",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Console": "4.0.0"
}
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions MaxMind.MinFraud/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"authors": [
"MaxMind, Inc."
],
"tags": [
""
],
"tags": ["maxmind", "minfraud", "fraud", "detection"],
"iconUrl": "https://raw.githubusercontent.com/maxmind/GeoIP2-dotnet/master/MaxMind-logo.png",
"projectUrl": "https://github.com/maxmind/minfraud-api-dotnet",
"licenseUrl": "https://github.com/maxmind/minfraud-api-dotnet/blob/master/LICENSE",
"copyright": "Copyright © 2015-2016"
Expand Down
58 changes: 33 additions & 25 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ version: '1.0.{build}'
os: Visual Studio 2015

environment:
global:
MAXMIND_TEST_BASE_DIR: MaxMind.MinFraud.UnitTest
matrix:
- Configuration: Debug
Framework: net451
- Configuration: Release
Framework: net451
- Configuration: Debug
Framework: netstandard1.6
- Configuration: Release
Framework: netstandard1.6
- CONFIGURATION: Debug
FRAMEWORK: net45
SECONDARYFRAMEWORK: net451
FrameworkLibsMoniker: net45
- CONFIGURATION: Release
FRAMEWORK: net45
SECONDARYFRAMEWORK: net451
FrameworkLibsMoniker: net45
- CONFIGURATION: Debug
FRAMEWORK: netcoreapp1.0
SECONDARYFRAMEWORK: netcoreapp1.0
FrameworkLibsMoniker: netstandard1.4
- CONFIGURATION: Release
FRAMEWORK: netcoreapp1.0
SECONDARYFRAMEWORK: netcoreapp1.0
FrameworkLibsMoniker: netstandard1.4

build_script:
before_build:
- git submodule update --init --recursive

build_script:
- ps: |
if (gcm dotnet -errorAction SilentlyContinue) {
echo "Using dotnet '$((gcm dotnet).Path)'"
Expand All @@ -25,26 +37,22 @@ build_script:
echo "dotnet.exe not found"
exit 1
}
# Restore packages
# Restore Packages
dotnet restore
if($env:Framework -eq "net45") {
$FrameworkLibsMoniker = "net45"
} else {
$FrameworkLibsMoniker = "netstandard1.6"
}
# Build projects
dotnet build -c $env:Configuration -f $FrameworkLibsMoniker .\MaxMind.MinFraud
dotnet build -c $env:Configuration -f $env:Framework .\MaxMind.MinFraud.UnitTest
# Build Projects
dotnet build -c $env:CONFIGURATION -f $env:FrameworkLibsMoniker .\MaxMind.MinFraud
dotnet build -c $env:CONFIGURATION -f $env:SECONDARYFRAMEWORK .\MaxMind.MinFraud.UnitTest
test_script:
- ps: |
# Run tests
cd .\MaxMind.MinFraud.UnitTest
# Run Unit Tests
- dotnet test -f %SECONDARYFRAMEWORK% -c %CONFIGURATION% MaxMind.MinFraud.UnitTest

after_test:
# Run Unit Tests
- dotnet pack -c %CONFIGURATION% MaxMind.MinFraud

dotnet test -f $env:Framework -c $env:Configuration
artifacts:
- path: 'MaxMind.MinFraud\bin\**\*.nupkg'

notifications:
- auth_token:
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"MaxMind.MinFraud.UnitTests"
],
"sdk": {
"version": "1.0.0-preview1-002702"
"version": "1.0.0-preview2-003121"
}
}

0 comments on commit 833ac92

Please sign in to comment.