Skip to content

Commit

Permalink
Configure CI (no. 116)
Browse files Browse the repository at this point in the history
  • Loading branch information
cafour committed May 25, 2021
1 parent 9fc0473 commit 2f1e054
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 83 deletions.
89 changes: 6 additions & 83 deletions .azure/pipelines/ci.yml
Expand Up @@ -10,12 +10,9 @@ variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1

jobs:
- job: crossplatformBuild
displayName: Build cross-platform projects (Linux)
pool:
name: DockerAgentsLinux
demands: Agent.OS -equals Linux
# container: docker-reg.riganti.cz/dotvvm-ci:linux
- job: testLinux
displayName: Run tests on Linux
pool: DockerAgentsLinux
workspace:
clean: all
steps:
Expand All @@ -24,90 +21,16 @@ jobs:
key: '"npm" | "$(Agent.OS)" | src/DotVVM.Framework/package.json'
path: $(DOTVVM_ROOT)/.npm
restoreKeys: '"npm" | "$(Agent.OS)"'
- script: npm ci --cache $(DOTVVM_ROOT)/.npm --prefer-offline
workingDirectory: src/DotVVM.Framework
- script: npm run build
workingDirectory: src/DotVVM.Framework
- task: Cache@2
inputs:
key: '"nuget" | "$(Agent.OS)" | **/*.csproj | **/packages.config'
path: $(DOTVVM_ROOT)/.nuget
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: ci/linux/Linux.sln
packagesDirectory: $(DOTVVM_ROOT)/.nuget
- task: DotNetCoreCLI@2
inputs:
command: build
projects: ci/linux/Linux.sln
arguments: --no-restore --configuration $(BUILD_CONFIGURATION)
- publish: $(DOTVVM_ROOT)/artifacts
name: crossplatformBuild

- job: unitTestsCrossplatform
displayName: Run cross-platform unit tests (Linux)
pool:
name: DockerAgentsLinux
demands: Agent.OS -equals Linux
# container: docker-reg.riganti.cz/dotvvm-ci:linux
dependsOn: crossplatformBuild
workspace:
clean: all
steps:
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: crossplatformBuild
path: $(DOTVVM_ROOT)/artifacts
- task: Cache@2
inputs:
key: '"nuget" | "$(Agent.OS)" | **/*.csproj | **/packages.config'
path: $(DOTVVM_ROOT)/.nuget
- task: DotNetCoreCLI@2
inputs:
command: test
projects: src/DotVVM.Framework.Tests.Common
arguments: --no-build --configuration $(BUILD_CONFIGURATION)
publishTestResults: true

- job: uiTestsCrossplatform
displayName: Run UI tests (Linux)
pool:
name: DockerAgentsLinux
demands: Agent.OS -equals Linux
# container: docker-reg.riganti.cz/dotvvm-ci:linux
dependsOn: crossplatformBuild
workspace:
clean: all
steps:
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: crossplatformBuild
path: $(DOTVVM_ROOT)/artifacts
- script: Xvfb $DISPLAY -screen 0 800x600x16 &
- task: Cache@2
inputs:
key: '"nuget" | "$(Agent.OS)" | **/*.csproj | **/packages.config'
path: $(DOTVVM_ROOT)/.nuget
- script: find $(DOTVVM_ROOT)/artifacts -type f -exec chmod +rwx {} \;
- script: |
dotnet run --project src/DotVVM.Samples.BasicSamples.AspNetCoreLatest \
--no-build \
--configuration $(BUILD_CONFIGURATION) \
--urls http://localhost:16018/ &
- script: |
dotnet test src/DotVVM.Samples.Tests \
--no-build \
--configuration $(BUILD_CONFIGURATION) \
--logger trx \
--results-directory $(Agent.TempDirectory)
continueOnError: true
- script: ./ci/linux/run.sh
displayName: run.sh
- task: PublishTestResults@2
inputs:
testResultsFormat: VSTest
testResultsFiles: $(Agent.TempDirectory)/**/*.trx
testResultsFiles: $(DOTVVM_ROOT)/artifacts/test/**/*.trx
failTaskOnFailedTests: true
buildConfiguration: $(BUILD_CONFIGURATION)

Expand Down
54 changes: 54 additions & 0 deletions ci/linux/run.sh
@@ -0,0 +1,54 @@
#/bin/bash

ROOT=${DOTVVM_ROOT:-$(pwd)}
CONFIGURATION=${BUILD_CONFIGURATION:-Release}
TEST_RESULTS_DIR=$ROOT/artifacts/tests
DISPLAY=${DISPLAY:-":42"}
echo "ROOT=$DOTVVM_ROOT"
echo "CONFIGURATION=$CONFIGURATION"

cd $ROOT/src/DotVVM.Framework \
&& npm ci --cache $(DOTVVM_ROOT)/.npm --prefer-offline \
&& npm run build

if [ $? -ne 0 ]; then
echo >&2 "npm build failed"
exit 1
fi

# override DOTVVM_ROOT in case this is a local build
export DOTVVM_ROOT=$ROOT

cd $ROOT \
&& dotnet restore $ROOT/ci/linux/Linux.sln --packages $ROOT/.nuget\
&& dotnet build $ROOT/ci/linux/Linux.sln --no-restore --configuration $CONFIGURATION

if [ $? -ne 0 ]; then
echo >&2 "dotnet build failed"
exit 1
fi

dotnet test src/DotVVM.Framework.Tests.Common \
--no-build \
--configuration $CONFIGURATION \
--logger trx \
--results-directory $TEST_RESULTS_DIR

killall Xvfb dotnet 2>/dev/null

Xvfb $DISPLAY -screen 0 800x600x16 &
XVFB_PID=$!

dotnet run --project src/DotVVM.Samples.BasicSamples.AspNetCoreLatest \
--no-build \
--configuration $CONFIGURATION \
--urls http://localhost:16018/ &
SAMPLES_PID=$!

dotnet test src/DotVVM.Samples.Tests \
--no-build \
--configuration $CONFIGURATION \
--logger trx \
--results-directory $TEST_RESULTS_DIR

kill $XVFB_PID $SAMPLES_PID 2>/dev/null

0 comments on commit 2f1e054

Please sign in to comment.