Skip to content

Commit 5393736

Browse files
authored
ci: replace verification repository (#45)
1 parent e604b03 commit 5393736

52 files changed

Lines changed: 16739 additions & 175 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish-release-snapshot.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish snapshot of test scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
16+
steps:
17+
- uses: actions/checkout@v2.4.0
18+
19+
- name: Setup .NET Core
20+
uses: actions/setup-dotnet@v1.9.0
21+
with:
22+
dotnet-version: 3.1.x
23+
24+
- run: dotnet restore
25+
26+
- name: Install Apache Ivy
27+
if: ${{ matrix.os == 'ubuntu-latest' }}
28+
run: curl https://archive.apache.org/dist/ant/ivy/2.5.0/apache-ivy-2.5.0-bin.tar.gz | tar xOz apache-ivy-2.5.0/ivy-2.5.0.jar > /usr/share/ant/lib/ivy.jar
29+
30+
- name: Install Apache Ivy
31+
if: ${{ matrix.os == 'windows-latest' }}
32+
run: choco install ivy
33+
34+
- name: Install Apache Ivy
35+
if: ${{ matrix.os == 'macos-latest' }}
36+
run: brew install ivy
37+
38+
- name: Make output directory
39+
run: mkdir ${{ github.workspace }}/output
40+
41+
- name: Scan verification repo
42+
working-directory: src/Microsoft.ComponentDetection
43+
run: dotnet run scan --Verbosity Verbose --SourceDirectory ${{ github.workspace }}/test/Microsoft.ComponentDetection.VerificationTests/resources --Output ${{ github.workspace }}/output
44+
45+
- name: Upload output folder
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: release-snapshot-output-${{ matrix.os }}
49+
path: ${{ github.workspace }}/output
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Verify snapshot of test scan
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
verify:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
16+
steps:
17+
- uses: actions/checkout@v2.4.0
18+
19+
- name: Make release snapshot output directory
20+
run: mkdir ${{ github.workspace }}/release-output
21+
22+
- name: Get latest release snapshot download url
23+
id: download-latest-release-snapshot
24+
uses: actions/github-script@v5.0.0
25+
with:
26+
result-encoding: string
27+
script: |
28+
const res = await github.paginate(
29+
github.rest.actions.listArtifactsForRepo.endpoint.merge({
30+
owner: 'microsoft',
31+
repo: 'component-detection',
32+
})
33+
);
34+
35+
return res
36+
.filter(
37+
(artifact) => artifact.name === 'release-snapshot-output-${{ matrix.os }}'
38+
)
39+
.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at))[0]
40+
.archive_download_url;
41+
42+
- name: Download latest release snapshot
43+
working-directory: ${{ github.workspace }}/release-output
44+
run: |
45+
curl -v -L -u octocat:${{ secrets.GITHUB_TOKEN }} -o output.zip "${{ steps.download-latest-release-snapshot.outputs.result }}"
46+
unzip output.zip
47+
rm output.zip
48+
49+
- name: Setup .NET Core
50+
uses: actions/setup-dotnet@v1.9.0
51+
with:
52+
dotnet-version: 3.1.x
53+
54+
- run: dotnet restore
55+
56+
- name: Install Apache Ivy
57+
if: ${{ matrix.os == 'ubuntu-latest' }}
58+
run: curl https://archive.apache.org/dist/ant/ivy/2.5.0/apache-ivy-2.5.0-bin.tar.gz | tar xOz apache-ivy-2.5.0/ivy-2.5.0.jar > /usr/share/ant/lib/ivy.jar
59+
60+
- name: Install Apache Ivy
61+
if: ${{ matrix.os == 'windows-latest' }}
62+
run: choco install ivy
63+
64+
- name: Install Apache Ivy
65+
if: ${{ matrix.os == 'macos-latest' }}
66+
run: brew install ivy
67+
68+
- name: Make output directory
69+
run: mkdir ${{ github.workspace }}/output
70+
71+
- name: Scan verification repo
72+
working-directory: src/Microsoft.ComponentDetection
73+
run: dotnet run scan --Verbosity Verbose --SourceDirectory ${{ github.workspace }}/test/Microsoft.ComponentDetection.VerificationTests/resources --Output ${{ github.workspace }}/output
74+
75+
- name: Run Verification Tests
76+
working-directory: test/Microsoft.ComponentDetection.VerificationTests
77+
run: dotnet test
78+
env:
79+
OFFICIAL_BUILD: 'True'
80+
GITHUB_OLD_ARTIFACTS_DIR: ${{ github.workspace }}/release-output
81+
GITHUB_NEW_ARTIFACTS_DIR: ${{ github.workspace }}/output
82+
ALLOWED_TIME_DRIFT_RATIO: '.75'

.github/workflows/verify-snapshot.yml

Lines changed: 0 additions & 109 deletions
This file was deleted.

docs/creating-a-new-detector.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ It is expected that once `OnFileFound` completes, the `SingleFileComponentRecord
117117

118118
## Create Detector Tests
119119

120-
We have two kind of tests for our detectors, unit tests and pre-production tests that verify complete graph outputs across 2 scan runs over an identical set of files (this set of files can be found over at https://github.com/microsoft/componentdetection-verification). In this section we are going to discuss how to add a unit test for your detector.
120+
We have two kind of tests for our detectors, unit tests and pre-production tests that verify complete graph outputs across 2 scan runs over an identical set of files (this set of files can be found over in `test/Microsoft.ComponentDetection.VerificationTests/resources/`). In this section we are going to discuss how to add a unit test for your detector.
121121

122122
Detectors' unit tests are in the project _MS.VS.Services.Governance.CD.Detectors.L0.Tests_, to create a new test for your detector you just need to create a new test class inside this project.
123123
We recommend to test just one unique scenario in each test, avoid creating dependent tests. Since a detector depends on the content of the file to extract the components, we recommend using the minimum amount of file's sections that are needed to test your scenario. In order to reduce boilerplate, typically around configuring file locations, in our testing code we created a `DetectorTestUtility`.
@@ -128,7 +128,7 @@ From the example above you can see each test is initialized with a new `Detector
128128

129129
## How to run/debug your detector
130130

131-
```
131+
```sh
132132
dotnet run --project "[YOUR REPO PATH]\src\Microsoft.ComponentDetection\Microsoft.ComponentDetection.csproj" scan
133133
--Verbosity Verbose
134134
--SourceDirectory [PATH TO THE REPO TO SCAN]
@@ -139,4 +139,6 @@ dotnet run --project "[YOUR REPO PATH]\src\Microsoft.ComponentDetection\Microsof
139139

140140
## How to setup E2E Verification Test
141141

142-
The final step of the contribution to detectors is to setup its end to end verification tests. Please follow [these contributing guidelines](https://github.com/microsoft/componentdetection-verification/blob/main/CONTRIBUTING.md#contributing-a-new-project) from componentdetection-verification. As a good practice you should include the link to the verification test PR in the description of the pull request that contains the detector code.
142+
The final step of the contribution to detectors is to setup its end to end verification tests. These are located under the `test/Microsoft.ComponentDetection.VerificationTests/resources` directory.
143+
144+
Each directory under the `resources` directory is related to an ecosystem that Component Detection can scan. Inside each ecosystem directory there are one or more projects, each in their own directory. Each project should fully exercise the detector's capabilities.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target 'component-detection' do
2+
pod 'Alamofire', '~> 5.4.4'
3+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- Alamofire (5.4.4)
3+
4+
DEPENDENCIES:
5+
- Alamofire (~> 5.4.4)
6+
7+
SPEC REPOS:
8+
trunk:
9+
- Alamofire
10+
11+
SPEC CHECKSUMS:
12+
Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9
13+
14+
PODFILE CHECKSUM: 4d0cb2c924af9fe33785bbff254ff8cff17b7994
15+
16+
COCOAPODS: 1.11.2
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
target 'cmponent-detection' do
2+
pod 'Alamofire', '~> 5.2'
3+
pod 'base64url'
4+
pod 'CryptoSwift', '~> 1.0'
5+
pod 'DeviceKit', '~> 3'
6+
pod 'IQKeyboardManagerSwift', '~> 3'
7+
pod 'JGProgressHUD'
8+
pod 'LicensesViewController', '~> 0.9.0'
9+
pod 'MaterialComponents/TextFields'
10+
pod 'Mocker', '~> 2.2.0'
11+
pod 'PhoneNumberKit', '~> 3.3'
12+
pod 'RealmSwift'
13+
pod 'RxAppState'
14+
pod 'RxSwift'
15+
pod 'SimpleCheckbox'
16+
pod 'SwiftBase32'
17+
pod 'SwiftGen', '~> 6.0'
18+
pod 'TTTAttributedLabel'
19+
pod 'Validator'
20+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github.com/microsoft/component-detection
2+
3+
go 1.17
4+
5+
require github.com/sirupsen/logrus v1.8.1
6+
7+
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
6+
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
7+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
8+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
9+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
10+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

0 commit comments

Comments
 (0)