From 62cb1063c79c6875063f914432afb9341238af58 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 31 May 2023 15:10:30 -0700 Subject: [PATCH] move the asset-sync scrips into the assets-automation folder. update links to it --- doc/development/powershell.md | 21 ++++++------ tools/asset-sync/ci.yml | 28 ---------------- tools/assets-automation/README.md | 9 ++++++ .../asset-sync/README.md | 0 .../asset-sync/assets.Tests.Helpers.ps1 | 0 .../asset-sync/assets.Tests.ps1 | 0 .../asset-sync/assets.json | 0 .../asset-sync/assets.ps1 | 0 .../asset-sync/contributing.md | 0 .../ScanTests.cs | 12 +++---- .../assets-maintenance-tool/README.md | 2 +- tools/assets-automation/tests.yml | 32 ------------------- 12 files changed, 27 insertions(+), 77 deletions(-) delete mode 100644 tools/asset-sync/ci.yml create mode 100644 tools/assets-automation/README.md rename tools/{ => assets-automation}/asset-sync/README.md (100%) rename tools/{ => assets-automation}/asset-sync/assets.Tests.Helpers.ps1 (100%) rename tools/{ => assets-automation}/asset-sync/assets.Tests.ps1 (100%) rename tools/{ => assets-automation}/asset-sync/assets.json (100%) rename tools/{ => assets-automation}/asset-sync/assets.ps1 (100%) rename tools/{ => assets-automation}/asset-sync/contributing.md (100%) diff --git a/doc/development/powershell.md b/doc/development/powershell.md index f313dc40c5a..57132f5ff4b 100644 --- a/doc/development/powershell.md +++ b/doc/development/powershell.md @@ -3,14 +3,15 @@ This page contains guidelines for developing or updating powershell scripts used Table of Contents ================= -* [TLDR](#tldr) -* [Structure](#structure) -* [Functionality](#functionality) -* [Style](#style) -* [Testing](#testing) - * [Unit Testing](#unit-testing) - * [Running Pester Tests](#running-pester-tests) - * [Local/Pipeline Functional Testing](#localpipeline-functional-testing) +- [Table of Contents](#table-of-contents) + - [TLDR](#tldr) + - [Structure](#structure) + - [Functionality](#functionality) + - [Style](#style) + - [Testing](#testing) + - [Unit Testing](#unit-testing) + - [Running Pester Tests](#running-pester-tests) + - [Local/Pipeline Functional Testing](#localpipeline-functional-testing) ## TLDR @@ -110,13 +111,13 @@ Powershell scripts should be testable, via one or more methods: Unit tests should be written for all scripts, and should utilize [Pester](https://pester.dev/). - Tests can be located alongside scripts in a directory called `tests`. -- Example pester test suites: [job matrix tests](https://github.com/Azure/azure-sdk-tools/tree/main/eng/common/scripts/job-matrix/tests), [asset sync tests](https://github.com/Azure/azure-sdk-tools/blob/main/tools/asset-sync/assets.Tests.ps1) +- Example pester test suites: [job matrix tests](https://github.com/Azure/azure-sdk-tools/tree/main/eng/common/scripts/job-matrix/tests), [asset sync tests](https://github.com/Azure/azure-sdk-tools/blob/main/tools/assets-automation/asset-sync/assets.Tests.ps1) - A CI pipeline should be defined to run scripts unit tests at the very least. See [archetype-sdk-tool-pwsh](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml) for how to do this. - Script code should always be written so as much of the surface area as possible can be run via unit tests. Move code that calls out to external dependencies into modular functions, and simplify context/data structures passed to functions as much as possible to it can be easily mocked. #### Running Pester Tests -(stolen from https://github.com/Azure/azure-sdk-tools/blob/main/tools/asset-sync/contributing.md). +(stolen from https://github.com/Azure/azure-sdk-tools/blob/main/tools/assets-automation/asset-sync/contributing.md). > **First, ensure you have `pester` installed:** > diff --git a/tools/asset-sync/ci.yml b/tools/asset-sync/ci.yml deleted file mode 100644 index 18d17781de9..00000000000 --- a/tools/asset-sync/ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. -trigger: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - tools/asset-sync - -pr: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - tools/asset-sync - -extends: - template: /eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml - parameters: - TargetDirectory: tools/asset-sync/ - TargetTags: 'Unit' diff --git a/tools/assets-automation/README.md b/tools/assets-automation/README.md new file mode 100644 index 00000000000..2aa9ce542b9 --- /dev/null +++ b/tools/assets-automation/README.md @@ -0,0 +1,9 @@ +# Assets automation tooling + +This directory contains tooling pertaining to the _support_ of externalized assets created by the [azure-sdk test-proxy](../test-proxy/Azure.Sdk.Tools.TestProxy/README.md). + +| Directory | Description | +|---|---| +| [assets-maintenance-tool](./assets-maintenance-tool/README.md) | CLI tool used to scan, backup, and clean azure-sdk assets across all repositories. | +| [assets-reporting](./assets-reporting/README.md) | CLI tool used to audit current repositories and find status of test-proxy adoption on a per-package basis. Used to generate weekly reporting. | +| [asset-sync](./assets-reporting/README.md) | Deprecated initial version of `asset-sync` implementation. The current implementation ended up integrated directly into the `test-proxy` codebase, rather than existing as an external powershell script. | diff --git a/tools/asset-sync/README.md b/tools/assets-automation/asset-sync/README.md similarity index 100% rename from tools/asset-sync/README.md rename to tools/assets-automation/asset-sync/README.md diff --git a/tools/asset-sync/assets.Tests.Helpers.ps1 b/tools/assets-automation/asset-sync/assets.Tests.Helpers.ps1 similarity index 100% rename from tools/asset-sync/assets.Tests.Helpers.ps1 rename to tools/assets-automation/asset-sync/assets.Tests.Helpers.ps1 diff --git a/tools/asset-sync/assets.Tests.ps1 b/tools/assets-automation/asset-sync/assets.Tests.ps1 similarity index 100% rename from tools/asset-sync/assets.Tests.ps1 rename to tools/assets-automation/asset-sync/assets.Tests.ps1 diff --git a/tools/asset-sync/assets.json b/tools/assets-automation/asset-sync/assets.json similarity index 100% rename from tools/asset-sync/assets.json rename to tools/assets-automation/asset-sync/assets.json diff --git a/tools/asset-sync/assets.ps1 b/tools/assets-automation/asset-sync/assets.ps1 similarity index 100% rename from tools/asset-sync/assets.ps1 rename to tools/assets-automation/asset-sync/assets.ps1 diff --git a/tools/asset-sync/contributing.md b/tools/assets-automation/asset-sync/contributing.md similarity index 100% rename from tools/asset-sync/contributing.md rename to tools/assets-automation/asset-sync/contributing.md diff --git a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/ScanTests.cs b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/ScanTests.cs index 4e9780df877..6150de8d5e5 100644 --- a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/ScanTests.cs +++ b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/ScanTests.cs @@ -70,7 +70,7 @@ public void TearDown() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestBasicScanSingleBranch() { var scanner = new AssetsScanner(TestDirectory); @@ -106,7 +106,7 @@ public void TestBasicScanSingleBranch() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestBasicScanMultipleBranches() { var scanner = new AssetsScanner(TestDirectory); @@ -155,7 +155,7 @@ public void TestBasicScanMultipleBranches() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestBasicScanMultipleBranchesMultipleRepos() { var scanner = new AssetsScanner(TestDirectory); @@ -187,7 +187,7 @@ public void TestBasicScanMultipleBranchesMultipleRepos() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestScanHonorsPreviousResults() { var specificDirectory = Path.Combine(TestDirectory, "TestResources", "basic_output"); @@ -232,7 +232,7 @@ public void TestScanHonorsPreviousResults() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestParsePreviouslyOutputResults() { var specificDirectory = Path.Combine(TestDirectory, "TestResources", "basic_output"); @@ -269,7 +269,7 @@ public void TestParsePreviouslyOutputResults() } [Test] - [GitTokenSkipAttribute] + [GitTokenSkip] public void TestScanOutputsResults() { var scanner = new AssetsScanner(TestDirectory); diff --git a/tools/assets-automation/assets-maintenance-tool/README.md b/tools/assets-automation/assets-maintenance-tool/README.md index 0d9865d0b1a..310db7c697d 100644 --- a/tools/assets-automation/assets-maintenance-tool/README.md +++ b/tools/assets-automation/assets-maintenance-tool/README.md @@ -3,7 +3,7 @@ The tool contained within this directory is intended two fulfill three main tasks. 1. Scan the commits of a set of targeted repos and branches to create a representation of all assets.jsons, their targeted tags, and their origin SHAs. - * This is just a map of the complete footprint of `test-proxy` assets. + * This is just a map of the complete footprint of `test-proxy` assets that are referenced in azure-sdk repositories. 2. Use the map of data created in step 1 to individually backup tags from the assets repository to a target that we can retrieve later. 3. Use the map of data created in step 1 to clean up _unnecessary_ tags in the assets repository. diff --git a/tools/assets-automation/tests.yml b/tools/assets-automation/tests.yml index 7bece9c6dba..e8bdf466abc 100644 --- a/tools/assets-automation/tests.yml +++ b/tools/assets-automation/tests.yml @@ -42,35 +42,3 @@ stages: testRunTitle: '$(OS) Maintenance tool tests against .NET' testResultsFormat: 'VSTest' mergeTestResults: true - - - job: CLI_Integration_Test - name: Invoke CLI Tool - strategy: - matrix: - Linux: - Pool: azsdk-pool-mms-ubuntu-2204-general - OS: 'Linux' - - pool: - name: $(Pool) - - steps: - - template: /eng/pipelines/templates/steps/install-dotnet.yml - - - script: 'dotnet test /p:ArtifactsPackagesDir=$(Build.ArtifactStagingDirectory) --logger trx $(Build.SourcesDirectory)/tools/assets-automation/assets-maintenance-tool/' - displayName: 'Test' - env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_MULTILEVEL_LOOKUP: 0 - GIT_TOKEN: $(azuresdk-github-pat) - GIT_COMMIT_OWNER: azure-sdk - GIT_COMMIT_EMAIL: azuresdk@microsoft.com - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/*.trx' - testRunTitle: '$(OS) Maintenance tool tests against .NET' - testResultsFormat: 'VSTest' - mergeTestResults: true