-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update error code crawler version * #566: Add config option for environment * Remove unused constant * #566: Set custom environment for workflow jobs * #566 Add unit tests * Update dependencies * Reduce permissions for GitHub workflows * Update dependencies in test * Reduce GitHub workflow permissions * Update changelog * Fix windows build
- Loading branch information
1 parent
5bf476a
commit 7bc1ed1
Showing
31 changed files
with
416 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ error-tags: | |
PK-CORE: | ||
packages: | ||
- com.exasol.projectkeeper | ||
highest-index: 206 | ||
highest-index: 207 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...per/src/main/java/com/exasol/projectkeeper/validators/files/GitHubWorkflowCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.exasol.projectkeeper.validators.files; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This class customizes a GitHub workflow by delegating to a list of {@link WorkflowCustomizer}s. | ||
*/ | ||
class GitHubWorkflowCustomizer implements ContentCustomizingTemplate.ContentCustomizer { | ||
private static final String GENERATED_COMMENT = "# This file was generated by Project Keeper.\n"; | ||
private final GitHubWorkflowIO yaml; | ||
private final List<WorkflowCustomizer> customizer; | ||
|
||
GitHubWorkflowCustomizer(final WorkflowCustomizer... customizer) { | ||
this(GitHubWorkflowIO.create(), asList(customizer)); | ||
} | ||
|
||
GitHubWorkflowCustomizer(final GitHubWorkflowIO yaml, final List<WorkflowCustomizer> customizer) { | ||
this.yaml = yaml; | ||
this.customizer = customizer; | ||
} | ||
|
||
@Override | ||
public String customizeContent(final String content) { | ||
final GitHubWorkflow workflow = yaml.loadWorkflow(content); | ||
customizeWorkflow(workflow); | ||
return GENERATED_COMMENT + yaml.dumpWorkflow(workflow); | ||
} | ||
|
||
private void customizeWorkflow(final GitHubWorkflow workflow) { | ||
this.customizer.forEach(c -> c.applyCustomization(workflow)); | ||
} | ||
|
||
/** | ||
* Interface for customizing a GitHub workflow. Implementations of this interface can modify the given workflow as | ||
* required. | ||
*/ | ||
interface WorkflowCustomizer { | ||
/** | ||
* Apply the customization to the given workflow. | ||
* | ||
* @param workflow workflow to customize | ||
*/ | ||
void applyCustomization(GitHubWorkflow workflow); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...n/java/com/exasol/projectkeeper/validators/files/GitHubWorkflowEnvironmentCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.exasol.projectkeeper.validators.files; | ||
|
||
import com.exasol.errorreporting.ExaError; | ||
import com.exasol.projectkeeper.validators.files.GitHubWorkflow.Job; | ||
|
||
class GitHubWorkflowEnvironmentCustomizer implements GitHubWorkflowCustomizer.WorkflowCustomizer { | ||
|
||
private final String environmentName; | ||
private final String jobId; | ||
|
||
GitHubWorkflowEnvironmentCustomizer(final String jobId, final String environmentName) { | ||
this.jobId = jobId; | ||
this.environmentName = environmentName; | ||
} | ||
|
||
// [impl->dsn~customize-build-process.ci-build.environment~1] | ||
@Override | ||
public void applyCustomization(final GitHubWorkflow workflow) { | ||
if (environmentName == null) { | ||
return; | ||
} | ||
final Job job = workflow.getJob(jobId); | ||
if (job == null) { | ||
throw new IllegalArgumentException(ExaError.messageBuilder("E-PK-CORE-207") | ||
.message("GitHub Workflow does not have a job with ID {{job id}}", jobId).toString()); | ||
} | ||
job.setEnvironment(this.environmentName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.