Skip to content

Fix website build job to only run if it is executing on the main upstream repository #1073

Fix website build job to only run if it is executing on the main upstream repository

Fix website build job to only run if it is executing on the main upstream repository #1073

####################################################################################
# DO NOT EDIT: This file was automatically generated by Generate-TestWorkflows.ps1
####################################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: 'Lucene.Net.Tests.Sandbox'
on:
workflow_dispatch:
pull_request:
paths:
- 'src/Lucene.Net.Tests.Sandbox/**/*'
- '.build/dependencies.props'
- '.build/TestReferences.Common.*'
- 'TestTargetFrameworks.*'
- '.github/**/*.yml'
- '*.sln'
- 'src/Lucene.Net.Tests.Sandbox/Directory.Build.*'
- 'src/Directory.Build.*'
- 'Directory.Build.*'
- 'src/Lucene.Net.Tests.Sandbox/Queries/fuzzyTestData.txt'
# Dependencies
- 'src/Lucene.Net/**/*'
- 'src/Lucene.Net.Analysis.Common/**/*'
- 'src/Lucene.Net.Codecs/**/*'
- 'src/Lucene.Net.Sandbox/**/*'
- 'src/Lucene.Net.TestFramework/**/*'
- '!**/*.md'
jobs:
Test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net10.0, net8.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
- os: ubuntu-latest
framework: net48
- os: ubuntu-latest
framework: net472
- os: macos-latest
framework: net48
- os: macos-latest
framework: net472
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
BUILD_FOR_ALL_TEST_TARGET_FRAMEWORKS: 'true'
project_path: './src/Lucene.Net.Tests.Sandbox/Lucene.Net.Tests.Sandbox.csproj'
run_slow_tests: 'false'
trx_file_name: 'TestResults.trx'
md_file_name: 'TestResults.md' # Report file name for LiquidTestReports.Markdown
steps:
- name: Checkout Source Code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: '8.0.x'
if: ${{ startswith(matrix.framework, 'net8.') }}
- name: Setup .NET 10 SDK
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: '10.0.x'
- name: Cache NuGet Packages
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
# '**/*.*proj' includes .csproj, .vbproj, .fsproj, msbuildproj, etc.
# '**/*.props' includes Directory.Packages.props, Directory.Build.props and Dependencies.props
# '**/*.targets' includes Directory.Build.targets
# '**/*.sln' and '*.sln' ensure root solution files are included (minimatch glitch for file extension .sln)
# 'global.json' included for SDK version changes
key: nuget-${{ runner.os }}-${{ env.BUILD_FOR_ALL_TEST_TARGET_FRAMEWORKS }}-${{ hashFiles('**/*.*proj', '**/*.props', '**/*.targets', '**/*.sln', '*.sln', 'global.json') }}
path: ${{ env.NUGET_PACKAGES }}
- name: Restore
run: dotnet restore /p:TestFrameworks=${{ env.BUILD_FOR_ALL_TEST_TARGET_FRAMEWORKS }}
- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
$test_results_artifact_name = "testresults_${{matrix.os}}_${{matrix.framework}}_${{matrix.platform}}_${{matrix.configuration}}"
$working_directory = "$env:GITHUB_WORKSPACE"
Write-Host "Project Name: $project_name"
Write-Host "Results Artifact Name: $test_results_artifact_name"
Write-Host "Working Directory: $working_directory"
echo "project_name=$project_name" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "test_results_artifact_name=$test_results_artifact_name" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Set the Azure DevOps default working directory env variable, so our tests only need to deal with a single env variable
echo "SYSTEM_DEFAULTWORKINGDIRECTORY=$working_directory" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Title for LiquidTestReports.Markdown
echo "title=Test Results for $project_name - ${{matrix.framework}} - ${{matrix.platform}} - ${{matrix.os}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- run: dotnet build "${{env.project_path}}" --configuration "${{matrix.configuration}}" --framework "${{matrix.framework}}" --no-restore -p:TestFrameworks=${{ env.BUILD_FOR_ALL_TEST_TARGET_FRAMEWORKS }}
shell: bash
- run: dotnet test "${{env.project_path}}" --configuration "${{matrix.configuration}}" --framework "${{matrix.framework}}" --no-build --no-restore --blame-hang --blame-hang-dump-type mini --blame-hang-timeout 20minutes --logger:"console;verbosity=normal" --logger:"trx;LogFileName=${{env.trx_file_name}}" --logger:"liquid.md;LogFileName=${{env.md_file_name}};Title=${{env.title}};" --results-directory:"${{github.workspace}}/${{env.test_results_artifact_name}}/${{env.project_name}}" -- RunConfiguration.TargetPlatform=${{matrix.platform}} NUnit.DisplayName=FullName TestRunParameters.Parameter\(name=\"tests:slow\",\ value=\"\${{env.run_slow_tests}}\"\)
shell: bash
# upload reports as build artifacts
- name: Upload a Build Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{always()}}
with:
name: '${{env.test_results_artifact_name}}'
path: '${{github.workspace}}/${{env.test_results_artifact_name}}'
- name: Output Test Summary
if: ${{always()}}
shell: pwsh
run: |
$md_file = Join-Path ${{github.workspace}} ${{env.test_results_artifact_name}} ${{env.project_name}} ${{env.md_file_name}}
if (Test-Path $md_file) {
Get-Content $md_file | Add-Content $env:GITHUB_STEP_SUMMARY
}