Skip to content

Commit

Permalink
Merge pull request #40 from JSkimming/ci-test-refinements
Browse files Browse the repository at this point in the history
CI Test Refinements
  • Loading branch information
JSkimming authored May 6, 2019
2 parents 9b694f5 + 639b397 commit 5550dec
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 49 deletions.
24 changes: 15 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: 2.1

orbs:

shellcheck: circleci/shellcheck@1

build:
jobs:

Expand All @@ -22,17 +24,19 @@ orbs:
steps:
- checkout
- run:
name: Restore
command: dotnet restore
- run:
name: Build
command: dotnet build --no-restore -f << parameters.framework >> -c << parameters.build-config >> ./test/Tesla.NET.Tests/Tesla.NET.Tests.csproj
- run:
name: Test
command: dotnet test --no-restore --no-build -f << parameters.framework >> -c << parameters.build-config >> ./test/Tesla.NET.Tests/Tesla.NET.Tests.csproj /p:CollectCoverage=true /p:Include="[Tesla.NET]*" /p:Exclude="[*.Tests]*"
name: Test Coverage
command: ./coverage.sh << parameters.framework >> << parameters.build-config >>
- store_artifacts:
path: ./test/Tesla.NET.Tests/coverage.json
path: ./test/TestResults/coverage.json
destination: coverage.json
- store_artifacts:
path: ./test/TestResults/coverage.opencover.xml
destination: coverage.opencover.xml
- store_artifacts:
path: ./test/TestResults/Report/
destination: report
- store_test_results:
path: ./test/TestResults/output/

executors:

Expand All @@ -48,6 +52,8 @@ workflows:

"Build All Frameworks":
jobs:
- shellcheck/check:
name: shellcheck
- build/run-build:
name: 2.1 Debug Build
image-tag: "2.1"
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**/obj
**/bin
.vs
*.sh
.git
.gitignore
.circleci
Dockerfile
**/TestResults
69 changes: 54 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
Expand All @@ -12,13 +13,18 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
Expand Down Expand Up @@ -52,20 +58,21 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
Expand All @@ -75,6 +82,7 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
Expand Down Expand Up @@ -177,6 +185,8 @@ PublishScripts/

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand All @@ -201,12 +211,14 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
!?*.[Cc]ache/

# Others
ClientBin/
Expand All @@ -219,6 +231,10 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
Expand All @@ -233,6 +249,8 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak

# SQL Server files
*.mdf
Expand All @@ -243,6 +261,10 @@ UpgradeLog*.htm
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

# Microsoft Fakes
FakesAssemblies/
Expand All @@ -254,9 +276,6 @@ FakesAssemblies/
.ntvs_analysis.dat
node_modules/

# TypeScript v1 declaration files
typings/

# Visual Studio 6 build log
*.plg

Expand All @@ -281,12 +300,8 @@ paket-files/
# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/
# CodeRush personal settings
.cr/personal

# Python Tools for Visual Studio (PTVS)
__pycache__/
Expand All @@ -311,12 +326,27 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog

# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# =========================
# Operating System Files
# =========================
Expand All @@ -328,6 +358,9 @@ ASALocalRun/
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

Expand All @@ -338,6 +371,7 @@ ASALocalRun/
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
Expand All @@ -349,19 +383,24 @@ Temporary Items
# Windows
# =========================

# Windows image file caches
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
Desktop.ini
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ matrix:
dotnet: 2.1
mono: none
- os: osx
dotnet: 2.1.301
dotnet: 2.1.506
mono: none

branches:
only:
- master

script:
- dotnet test -c Release -f netcoreapp2.1 test/Tesla.NET.Tests/Tesla.NET.Tests.csproj /p:CollectCoverage=true /p:Include="[Tesla.NET]*" /p:Exclude="[*.Tests]*"
- ./coverage.sh netcoreapp2.1 Release
40 changes: 35 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
FROM microsoft/dotnet:2.1-sdk
########################################################################################################################
# shellcheck - lining for bash scrips
FROM nlknguyen/alpine-shellcheck:v0.4.6

COPY ./ ./

# Convert CRLF to CR as it causes shellcheck warnings.
RUN find . -type f -name '*.sh' -exec dos2unix {} \;

# Run shell check on all the shell files.
RUN find . -type f -name '*.sh' | wc -l && find . -type f -name '*.sh' | xargs shellcheck --external-sources

########################################################################################################################
# .NET Core 2.1
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-alpine

ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

Expand All @@ -14,8 +28,24 @@ RUN dotnet restore

COPY . .

# Build to ensure the tests are their own distinct step.
RUN dotnet build --no-restore -f netcoreapp2.1 -c Debug ./test/Tesla.NET.Tests/Tesla.NET.Tests.csproj
RUN ./coverage.sh netcoreapp2.1 Debug

########################################################################################################################
# .NET Core 2.2
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine

ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

WORKDIR /work

# Copy just the solution and proj files to make best use of docker image caching.
COPY ./tesla-net.sln .
COPY ./src/Tesla.NET/Tesla.NET.csproj ./src/Tesla.NET/Tesla.NET.csproj
COPY ./test/Tesla.NET.Tests/Tesla.NET.Tests.csproj ./test/Tesla.NET.Tests/Tesla.NET.Tests.csproj

# Run restore on just the project files, this should cache the image after restore.
RUN dotnet restore

COPY . .

# Run unit tests.
RUN dotnet test --no-restore --no-build -c Debug -f netcoreapp2.1 test/Tesla.NET.Tests/Tesla.NET.Tests.csproj /p:CollectCoverage=true /p:Include="[Tesla.NET*]*" /p:Exclude="[*.Tests]*"
RUN ./coverage.sh netcoreapp2.1 Debug
12 changes: 6 additions & 6 deletions coverage.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@
::@echo %xunit_exe%

@SET results_path=%~dp0test\TestResults
@SET test_assemblies=%~dp0test\Tesla.NET.Tests\bin\%config%\net47\Tesla.NET.Tests.dll
::@SET test_assemblies=%test_assemblies% %~dp0test\More.Tests\bin\%config%\net47\More.Tests.dll
@SET test_assemblies=%~dp0test\Tesla.NET.Tests\bin\%config%\net472\Tesla.NET.Tests.dll
::@SET test_assemblies=%test_assemblies% %~dp0test\More.Tests\bin\%config%\net472\More.Tests.dll
@SET xunit_results=%results_path%\Xunit.Tests.html
@SET coverage_filter=+[Tesla.NET*]* -[*.Tests]*
@SET coverage_results=%results_path%\Test.Coverage.xml

@IF NOT EXIST "%results_path%" MD "%results_path%"

@echo dotnet build --configuration %config% "%~dp0test\Tesla.NET.Tests\Tesla.NET.Tests.csproj"
@dotnet build --configuration %config% "%~dp0test\Tesla.NET.Tests\Tesla.NET.Tests.csproj"
@echo dotnet build --framework net472 --configuration %config% "%~dp0test\Tesla.NET.Tests\Tesla.NET.Tests.csproj"
@dotnet build --framework net472 --configuration %config% "%~dp0test\Tesla.NET.Tests\Tesla.NET.Tests.csproj"
@IF ERRORLEVEL 1 (
echo Error building the test project
EXIT /B 2
Expand All @@ -70,5 +70,5 @@
EXIT /B 2
)

@echo "%report_exe%" -verbosity:Error "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
@"%report_exe%" -verbosity:Error "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
@echo "%report_exe%" -verbosity:Info "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
@"%report_exe%" -verbosity:Info "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
Loading

0 comments on commit 5550dec

Please sign in to comment.