Skip to content

Commit

Permalink
move the asset-sync scrips into the assets-automation folder. update …
Browse files Browse the repository at this point in the history
…links to it
  • Loading branch information
scbedd committed May 31, 2023
1 parent 9484399 commit 62cb106
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 77 deletions.
21 changes: 11 additions & 10 deletions doc/development/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:**
>
Expand Down
28 changes: 0 additions & 28 deletions tools/asset-sync/ci.yml

This file was deleted.

9 changes: 9 additions & 0 deletions tools/assets-automation/README.md
Original file line number Diff line number Diff line change
@@ -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. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void TearDown()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestBasicScanSingleBranch()
{
var scanner = new AssetsScanner(TestDirectory);
Expand Down Expand Up @@ -106,7 +106,7 @@ public void TestBasicScanSingleBranch()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestBasicScanMultipleBranches()
{
var scanner = new AssetsScanner(TestDirectory);
Expand Down Expand Up @@ -155,7 +155,7 @@ public void TestBasicScanMultipleBranches()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestBasicScanMultipleBranchesMultipleRepos()
{
var scanner = new AssetsScanner(TestDirectory);
Expand Down Expand Up @@ -187,7 +187,7 @@ public void TestBasicScanMultipleBranchesMultipleRepos()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestScanHonorsPreviousResults()
{
var specificDirectory = Path.Combine(TestDirectory, "TestResources", "basic_output");
Expand Down Expand Up @@ -232,7 +232,7 @@ public void TestScanHonorsPreviousResults()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestParsePreviouslyOutputResults()
{
var specificDirectory = Path.Combine(TestDirectory, "TestResources", "basic_output");
Expand Down Expand Up @@ -269,7 +269,7 @@ public void TestParsePreviouslyOutputResults()
}

[Test]
[GitTokenSkipAttribute]
[GitTokenSkip]
public void TestScanOutputsResults()
{
var scanner = new AssetsScanner(TestDirectory);
Expand Down
2 changes: 1 addition & 1 deletion tools/assets-automation/assets-maintenance-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
32 changes: 0 additions & 32 deletions tools/assets-automation/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/*.trx'
testRunTitle: '$(OS) Maintenance tool tests against .NET'
testResultsFormat: 'VSTest'
mergeTestResults: true

0 comments on commit 62cb106

Please sign in to comment.