Skip to content

Build and test

Build and test #140

Workflow file for this run

name: build
run-name: Build and test
on:
push:
branches:
- main
tags:
- "[0-9]+.[0-9]+.[0-9]+"
pull_request:
types: [opened, reopened, synchronize]
merge_group:
types: [checks_requested]
jobs:
formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: 8.0.303
- name: Install tools
run: dotnet tool restore
- name: Check formatting
run: dotnet csharpier --check .
coverage:
name: Check code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: 8.0.303
- name: Run tests
run: dotnet test -c Debug --collect:"XPlat Code Coverage" --settings coverlet.runsettings ArchUnitNETTests/
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
run-tests:
name: Run tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: 8.0.303
- name: Run tests
run: dotnet test -c Debug
publish-docs:
name: Publish documentation
runs-on: ubuntu-latest
needs:
- formatting
- coverage
- run-tests
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup doxygen
run: sudo apt-get install doxygen
- name: Create temporary directory
run: |
tmpdir=$(mktemp -d -p "$GITHUB_WORKSPACE")
mkdir -p $tmpdir
relative_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$tmpdir")
echo "Created temporary directory $tmpdir ($relative_path relative to $GITHUB_WORKSPACE)"
echo "DOCS_TEMP_DIR=$relative_path" >> "$GITHUB_ENV"
- name: Checkout gh-pages branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: gh-pages
path: ${{ env.DOCS_TEMP_DIR }}
- name: Generate documentation
working-directory: ${{ env.DOCS_TEMP_DIR }}
run: |
find . -mindepth 1 -not -path './.git*' -delete
doxygen "$GITHUB_WORKSPACE/documentation/Doxyfile"
touch .nojekyll
- name: Commit and push changes
if: github.ref == 'refs/tags/[0-9]+.[0-9]+.[0-9]+'
working-directory: ${{ env.DOCS_TEMP_DIR }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add -A
if [[ "$(git status --porcelain)" ]]; then
git commit -m "Update documentation for $GITHUB_REF_NAME"
git push
else
echo "No changes to commit"
fi
publish-packages:
name: Publish packages
if: github.ref == 'refs/tags/[0-9]+.[0-9]+.[0-9]+'
runs-on: windows-latest
environment: deploy
needs:
- formatting
- coverage
- run-tests
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: 8.0.303
- name: Add package source
run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
- name: Build
run: dotnet build -c Release
- name: Pack
run: dotnet pack -c Release --output nupkgs -p:PackageVersion="${{ github.ref_name }}" -p:AssemblyVersion="${{ github.ref_name }}.0"
- name: Push
run: dotnet nuget push nupkgs/*.nupkg --source nuget.org --api-key ${{ secrets.NUGET_API_KEY }}