fixing tests #200
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: cdp | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
branches: [master] | |
env: | |
VsixFileName: RustAnalyzer.vsix | |
SolutionPath: src\RustAnalyzer.sln | |
VsixManifestPath: src\RustAnalyzer\source.extension.vsixmanifest | |
VsixManifestSourcePath: src\RustAnalyzer\source.extension.cs | |
TestAdapterNameNoExt: KS.RustAnalyzer.TestAdapter | |
RUSTANALYZER_TELEMETRY_DISABLED: 1 | |
jobs: | |
build-test-deploy: | |
outputs: | |
version: ${{ steps.vsix_version.outputs.version-number }} | |
name: Build, Test & Deploy | |
runs-on: windows-2022 | |
env: | |
Configuration: Release | |
DeployExtension: False | |
OutDir: \_built\ | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup .NET build dependencies | |
uses: timheuer/bootstrap-dotnet@v1 | |
with: | |
nuget: 'false' | |
sdk: 'false' | |
msbuild: 'true' | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
target: x86_64-pc-windows-msvc | |
default: true | |
components: rustfmt, clippy | |
- name: Increment VSIX version | |
id: vsix_version | |
uses: timheuer/vsix-version-stamp@v1 | |
with: | |
manifest-file: ${{ env.VsixManifestPath }} | |
vsix-token-source-file: ${{ env.VsixManifestSourcePath }} | |
- name: Build | |
run: msbuild $env:SolutionPath /m /t:rebuild /restore /p:OutDir=$env:OutDir | |
- name: Zip TestAdapter | |
run: | | |
$files = @("${env:OutDir}${env:TestAdapterNameNoExt}.dll", "${env:OutDir}${env:TestAdapterNameNoExt}.pdb", "${env:OutDir}Microsoft.ApplicationInsights.dll", "${env:OutDir}Microsoft.ApplicationInsights.pdb", "${env:OutDir}Ensure.That.dll") | |
$dst = "${env:OutDir}${env:TestAdapterNameNoExt}.zip" | |
Compress-Archive -Path $files -DestinationPath $dst | |
# List contents for debugging purposes | |
Add-Type -assembly "system.io.compression.filesystem" | |
echo "listing files in zip..." | |
[io.compression.zipfile]::OpenRead($dst).Entries.Name | % { "- $_"} | |
shell: pwsh | |
- name: Test | |
uses: rusty-bender/vstest-action@main | |
with: | |
testAssembly: '*.UnitTests.dll' | |
searchFolder: '${{ env.OutDir }}' | |
runInParallel: true | |
resultLogsArtifactName: unit-tests-results-log | |
- name: Generate test report | |
uses: dorny/test-reporter@v1 | |
with: | |
name: Tests Results | |
path: TestResults/*.trx | |
reporter: dotnet-trx | |
fail-on-error: true | |
- name: Upload VSIX | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ github.event.repository.name }}.zip | |
path: ${{ env.OutDir }}${{ env.VsixFileName }} | |
if-no-files-found: error | |
- name: Upload TestAdapter | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.TestAdapterNameNoExt }}.zip | |
path: ${{ env.OutDir }}${{ env.TestAdapterNameNoExt }}.zip | |
if-no-files-found: warn | |
run-integration-tests: | |
name: Integration tests | |
needs: build-test-deploy | |
runs-on: windows-2022 | |
env: | |
TestAdapterLocation: \testadapter | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
target: x86_64-pc-windows-msvc | |
default: true | |
components: rustfmt, clippy | |
- uses: darenm/[email protected] | |
- name: Download TestAdapter | |
id: itdownloadta | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.TestAdapterNameNoExt }}.zip | |
- name: Prepare for integration tests | |
run: | | |
$adapterPathNoExt = "${env:itdownloadta}\${env:TestAdapterNameNoExt}" | |
mkdir $env:TestAdapterLocation | |
Expand-Archive "${env:itdownloadta}\${env:TestAdapterNameNoExt}.zip" -DestinationPath $env:TestAdapterLocation | |
shell: pwsh | |
env: | |
itdownloadta: ${{ steps.itdownloadta.outputs.download-path }} | |
- name: Run integration tests | |
run: | | |
.\src\TestProjects\run-integrationtests.ps1 .\src\TestProjects\workspace_with_tests $env:TestAdapterLocation | |
shell: pwsh | |
publish: | |
name: Publish | |
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
needs: [build-test-deploy, run-integration-tests] | |
runs-on: windows-2022 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download VSIX | |
id: downloadvx | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ github.event.repository.name }}.zip | |
- name: Download TestAdapter | |
id: downloadta | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.TestAdapterNameNoExt }}.zip | |
- name: Upload to Open VSIX | |
uses: timheuer/openvsixpublish@v1 | |
with: | |
vsix-file: '${{ steps.downloadvx.outputs.download-path }}\\${{ env.VsixFileName }}' | |
- name: Tag and Release | |
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[release]') }} | |
id: tag_release | |
uses: softprops/[email protected] | |
with: | |
generate_release_notes: true | |
tag_name: ${{ needs.build-test-deploy.outputs.version }} | |
name: Release ${{ needs.build-test-deploy.outputs.version }} | |
files: | | |
'${{ steps.downloadvx.outputs.download-path }}\\${{ env.VsixFileName }}' | |
'${{ steps.downloadta.outputs.download-path }}\\${{ env.TestAdapterNameNoExt }}.zip' | |
- name: Publish extension to Marketplace | |
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[release]') }} | |
uses: cezarypiatek/[email protected] | |
with: | |
extension-file: '${{ steps.downloadvx.outputs.download-path }}\\${{ env.VsixFileName }}' | |
publish-manifest-file: 'vs-publish.json' | |
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }} |