Skip to content

Reconcile bare/rich component Ids in DependencyGraphs #4390

Reconcile bare/rich component Ids in DependencyGraphs

Reconcile bare/rich component Ids in DependencyGraphs #4390

Workflow file for this run

name: Smoke Tests
env:
CD_DETECTOR_EXPERIMENTS: 1
on:
push:
branches:
- main
pull_request:
paths:
- "src/**"
- "Directory.Build.props"
- "Directory.Build.targets"
- "Directory.Packages.props"
- "global.json"
- ".github/workflows/smoke-test.yml"
schedule:
- cron: "0 0 * * *" # every day at midnight
permissions:
contents: read
jobs:
smoke-test:
if: github.repository == 'microsoft/component-detection' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
runs-on: ["self-hosted", "1ES.Pool=1ES-OSE-GH-Pool"]
name: Smoke Test
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout Component Detection
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare Dotnet
run: |
# When using a Vanilla Ubuntu image, GH Actions may not have access to the /usr/share/dotnet directory.
sudo mkdir /usr/share/dotnet
sudo chmod 777 /usr/share/dotnet
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
- name: Install Apache Ivy
run: |
echo "Starting Apache Ant and Ivy installation..."
sudo apt install -y ant
echo "Ant installed successfully. Installing Ivy plugin..."
sudo chmod 777 /usr/share/ant/lib
curl https://downloads.apache.org/ant/ivy/2.5.2/apache-ivy-2.5.2-bin.tar.gz | tar xOz apache-ivy-2.5.2/ivy-2.5.2.jar > /usr/share/ant/lib/ivy.jar
- name: Checkout Smoke Test Repos
run: |
mkdir -p smoke-test-repos
repos=(
"realm/realm-swift" # CocoaPods
"microsoft/ApplicationInsights-Java" # Gradle
"kubernetes/kubernetes" # Go
"apache/kafka" # Maven
"axios/axios" # NPM
"Radarr/Radarr" # NuGet
"django/django" # Pip
"pnpm/pnpm" # Pnpm
"Textualize/rich" # Poetry
"rails/rails" # Ruby
"alacritty/alacritty" # Rust
"gatsbyjs/gatsby" # Yarn
)
for repo in "${repos[@]}"; do
dir="smoke-test-repos/$(basename "$repo")"
echo "Cloning $repo into $dir..."
git clone --depth 1 "https://github.com/$repo.git" "$dir"
done
- name: Restore Smoke Test NuGet Packages
working-directory: smoke-test-repos/Radarr/src
run: dotnet restore
- name: Run Smoke Test
working-directory: src/Microsoft.ComponentDetection
run: |
ITERATIONS=${{ github.event_name == 'schedule' && 10 || 1 }}
for i in $(seq 1 $ITERATIONS); do
dotnet run -c Release -- scan --SourceDirectory ${{ github.workspace }}/smoke-test-repos --Verbosity Verbose || exit 1
done
create-issue:
runs-on: ubuntu-latest
needs: smoke-test
name: Create Issue
if: always() && github.event_name == 'schedule' && needs.smoke-test.result == 'failure'
permissions:
issues: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Create GitHub Issue
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const failed_tests = [];
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
for (const job of jobs.data.jobs) {
if (job.status === 'completed' && job.conclusion === 'failure') {
failed_tests.push('* ' + job.name);
}
}
const issue_body = `# :x: Smoke Test Failure\nThe following smoke tests failed:\n\n${failed_tests.join('\n')}\n\n[View Run](${context.payload.repository.html_url}/actions/runs/${context.runId})\n\ncc: @microsoft/ose-component-detection-maintainers`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Smoke Test Failure',
body: issue_body,
labels: ['bug']
})