Skip to content

Add ephemeral state manager #60

Add ephemeral state manager

Add ephemeral state manager #60

Workflow file for this run

# SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
#
# SPDX-License-Identifier: MIT
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: read
checks: write
pull-requests: write
actions: write
jobs:
lookup-runtime-caches:
runs-on: ubuntu-latest
outputs:
linux-x64: ${{ steps.lookup-linux-x64.outputs.cache-hit }}
win-x64: ${{ steps.lookup-win-x64.outputs.cache-hit }}
osx-arm64: ${{ steps.lookup-osx-arm64.outputs.cache-hit }}
browser-wasm: ${{ steps.lookup-browser-wasm.outputs.cache-hit }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Lookup linux-x64
id: lookup-linux-x64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: linux-x64
- name: Lookup win-x64
id: lookup-win-x64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: win-x64
- name: Lookup osx-arm64
id: lookup-osx-arm64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: osx-arm64
- name: Lookup browser-wasm
id: lookup-browser-wasm
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: browser-wasm
runtime-linux-x64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.linux-x64 }}
uses: ./.github/workflows/runtime-linux-x64.yml
permissions:
contents: read
actions: write
runtime-win-x64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.win-x64 }}
uses: ./.github/workflows/runtime-win-x64.yml
permissions:
contents: read
actions: write
runtime-osx-arm64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.osx-arm64 }}
uses: ./.github/workflows/runtime-osx-arm64.yml
permissions:
contents: read
actions: write
runtime-browser-wasm:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.browser-wasm }}
uses: ./.github/workflows/runtime-browser-wasm.yml
permissions:
contents: read
actions: write
build:
needs:
- runtime-linux-x64
- runtime-win-x64
- runtime-osx-arm64
- runtime-browser-wasm
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore linux-x64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: linux-x64
- name: Restore win-x64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: win-x64
- name: Restore osx-arm64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: osx-arm64
- name: Restore browser-wasm
uses: ./.github/actions/restore-runtime-cache
with:
runtime: browser-wasm
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json', '.config/dotnet-tools.json', '**/Directory.Packages.props') }}
- name: Restore dependencies
run: |
dotnet tool restore
dotnet workload restore
dotnet restore
dotnet restore Documentation --no-dependencies
- name: Build
run: |
dotnet build --configuration Release --no-restore
- name: Test
run: |
dotnet test --configuration Release --no-build \
-p:TestingPlatformCommandLineArguments="--report-trx --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml"
- name: Package
run: |
dotnet pack --configuration Release --no-build
- name: Upload Package Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: |
**/*.nupkg
**/*.snupkg
retention-days: 14
- name: Publish WebAssembly example
# This one is *slow*, so only when commiting to main (and deploying GitHub Pages)
if: github.event_name != 'pull_request'
run: |
dotnet publish --configuration Release --no-restore
- name: Build Documentation
run: |
dotnet build --configuration Release --no-restore Documentation
- name: Upload GitHub Pages as artifact
uses: actions/upload-pages-artifact@v3
with:
path: Documentation/_site/
- name: Convert test results
if: ${{ !cancelled() }}
run: |
find . -name "*.trx" -exec dotnet tool run trx2junit --output TestResults/JUnit {} +
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: TestResults/JUnit/*.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
needs: build
if: ${{ always() && github.event_name == 'push' && needs.build.result == 'success' }}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4