Unverified Commit 22818445 authored by daz's avatar daz
Browse files

Restrict download-and-submit to selected file

parent 36c24e79
Loading
Loading
Loading
Loading
+4 −2
Changes for .github/workflows/integ-test-dependency-graph.yml: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ env:
  GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository

jobs:
  groovy-generate:
  groovy-upload:
    strategy:
      fail-fast: false
      matrix:
@@ -42,7 +42,7 @@ jobs:
      working-directory: .github/workflow-samples/groovy-dsl

  groovy-submit:
    needs: [groovy-generate]
    needs: [groovy-upload]
    runs-on: "ubuntu-latest"
    steps:
    - name: Checkout sources
@@ -54,6 +54,8 @@ jobs:
      uses: ./setup-gradle
      with:
        dependency-graph: download-and-submit
      env:
        DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: groovy-upload

  kotlin-generate-and-submit:
    strategy:
+4
Changes for .github/workflows/integ-test-dependency-submission.yml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ jobs:
      uses: ./dependency-submission
      with:
        dependency-graph: download-and-submit
      env:
        DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: groovy-generate-and-upload-${{ matrix.os }}

  kotlin-generate-and-submit:
    strategy:
@@ -313,6 +315,8 @@ jobs:
        build-root-directory: .github/workflow-samples/groovy-dsl
      env: 
        DEPENDENCY_GRAPH_REPORT_DIR: '${{ github.workspace }}/custom/report-dir'
        DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: custom-report-dir-upload

    - name: Check downloaded dependency graph
      shell: bash
      run: |
+4
Changes for sources/src/configuration.ts: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ export class DependencyGraphConfig {
        return path.resolve(getWorkspaceDirectory(), 'dependency-graph-reports')
    }

    getDownloadArtifactName(): string | undefined {
        return process.env['DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME']
    }

    static constructJobCorrelator(workflow: string, jobId: string, matrixJson: string): string {
        const matrixString = this.describeMatrix(matrixJson)
        const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`
+9 −3
Changes for sources/src/dependency-graph.ts: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ async function downloadAndSubmitDependencyGraphs(config: DependencyGraphConfig):
    }

    try {
        await submitDependencyGraphs(await downloadDependencyGraphs())
        await submitDependencyGraphs(await downloadDependencyGraphs(config))
    } catch (e) {
        warnOrFail(config, DependencyGraphOption.DownloadAndSubmit, e)
    }
@@ -111,7 +111,7 @@ async function findAndUploadDependencyGraphs(config: DependencyGraphConfig): Pro
    await uploadDependencyGraphs(await findDependencyGraphFiles(), config)
}

async function downloadDependencyGraphs(): Promise<string[]> {
async function downloadDependencyGraphs(config: DependencyGraphConfig): Promise<string[]> {
    const findBy = github.context.payload.workflow_run
        ? {
              token: getGithubToken(),
@@ -123,13 +123,19 @@ async function downloadDependencyGraphs(): Promise<string[]> {

    const artifactClient = new DefaultArtifactClient()

    const dependencyGraphArtifacts = (
    let dependencyGraphArtifacts = (
        await artifactClient.listArtifacts({
            latest: true,
            findBy
        })
    ).artifacts.filter(artifact => artifact.name.startsWith(DEPENDENCY_GRAPH_PREFIX))

    const artifactName = config.getDownloadArtifactName()
    if (artifactName) {
        core.info(`Filtering for artifacts ending with ${artifactName}`)
        dependencyGraphArtifacts = dependencyGraphArtifacts.filter(artifact => artifact.name.includes(artifactName))
    }

    for (const artifact of dependencyGraphArtifacts) {
        const downloadedArtifact = await artifactClient.downloadArtifact(artifact.id, {
            findBy