Merge pull request #87 from actions/elr/inputs

add inputs used by autosubmission
This commit is contained in:
E. Lynette Rayle
2025-05-29 22:08:57 -04:00
committed by GitHub
5 changed files with 125 additions and 15 deletions
+6 -1
View File
@@ -28,5 +28,10 @@ jobs:
run: npm rebuild && npm run all
- name: Verify no uncommitted files
run: '[ -z "$(git status --porcelain=v1 2>/dev/null)" ]'
run: |
if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then
echo "There are uncommitted changes!"
git status --porcelain=v1
exit 1
fi
shell: bash
+28
View File
@@ -17,6 +17,34 @@ inputs:
required: true
description: 'Build target to detect build dependencies. If unspecified, will use "all", with will detect all dependencies used in all build targets (including tests and tools).'
default: 'all'
snapshot-sha:
description: The SHA that the results will be linked to in the dependency snapshot
type: string
required: false
default: ''
snapshot-ref:
description: The ref that the results will be linked to in the dependency snapshot
type: string
required: false
default: ''
# If any of detector-name, detector-version, or detector-url are provided, they all have to be provided.
# Defaults will be used if none are not provided. If only one or two are provided, the action will fail.
detector-name:
description: The name of the detector that generated the dependency snapshot
type: string
required: false
default: ''
detector-version:
description: The version of the detector that generated the dependency snapshot
type: string
required: false
default: ''
detector-url:
description: The URL to the detector that generated the dependency snapshot
type: string
required: false
default: ''
runs:
using: 'node20'
main: 'dist/index.js'
Generated Vendored
+39 -5
View File
@@ -94,15 +94,49 @@ function main() {
}
manifest.addIndirectDependency(dep);
});
const snapshot = new dependency_submission_toolkit_1.Snapshot({
name: 'actions/go-dependency-submission',
url: 'https://github.com/actions/go-dependency-submission',
version: '0.0.1'
}, github.context, {
let snapshotDetector;
const detectorName = core.getInput('detector-name');
const detectorUrl = core.getInput('detector-url');
const detectorVersion = core.getInput('detector-version');
if (detectorName === '' && detectorUrl === '' && detectorVersion === '') {
// use defaults if none are specified
snapshotDetector = {
name: 'actions/go-dependency-submission',
url: 'https://github.com/actions/go-dependency-submission',
version: '0.0.1'
};
}
else if (detectorName === '' ||
detectorUrl === '' ||
detectorVersion === '') {
// if any of detectorName, detectorUrl, or detectorVersion have value, then they are all required
throw new Error("Invalid input: if any of 'detector-name', 'detector-url', or 'detector-version' have value, then thay are all required.");
}
else {
// use inputs since all are specified
snapshotDetector = {
name: detectorName,
url: core.getInput('detector-url', { required: true }),
version: core.getInput('detector-version', { required: true })
};
}
const snapshot = new dependency_submission_toolkit_1.Snapshot(snapshotDetector, github.context, {
correlator: `${github.context.job}-${goBuildTarget}`,
id: github.context.runId.toString()
});
snapshot.addManifest(manifest);
// only override the sha if the input has a value
// otherwise, continue to use the sha set from the context in the Snapshot constructor
const inputSHA = core.getInput('sha');
if (inputSHA !== '') {
snapshot.sha = inputSHA;
}
// only override the ref if the input has a value
// otherwise, continue to use the ref set from the context in the Snapshot constructor
const inputRef = core.getInput('ref');
if (inputRef !== '') {
snapshot.ref = inputRef;
}
(0, dependency_submission_toolkit_1.submitSnapshot)(snapshot);
});
}
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+51 -8
View File
@@ -77,19 +77,62 @@ async function main () {
manifest.addIndirectDependency(dep)
})
const snapshot = new Snapshot(
{
type SnapshotDetector = {
name: string
url: string
version: string
}
let snapshotDetector: SnapshotDetector
const detectorName = core.getInput('detector-name')
const detectorUrl = core.getInput('detector-url')
const detectorVersion = core.getInput('detector-version')
if (detectorName === '' && detectorUrl === '' && detectorVersion === '') {
// use defaults if none are specified
snapshotDetector = {
name: 'actions/go-dependency-submission',
url: 'https://github.com/actions/go-dependency-submission',
version: '0.0.1'
},
github.context,
{
correlator: `${github.context.job}-${goBuildTarget}`,
id: github.context.runId.toString()
}
)
} else if (
detectorName === '' ||
detectorUrl === '' ||
detectorVersion === ''
) {
// if any of detectorName, detectorUrl, or detectorVersion have value, then they are all required
throw new Error(
"Invalid input: if any of 'detector-name', 'detector-url', or 'detector-version' have value, then thay are all required."
)
} else {
// use inputs since all are specified
snapshotDetector = {
name: detectorName,
url: core.getInput('detector-url', { required: true }),
version: core.getInput('detector-version', { required: true })
}
}
const snapshot = new Snapshot(snapshotDetector, github.context, {
correlator: `${github.context.job}-${goBuildTarget}`,
id: github.context.runId.toString()
})
snapshot.addManifest(manifest)
// only override the sha if the input has a value
// otherwise, continue to use the sha set from the context in the Snapshot constructor
const inputSHA = core.getInput('sha')
if (inputSHA !== '') {
snapshot.sha = inputSHA
}
// only override the ref if the input has a value
// otherwise, continue to use the ref set from the context in the Snapshot constructor
const inputRef = core.getInput('ref')
if (inputRef !== '') {
snapshot.ref = inputRef
}
submitSnapshot(snapshot)
}