Skip to content

Persistence

Persistence #197

Workflow file for this run

name: Persistence
on:
schedule:
- cron: '30 21 * * *'
push:
branches:
- 'main'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
packages: write
actions: write
env:
VERSION: '2.1.${{ github.run_number }}'
jobs:
create_nuget_cache:
runs-on: ubuntu-latest
steps:
- name: Pull
uses: actions/checkout@v4
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Have nuget dependencies changed
uses: actions/cache@v4
id: nuget-cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Update Nuget Dependencies
run: |
dotnet tool install --global dotnet-outdated-tool
dotnet outdated --upgrade
dotnet restore
- name: Push
uses: stefanzweifel/git-auto-commit-action@v5
- name: Detect Changes
uses: dorny/paths-filter@v3
id: changed
with:
base: ${{ github.event_name == 'push' && github.event.before || github.sha }}
filters: |
changed:
- './**'
outputs:
DETECTED_CHANGES: ${{ steps.changed.outputs.changed }}
test_domain:
runs-on: ubuntu-latest
needs: [ create_nuget_cache ]
steps:
- name: Get nuget cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install Sql
uses: potatoqualitee/mssqlsuite@v1.7
with:
install: sqlengine
sa-password: c0MplicatedP@ssword
- name: Pull
uses: actions/checkout@v4
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Test
run: dotnet test ./Specs/Domain/Domain.csproj --configuration Release --environment ServerConnectionString="Server=localhost;Integrated security=False;User=sa;Password=c0MplicatedP@ssword;TrustServerCertificate=True;"
test_blob:
runs-on: ubuntu-latest
needs: [ create_nuget_cache ]
steps:
- name: Get nuget cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Install Azurite
run: npm install -g azurite
- name: Pull
uses: actions/checkout@v4
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Run Azurite in Background
shell: bash
run: azurite &
- name: Test
run: dotnet test ./Specs/Persistence.Blob/Persistence.Blob.csproj --configuration Release --environment RunAzurite="false"
test_cosmos:
runs-on: windows-latest
needs: [ create_nuget_cache ]
outputs:
windowsNugetHash: ${{ steps.cache-windows-nuget-hash.outputs.windowsNugetHash }}
steps:
- name: Pull
uses: actions/checkout@v4
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Start up emulator
run: |
Write-Host "Launching Cosmos DB Emulator"
Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
Start-CosmosDbEmulator -Timeout 600
Write-Host "Cosmos DB Emulator started"
- name: Cache nuget for windows
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Output nuget hash
id: cache-windows-nuget-hash
run: echo "::set-output name=windowsNugetHash::${{ hashFiles('**/*.csproj') }}"
- name: Test
run: dotnet test ./Specs/Persistence.Cosmos/Persistence.Cosmos.csproj --configuration Release --environment CiIsManagingEmulator="true"
test_dapper:
runs-on: ubuntu-latest
needs: [ create_nuget_cache ]
steps:
- name: Get nuget cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install Sql
uses: potatoqualitee/mssqlsuite@v1.7
with:
install: sqlengine
sa-password: c0MplicatedP@ssword
- name: Pull
uses: actions/checkout@v4
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Test
run: dotnet test ./Specs/Persistence.Dapper/Persistence.Dapper.csproj --configuration Release --environment ServerConnectionString="Server=localhost;Integrated security=False;User=sa;Password=c0MplicatedP@ssword;TrustServerCertificate=True;"
pack:
runs-on: ubuntu-latest
needs: [ create_nuget_cache ]
steps:
- name: Pull
uses: actions/checkout@v4
- name: Get nuget cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install .Net Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
source-url: https://nuget.pkg.github.com/sensemaking/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Cache packages
uses: actions/cache@v4
with:
path: ./packages
key: ${{ runner.os }}-packages-${{ github.run_id }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-packages-${{ github.run_id }}-${{ github.run_number }}
- name: Package
if: needs.create_nuget_cache.outputs.DETECTED_CHANGES == 'true'
run: dotnet pack -o packages -p:PackageVersion=${{env.VERSION}} --configuration Release /p:Configuration=Release /p:TreatWarningsAsErrors=true
push:
runs-on: ubuntu-latest
needs: [ create_nuget_cache, test_domain, test_blob, test_cosmos, test_dapper, pack ]
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Pull
uses: actions/checkout@v4
- name: Get packages cache
uses: actions/cache@v4
with:
path: ./packages
key: ${{ runner.os }}-packages-${{ github.run_id}}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-packages-${{ github.run_id}}-${{ github.run_number }}
- name: Publish Packages
if: needs.create_nuget_cache.outputs.DETECTED_CHANGES == 'true'
run: dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key ${{github.token}} --source https://nuget.pkg.github.com/sensemaking/index.json
- name: Cleanup cache
run: |
gh extension install actions/gh-actions-cache
cacheKeys=$(gh actions-cache list -R ${{ github.repository }} | cut -f 1)
set +e
for cacheKey in $cacheKeys
do
if [ "$cacheKey" != "Windows-nuget-${{needs.test_cosmos.outputs.windowsNugetHash}}" ] && [ "$cacheKey" != "Linux-nuget-${{ hashFiles('**/*.csproj') }}" ]; then
gh actions-cache delete $cacheKey -R ${{ github.repository }} --confirm || true
fi
done