Loading sources/src/dependency-graph.ts +7 −8 Changes for sources/src/dependency-graph.ts: 7 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ import type {PullRequestEvent} from '@octokit/webhooks-types' import * as path from 'path' import fs from 'fs' import * as layout from './repository-layout' import {PostActionJobFailure} from './errors' import {DependencyGraphConfig, DependencyGraphOption, getGithubToken} from './input-params' import {DependencyGraphConfig, DependencyGraphOption, getGithubToken, getWorkspaceDirectory} from './input-params' const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_' Loading @@ -34,10 +33,10 @@ export async function setup(config: DependencyGraphConfig): Promise<void> { maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_SHA', getShaFromContext()) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', layout.workspaceDirectory()) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', getWorkspaceDirectory()) maybeExportVariable( 'DEPENDENCY_GRAPH_REPORT_DIR', path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports') path.resolve(getWorkspaceDirectory(), 'dependency-graph-reports') ) // To clear the dependency graph, we generate an empty graph by excluding all projects and configurations Loading Loading @@ -74,7 +73,7 @@ export async function complete(config: DependencyGraphConfig): Promise<void> { } async function findGeneratedDependencyGraphFiles(): Promise<string[]> { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() return await findDependencyGraphFiles(workspaceDirectory) } Loading @@ -85,7 +84,7 @@ async function uploadDependencyGraphs(dependencyGraphFiles: string[], config: De return } const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() const artifactClient = new DefaultArtifactClient() for (const dependencyGraphFile of dependencyGraphFiles) { Loading Loading @@ -157,7 +156,7 @@ async function submitDependencyGraphFile(jsonFile: string): Promise<void> { } async function downloadDependencyGraphs(): Promise<string[]> { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() const findBy = github.context.payload.workflow_run ? { Loading Loading @@ -220,7 +219,7 @@ function getOctokit(): InstanceType<typeof GitHub> { } function getRelativePathFromWorkspace(file: string): string { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() return path.relative(workspaceDirectory, file) } Loading sources/src/dependency-submission/main.ts +2 −9 Changes for sources/src/dependency-submission/main.ts: 2 added lines, 9 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as setupGradle from '../setup-gradle' import * as execution from '../execution' import * as provisioner from '../provision' import * as layout from '../repository-layout' import * as gradle from '../execution/gradle' import * as dependencyGraph from '../dependency-graph' import {parseArgsStringToArgv} from 'string-argv' Loading @@ -26,9 +24,6 @@ export async function run(): Promise<void> { return } // Download and install Gradle if required const executable = await provisioner.provisionGradle() // Only execute if arguments have been provided const additionalArgs = core.getInput('additional-arguments') const executionArgs = ` Loading @@ -38,10 +33,8 @@ export async function run(): Promise<void> { :ForceDependencyResolutionPlugin_resolveAllDependencies ${additionalArgs} ` const args: string[] = parseArgsStringToArgv(executionArgs) const buildRootDirectory = layout.buildRootDirectory() await execution.executeGradleBuild(executable, buildRootDirectory, args) await gradle.provisionAndMaybeExecute(args) await dependencyGraph.complete(config) } catch (error) { Loading sources/src/execution.ts→sources/src/execution/gradle.ts +26 −1 Changes for sources/src/execution/gradle.ts: 26 added lines, 1 removed line. Original line number Diff line number Diff line import * as core from '@actions/core' import * as exec from '@actions/exec' import * as path from 'path' import * as params from '../input-params' import * as provisioner from './provision' import * as gradlew from './gradlew' import {getWorkspaceDirectory} from '../input-params' export async function provisionAndMaybeExecute(args: string[]): Promise<void> { // Download and install Gradle if required const executable = await provisioner.provisionGradle() export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> { // Only execute if arguments have been provided if (args.length > 0) { await executeGradleBuild(executable, buildRootDirectory(), args) } } async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> { // Use the provided executable, or look for a Gradle wrapper script to run const toExecute = executable ?? gradlew.gradleWrapperScript(root) Loading @@ -15,3 +30,13 @@ export async function executeGradleBuild(executable: string | undefined, root: s core.setFailed(`Gradle build failed: see console output for details`) } } function buildRootDirectory(): string { const baseDirectory = getWorkspaceDirectory() const buildRootDirectoryInput = params.getBuildRootDirectory() const resolvedBuildRootDirectory = buildRootDirectoryInput === '' ? path.resolve(baseDirectory) : path.resolve(baseDirectory, buildRootDirectoryInput) return resolvedBuildRootDirectory } sources/src/gradlew.ts→sources/src/execution/gradlew.ts File moved. View file sources/src/provision.ts→sources/src/execution/provision.ts +3 −3 Changes for sources/src/execution/provision.ts: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ import * as cache from '@actions/cache' import * as toolCache from '@actions/tool-cache' import * as gradlew from './gradlew' import * as params from './input-params' import {handleCacheFailure} from './caching/cache-utils' import {CacheConfig} from './input-params' import * as params from '../input-params' import {handleCacheFailure} from '../caching/cache-utils' import {CacheConfig} from '../input-params' const gradleVersionsBaseUrl = 'https://services.gradle.org/versions' Loading Loading
sources/src/dependency-graph.ts +7 −8 Changes for sources/src/dependency-graph.ts: 7 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ import type {PullRequestEvent} from '@octokit/webhooks-types' import * as path from 'path' import fs from 'fs' import * as layout from './repository-layout' import {PostActionJobFailure} from './errors' import {DependencyGraphConfig, DependencyGraphOption, getGithubToken} from './input-params' import {DependencyGraphConfig, DependencyGraphOption, getGithubToken, getWorkspaceDirectory} from './input-params' const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_' Loading @@ -34,10 +33,10 @@ export async function setup(config: DependencyGraphConfig): Promise<void> { maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_SHA', getShaFromContext()) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', layout.workspaceDirectory()) maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', getWorkspaceDirectory()) maybeExportVariable( 'DEPENDENCY_GRAPH_REPORT_DIR', path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports') path.resolve(getWorkspaceDirectory(), 'dependency-graph-reports') ) // To clear the dependency graph, we generate an empty graph by excluding all projects and configurations Loading Loading @@ -74,7 +73,7 @@ export async function complete(config: DependencyGraphConfig): Promise<void> { } async function findGeneratedDependencyGraphFiles(): Promise<string[]> { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() return await findDependencyGraphFiles(workspaceDirectory) } Loading @@ -85,7 +84,7 @@ async function uploadDependencyGraphs(dependencyGraphFiles: string[], config: De return } const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() const artifactClient = new DefaultArtifactClient() for (const dependencyGraphFile of dependencyGraphFiles) { Loading Loading @@ -157,7 +156,7 @@ async function submitDependencyGraphFile(jsonFile: string): Promise<void> { } async function downloadDependencyGraphs(): Promise<string[]> { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() const findBy = github.context.payload.workflow_run ? { Loading Loading @@ -220,7 +219,7 @@ function getOctokit(): InstanceType<typeof GitHub> { } function getRelativePathFromWorkspace(file: string): string { const workspaceDirectory = layout.workspaceDirectory() const workspaceDirectory = getWorkspaceDirectory() return path.relative(workspaceDirectory, file) } Loading
sources/src/dependency-submission/main.ts +2 −9 Changes for sources/src/dependency-submission/main.ts: 2 added lines, 9 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as setupGradle from '../setup-gradle' import * as execution from '../execution' import * as provisioner from '../provision' import * as layout from '../repository-layout' import * as gradle from '../execution/gradle' import * as dependencyGraph from '../dependency-graph' import {parseArgsStringToArgv} from 'string-argv' Loading @@ -26,9 +24,6 @@ export async function run(): Promise<void> { return } // Download and install Gradle if required const executable = await provisioner.provisionGradle() // Only execute if arguments have been provided const additionalArgs = core.getInput('additional-arguments') const executionArgs = ` Loading @@ -38,10 +33,8 @@ export async function run(): Promise<void> { :ForceDependencyResolutionPlugin_resolveAllDependencies ${additionalArgs} ` const args: string[] = parseArgsStringToArgv(executionArgs) const buildRootDirectory = layout.buildRootDirectory() await execution.executeGradleBuild(executable, buildRootDirectory, args) await gradle.provisionAndMaybeExecute(args) await dependencyGraph.complete(config) } catch (error) { Loading
sources/src/execution.ts→sources/src/execution/gradle.ts +26 −1 Changes for sources/src/execution/gradle.ts: 26 added lines, 1 removed line. Original line number Diff line number Diff line import * as core from '@actions/core' import * as exec from '@actions/exec' import * as path from 'path' import * as params from '../input-params' import * as provisioner from './provision' import * as gradlew from './gradlew' import {getWorkspaceDirectory} from '../input-params' export async function provisionAndMaybeExecute(args: string[]): Promise<void> { // Download and install Gradle if required const executable = await provisioner.provisionGradle() export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> { // Only execute if arguments have been provided if (args.length > 0) { await executeGradleBuild(executable, buildRootDirectory(), args) } } async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> { // Use the provided executable, or look for a Gradle wrapper script to run const toExecute = executable ?? gradlew.gradleWrapperScript(root) Loading @@ -15,3 +30,13 @@ export async function executeGradleBuild(executable: string | undefined, root: s core.setFailed(`Gradle build failed: see console output for details`) } } function buildRootDirectory(): string { const baseDirectory = getWorkspaceDirectory() const buildRootDirectoryInput = params.getBuildRootDirectory() const resolvedBuildRootDirectory = buildRootDirectoryInput === '' ? path.resolve(baseDirectory) : path.resolve(baseDirectory, buildRootDirectoryInput) return resolvedBuildRootDirectory }
sources/src/provision.ts→sources/src/execution/provision.ts +3 −3 Changes for sources/src/execution/provision.ts: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ import * as cache from '@actions/cache' import * as toolCache from '@actions/tool-cache' import * as gradlew from './gradlew' import * as params from './input-params' import {handleCacheFailure} from './caching/cache-utils' import {CacheConfig} from './input-params' import * as params from '../input-params' import {handleCacheFailure} from '../caching/cache-utils' import {CacheConfig} from '../input-params' const gradleVersionsBaseUrl = 'https://services.gradle.org/versions' Loading