Skip to content

Commit

Permalink
Add configuration for artifact retention
Browse files Browse the repository at this point in the history
  • Loading branch information
lerebear committed Mar 4, 2024
1 parent c876bf0 commit b012348
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
coverage/
coverage/
src/configuration.ts
18 changes: 14 additions & 4 deletions dist/config/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions src/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@
"type": "boolean",
"default": false
},
"persistScoreArtifact": {
"description": "Whether or not to create a workflow artifact that contains details about the score",
"type": "boolean",
"default": false
"archiving": {
"description": "Configuration options for persisting the output of this workflow",
"type": "object",
"properties": {
"persistScoreArtifact": {
"description": "Whether or not to create a workflow artifact that contains details about the score",
"type": "boolean",
"default": false
},
"artifactRetention": {
"description": "Retention period (in days) for the artifact created by this workflow. The actual retention period used may be shorter than this in the presence of an overriding repository- or organization- level retention period setting.",
"type": "number"
}
}
},
"sizeup": {
"$ref": "https://raw.githubusercontent.com/lerebear/sizeup/main/src/config/schema.json"
Expand Down
75 changes: 42 additions & 33 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,61 @@ export interface Configuration {
/**
* Whether or not to apply the category label to each assessed pull request
*/
applyCategoryLabels?: boolean
applyCategoryLabels?: boolean;
/**
* Whether or not to skip applying the category label to a draft pull request
*/
excludeDraftPullRequests?: boolean
excludeDraftPullRequests?: boolean;
/**
* The prefix to add to each category label that we apply
*/
categoryLabelPrefix?: string
}
categoryLabelPrefix?: string;
};
/**
* Configuration that controls how we add comments to assessed pull requests
*/
commenting?: {
/**
* Whether or not to add a comment to each assessed pull request that exceeds the configured score threshold
*/
addCommentWhenScoreThresholdHasBeenExceeded?: boolean
addCommentWhenScoreThresholdHasBeenExceeded?: boolean;
/**
* Whether or not to skip commenting on a draft pull request that exceeds the configured score threshold
*/
excludeDraftPullRequests?: boolean
excludeDraftPullRequests?: boolean;
/**
* The score above which this tool will post a comment on the pull request.
*/
scoreThreshold?: number
scoreThreshold?: number;
/**
* The template for the comment that should be added to each pull request that exceeds the configured score threshold
*/
commentTemplate?: string
}
commentTemplate?: string;
};
/**
* A list of GitHub handles for users or teams that have opted into this workflow
*
* @minItems 1
*/
optIns?: [string, ...string[]]
optIns?: [string, ...string[]];
/**
* Whether or not to compute a score even for users who have opted out of the workflow
*/
shadowOptOuts?: boolean
shadowOptOuts?: boolean;
/**
* Whether or not to create a workflow artifact that contains details about the score
* Configuration options for persisting the output of this workflow
*/
persistScoreArtifact?: boolean
sizeup?: Configuration1
archiving?: {
/**
* Whether or not to create a workflow artifact that contains details about the score
*/
persistScoreArtifact?: boolean;
/**
* Retention period (in days) for the artifact created by this workflow. The actual retention period used may be shorter than this in the presence of an overriding repository- or organization- level retention period setting.
*/
artifactRetention?: number;
};
sizeup?: Configuration1;
}
/**
* YAML configuration accepted by sizeup
Expand All @@ -77,62 +86,62 @@ export interface Configuration1 {
/**
* human-friendly name of the category
*/
name: string
name: string;
/**
* A visual label that should be used to represent this category
*/
label?: {
/**
* name of the label that should be used to represent this category
*/
name: string
name: string;
/**
* describes the meaning of the label that will be used to represent this category
*/
description?: string
description?: string;
/**
* preferred CSS hex color label that should be used to represent this category
*/
color?: string
}
color?: string;
};
/**
* inclusive upper bound on the score that a pull request must have to be assigned this category
*/
lte?: number
lte?: number;
},
...{
/**
* human-friendly name of the category
*/
name: string
name: string;
/**
* A visual label that should be used to represent this category
*/
label?: {
/**
* name of the label that should be used to represent this category
*/
name: string
name: string;
/**
* describes the meaning of the label that will be used to represent this category
*/
description?: string
description?: string;
/**
* preferred CSS hex color label that should be used to represent this category
*/
color?: string
}
color?: string;
};
/**
* inclusive upper bound on the score that a pull request must have to be assigned this category
*/
lte?: number
lte?: number;
}[]
]
];
scoring?: {
/**
* an expression, written in prefix-notation, that describes how to combine features to produce a score
*/
formula: string
formula: string;
/**
* named expression aliases, each of which can be used as shortand in a formula
*/
Expand All @@ -141,15 +150,15 @@ export interface Configuration1 {
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^[\w][\w-]*$".
*/
[k: string]: string
}
}
[k: string]: string;
};
};
/**
* glob expressions matching file patterns that should be considered as tests during the scoring process
*/
testFilePatterns?: string[]
testFilePatterns?: string[];
/**
* glob expressions matching file patterns that are ignored in the scoring process
*/
ignoredFilePatterns?: string[]
ignoredFilePatterns?: string[];
}
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async function createScoreArtifact(
score: Score,
config: Configuration
): Promise<void> {
if (!config.persistScoreArtifact) {
if (!config.archiving?.persistScoreArtifact) {
core.info('Skipping score artifact creation')
return
}
Expand All @@ -281,5 +281,7 @@ async function createScoreArtifact(
)

const client = new DefaultArtifactClient()
await client.uploadArtifact('sizeup-score', [scoreFile], tmpDir)
await client.uploadArtifact('sizeup-score', [scoreFile], tmpDir, {
retentionDays: config.archiving?.artifactRetention
})
}

0 comments on commit b012348

Please sign in to comment.