mirror of
https://github.com/gradle/actions.git
synced 2025-08-24 10:51:27 +08:00
Isolate 'dependency-submission' action from 'setup-gradle' (#293)
This commit is contained in:
commit
4a315dceb2
@ -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
|
GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
groovy-generate:
|
groovy-upload:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -42,7 +42,7 @@ jobs:
|
|||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
|
||||||
groovy-submit:
|
groovy-submit:
|
||||||
needs: [groovy-generate]
|
needs: [groovy-upload]
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
@ -54,6 +54,8 @@ jobs:
|
|||||||
uses: ./setup-gradle
|
uses: ./setup-gradle
|
||||||
with:
|
with:
|
||||||
dependency-graph: download-and-submit
|
dependency-graph: download-and-submit
|
||||||
|
env:
|
||||||
|
DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: groovy-upload
|
||||||
|
|
||||||
kotlin-generate-and-submit:
|
kotlin-generate-and-submit:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -80,6 +80,8 @@ jobs:
|
|||||||
uses: ./dependency-submission
|
uses: ./dependency-submission
|
||||||
with:
|
with:
|
||||||
dependency-graph: download-and-submit
|
dependency-graph: download-and-submit
|
||||||
|
env:
|
||||||
|
DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: groovy-generate-and-upload-${{ matrix.os }}
|
||||||
|
|
||||||
kotlin-generate-and-submit:
|
kotlin-generate-and-submit:
|
||||||
strategy:
|
strategy:
|
||||||
@ -225,7 +227,7 @@ jobs:
|
|||||||
gradle-version: ${{ matrix.gradle }}
|
gradle-version: ${{ matrix.gradle }}
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
||||||
|
|
||||||
after-setup-gradle:
|
with-setup-gradle:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -244,6 +246,25 @@ jobs:
|
|||||||
uses: ./dependency-submission
|
uses: ./dependency-submission
|
||||||
with:
|
with:
|
||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
- name: Check and delete generated dependency graph
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ ! -e "${{ steps.dependency-submission.outputs.dependency-graph-file }}" ]; then
|
||||||
|
echo "Did not find generated dependency graph files"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
rm ${{ steps.dependency-submission.outputs.dependency-graph-file }}*
|
||||||
|
- name: Run Gradle build
|
||||||
|
run: ./gradlew build
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
- name: Check no dependency graph is generated
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ ! -z "$(ls -A dependency-graph-reports)" ]; then
|
||||||
|
echo "Expected no dependency graph files to be generated"
|
||||||
|
ls -l dependency-graph-reports
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
custom-report-dir-submit:
|
custom-report-dir-submit:
|
||||||
strategy:
|
strategy:
|
||||||
@ -313,6 +334,8 @@ jobs:
|
|||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
env:
|
env:
|
||||||
DEPENDENCY_GRAPH_REPORT_DIR: '${{ github.workspace }}/custom/report-dir'
|
DEPENDENCY_GRAPH_REPORT_DIR: '${{ github.workspace }}/custom/report-dir'
|
||||||
|
DEPENDENCY_GRAPH_DOWNLOAD_ARTIFACT_NAME: custom-report-dir-upload
|
||||||
|
|
||||||
- name: Check downloaded dependency graph
|
- name: Check downloaded dependency graph
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
@ -49,6 +49,10 @@ export class DependencyGraphConfig {
|
|||||||
return path.resolve(getWorkspaceDirectory(), 'dependency-graph-reports')
|
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 {
|
static constructJobCorrelator(workflow: string, jobId: string, matrixJson: string): string {
|
||||||
const matrixString = this.describeMatrix(matrixJson)
|
const matrixString = this.describeMatrix(matrixJson)
|
||||||
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`
|
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`
|
||||||
|
@ -77,7 +77,7 @@ async function downloadAndSubmitDependencyGraphs(config: DependencyGraphConfig):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await submitDependencyGraphs(await downloadDependencyGraphs())
|
await submitDependencyGraphs(await downloadDependencyGraphs(config))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
warnOrFail(config, DependencyGraphOption.DownloadAndSubmit, e)
|
warnOrFail(config, DependencyGraphOption.DownloadAndSubmit, e)
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ async function findAndUploadDependencyGraphs(config: DependencyGraphConfig): Pro
|
|||||||
await uploadDependencyGraphs(await findDependencyGraphFiles(), config)
|
await uploadDependencyGraphs(await findDependencyGraphFiles(), config)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadDependencyGraphs(): Promise<string[]> {
|
async function downloadDependencyGraphs(config: DependencyGraphConfig): Promise<string[]> {
|
||||||
const findBy = github.context.payload.workflow_run
|
const findBy = github.context.payload.workflow_run
|
||||||
? {
|
? {
|
||||||
token: getGithubToken(),
|
token: getGithubToken(),
|
||||||
@ -123,13 +123,19 @@ async function downloadDependencyGraphs(): Promise<string[]> {
|
|||||||
|
|
||||||
const artifactClient = new DefaultArtifactClient()
|
const artifactClient = new DefaultArtifactClient()
|
||||||
|
|
||||||
const dependencyGraphArtifacts = (
|
let dependencyGraphArtifacts = (
|
||||||
await artifactClient.listArtifacts({
|
await artifactClient.listArtifacts({
|
||||||
latest: true,
|
latest: true,
|
||||||
findBy
|
findBy
|
||||||
})
|
})
|
||||||
).artifacts.filter(artifact => artifact.name.startsWith(DEPENDENCY_GRAPH_PREFIX))
|
).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) {
|
for (const artifact of dependencyGraphArtifacts) {
|
||||||
const downloadedArtifact = await artifactClient.downloadArtifact(artifact.id, {
|
const downloadedArtifact = await artifactClient.downloadArtifact(artifact.id, {
|
||||||
findBy
|
findBy
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
import * as setupGradle from '../setup-gradle'
|
import * as setupGradle from '../setup-gradle'
|
||||||
import * as gradle from '../execution/gradle'
|
import * as gradle from '../execution/gradle'
|
||||||
import * as dependencyGraph from '../dependency-graph'
|
import * as dependencyGraph from '../dependency-graph'
|
||||||
@ -24,6 +25,9 @@ export async function run(): Promise<void> {
|
|||||||
// Configure Gradle environment (Gradle User Home)
|
// Configure Gradle environment (Gradle User Home)
|
||||||
await setupGradle.setup(new CacheConfig(), new BuildScanConfig())
|
await setupGradle.setup(new CacheConfig(), new BuildScanConfig())
|
||||||
|
|
||||||
|
// Capture the enabled state of dependency-graph
|
||||||
|
const originallyEnabled = process.env['GITHUB_DEPENDENCY_GRAPH_ENABLED']
|
||||||
|
|
||||||
// Configure the dependency graph submission
|
// Configure the dependency graph submission
|
||||||
const config = new DependencyGraphConfig()
|
const config = new DependencyGraphConfig()
|
||||||
await dependencyGraph.setup(config)
|
await dependencyGraph.setup(config)
|
||||||
@ -53,6 +57,9 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
await dependencyGraph.complete(config)
|
await dependencyGraph.complete(config)
|
||||||
|
|
||||||
|
// Reset the enabled state of dependency graph
|
||||||
|
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', originallyEnabled)
|
||||||
|
|
||||||
saveDeprecationState()
|
saveDeprecationState()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleMainActionError(error)
|
handleMainActionError(error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user