Skip to content

Feature/increase coverage unit tests (#239) #123

Feature/increase coverage unit tests (#239)

Feature/increase coverage unit tests (#239) #123

Workflow file for this run

name: Deploy to GitHub Pages
concurrency:
group: github-pages
cancel-in-progress: true
# Run workflow on every push to the master branch
on:
push:
branches: [ dev ]
paths-ignore:
- '**.md'
jobs:
deploy-to-github-pages:
# use ubuntu-latest image to run steps on
runs-on: ubuntu-latest
environment: github-pages
needs: demo-projects-build
steps:
# uses GitHub's checkout action to checkout code form the master branch
- uses: actions/checkout@v3
# sets up .NET Core SDK 7, 6
- name: Setup .NET 7, 6
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: src/Cropper.Blazor
- name: Build
run: dotnet build --no-restore
working-directory: src/Cropper.Blazor
- name: Test
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByAttribute='ExcludeFromCodeCoverage' /p:SkipAutoProps=true /p:Exclude="[*]Cropper.Blazor.Testing.*"
working-directory: src/Cropper.Blazor/Cropper.Blazor.UnitTests
- name: Coverage
uses: codecov/[email protected]
with:
file: coverage.net6.0.cobertura.xml
fail_ci_if_error: true
verbose: true
# publishes Blazor project to the release-folder
- name: Publish .NET Core Project
run: dotnet publish ./src/Cropper.Blazor/Server/Cropper.Blazor.Server.csproj -c Release --output release --nologo
# changes the base-tag in index.html from '/' to 'Cropper.Blazor' to match GitHub Pages repository subdirectory
#- name: Change base-tag in index.html from / to Cropper.Blazor
# run: sed -i 's/<base href="\/" \/>/<base href="\/Cropper.Blazor\/" \/>/g' release/wwwroot/index.html
- name: Fix service-worker-assets.js hashes
working-directory: release/wwwroot
run: |
jsFile=$(<service-worker-assets.js)
# remove JavaScript from contents so it can be interpreted as JSON
json=$(echo "$jsFile" | sed "s/self.assetsManifest = //g" | sed "s/;//g")
# grab the assets JSON array
assets=$(echo "$json" | jq '.assets[]' -c)
for asset in $assets
do
oldHash=$(echo "$asset" | jq '.hash')
#remove leading and trailing quotes
oldHash="${oldHash:1:-1}"
path=$(echo "$asset" | jq '.url')
#remove leading and trailing quotes
path="${path:1:-1}"
# shellcheck disable=2086
newHash="sha256-$(openssl dgst -sha256 -binary $path | openssl base64 -A)"
# shellcheck disable=2086
if [ $oldHash != $newHash ]; then
# escape slashes for json
# shellcheck disable=2001
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
# shellcheck disable=2001
newHash=$(echo "$newHash" | sed 's;/;\\/;g')
echo "Updating hash for $path from $oldHash to $newHash"
# escape slashes second time for sed
# shellcheck disable=2001
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
jsFile=$(echo -n "$jsFile" | sed "s;$oldHash;$newHash;g")
fi
done
echo -n "$jsFile" > service-worker-assets.js
# copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll
- name: Uploading files to gh-pages branch
uses: JamesIves/[email protected]
with:
token: ${{ secrets.DEPLOY_KEY }}
branch: gh-pages
folder: release/wwwroot
repository-name: CropperBlazor/CropperBlazor.github.io
demo-projects-build:
name: Build Demo Projects
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
# sets up .NET Core SDK 7, 6
- name: Setup .NET 7, 6
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install MAUI Workloads
run: |
dotnet workload install maui --ignore-failed-sources
- name: Restore dependencies for Cropper.Blazor.Demo
run: dotnet restore
working-directory: examples
- name: DotNet Build MVC with Blazor Server Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.MVC.With.Blazor.Server.Net7
- name: DotNet Build Blazor Server Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.Server.Net7
- name: DotNet Build Blazor MAUI Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.MAUI.Net7
- name: DotNet Build Blazor Server Demo Project for .net 6
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.Server.Net6
- name: DotNet Build Blazor MAUI Demo Project for .net 6
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.MAUI.Net6