|
| 1 | +name: Smoke Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + schedule: |
| 7 | + - cron: "0 0 * * *" # every day at midnight |
| 8 | + |
| 9 | +jobs: |
| 10 | + smoke-test: |
| 11 | + runs-on: ["self-hosted", "1ES.Pool=1ES-OSE-GH-Pool"] |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + language: |
| 15 | + [ |
| 16 | + { name: "CocoaPods", repo: "realm/realm-swift" }, |
| 17 | + { name: "Gradle", repo: "microsoft/ApplicationInsights-Java" }, |
| 18 | + { name: "Go", repo: "kubernetes/kubernetes" }, |
| 19 | + { name: "Maven", repo: "apache/kafka" }, |
| 20 | + { name: "NPM", repo: "axios/axios" }, |
| 21 | + { name: "NuGet", repo: "Radarr/Radarr" }, |
| 22 | + { name: "Pip", repo: "django/django" }, |
| 23 | + { name: "Pnpm", repo: "pnpm/pnpm" }, |
| 24 | + { name: "Poetry", repo: "Textualize/rich" }, |
| 25 | + { name: "Ruby", repo: "rails/rails" }, |
| 26 | + { name: "Rust", repo: "alacritty/alacritty" }, |
| 27 | + { name: "Yarn", repo: "gatsbyjs/gatsby" }, |
| 28 | + ] |
| 29 | + fail-fast: false |
| 30 | + name: ${{ matrix.language.name }} |
| 31 | + steps: |
| 32 | + - name: Checkout Component Detection |
| 33 | + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 |
| 34 | + |
| 35 | + - name: Setup .NET |
| 36 | + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 |
| 37 | + |
| 38 | + - name: Setup NuGet cache |
| 39 | + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 |
| 40 | + with: |
| 41 | + path: ~/.nuget/packages |
| 42 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }} |
| 43 | + restore-keys: ${{ runner.os }}-nuget- |
| 44 | + |
| 45 | + - name: Install Apache Ivy |
| 46 | + run: curl https://downloads.apache.org/ant/ivy/2.5.1/apache-ivy-2.5.1-bin.tar.gz | tar xOz apache-ivy-2.5.1/ivy-2.5.1.jar > /usr/share/ant/lib/ivy.jar |
| 47 | + |
| 48 | + - name: Checkout Smoke Test Repo |
| 49 | + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 |
| 50 | + with: |
| 51 | + repository: ${{ matrix.language.repo }} |
| 52 | + path: smoke-test-repo |
| 53 | + |
| 54 | + - name: Restore Smoke Test NuGet Packages |
| 55 | + if: ${{ matrix.language.name == 'NuGet'}} |
| 56 | + working-directory: smoke-test-repo/src |
| 57 | + run: dotnet restore |
| 58 | + |
| 59 | + - name: Run Smoke Test |
| 60 | + working-directory: src/Microsoft.ComponentDetection |
| 61 | + run: | |
| 62 | + for i in $(seq 1 10); do |
| 63 | + dotnet run -c Release -- scan --SourceDirectory ${{ github.workspace }}/smoke-test-repo --Verbosity Verbose || exit 1 |
| 64 | + done |
| 65 | +
|
| 66 | + create-issue: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: smoke-test |
| 69 | + name: Create Issue |
| 70 | + if: always() && github.event_name == 'schedule' && needs.smoke-test.result == 'failure' |
| 71 | + permissions: |
| 72 | + issues: write |
| 73 | + steps: |
| 74 | + - name: Create GitHub Issue |
| 75 | + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 |
| 76 | + with: |
| 77 | + script: | |
| 78 | + const failed_tests = []; |
| 79 | + const jobs = await github.rest.actions.listJobsForWorkflowRun({ |
| 80 | + owner: context.repo.owner, |
| 81 | + repo: context.repo.repo, |
| 82 | + run_id: context.runId, |
| 83 | + }); |
| 84 | + for (const job of jobs.data.jobs) { |
| 85 | + if (job.status === 'completed' && job.conclusion === 'failure') { |
| 86 | + failed_tests.push('* ' + job.name); |
| 87 | + } |
| 88 | + } |
| 89 | + 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`; |
| 90 | + await github.rest.issues.create({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + title: 'Smoke Test Failure', |
| 94 | + body: issue_body, |
| 95 | + labels: ['bug'] |
| 96 | + }) |
0 commit comments