Skip to content

Commit

Permalink
Added changes for MR Reviews and added a step in generate.sh for ever…
Browse files Browse the repository at this point in the history
…y projects using maven build-tools
  • Loading branch information
Hawkurane committed Mar 5, 2022
1 parent 2f0b2f2 commit 3b26f40
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public GithubActionsApplicationService(GithubActionsService githubActionsService
}

public void init(Project project) {
githubActionsService.init(project);
}

public void addYml(Project project) {
githubActionsService.addYmls(project);
githubActionsService.addGitHubActionsForMaven(project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ public GithubActionsDomainService(ProjectRepository projectRepository) {
}

@Override
public void init(Project project) {
public void addGitHubActionsForMaven(Project project) {
addYmls(project);
}

@Override
public void addYmls(Project project) {
private void addYmls(Project project) {
projectRepository.template(
project,
GITHUB_ACTIONS_SETUP_SOURCE_FOLDER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
import tech.jhipster.lite.generator.project.domain.Project;

public interface GithubActionsService {
void init(Project project);

void addYmls(Project project);
void addGitHubActionsForMaven(Project project);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@RestController
@RequestMapping("/api/github-actions/")
@Tag(name = "Github Actions")
@Tag(name = "GitHub Actions")
class GithubActionsResource {

private final GithubActionsApplicationService githubActionsApplicationService;
Expand All @@ -23,11 +23,11 @@ class GithubActionsResource {
this.githubActionsApplicationService = githubActionsApplicationService;
}

@Operation(summary = "Init Github Actions YML file")
@ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file")
@PostMapping("/init")
@Operation(summary = "Init Github Actions YML files")
@ApiResponse(responseCode = "500", description = "An error occurred while adding GitHub Actions")
@PostMapping("/maven")
@GeneratorStep(id = "github-actions")
public void init(@RequestBody ProjectDTO projectDTO) {
public void addGitHubActionsForMaven(@RequestBody ProjectDTO projectDTO) {
Project project = ProjectDTO.toProject(projectDTO);
githubActionsApplicationService.init(project);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ jobs:
#--------------------------------------------------
tests:
name: tests
runs-on: ubuntu-latest
timeout-minutes: 2
steps:{{=<% %>=}}
- name: 'Setup: checkout project'
uses: actions/checkout@v2
- name: 'Setup: environment'
id: setup
uses: ./.github/actions/setup
- name: 'Init: cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-<%={{ }}=%>
- name: 'Test: run tests'
run: |
chmod +x mvnw
./mvnw clean verify
runs-on: ubuntu-latest
timeout-minutes: 2
steps:{{=<% %>=}}
- name: 'Setup: checkout project'
uses: actions/checkout@v2
- name: 'Setup: environment'
id: setup
uses: ./.github/actions/setup
- name: 'Init: cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-<%={{ }}=%>
- name: 'Test: run tests'
run: |
chmod +x mvnw
./mvnw clean verify
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,4 @@ void shouldInit() {

assertFilesYml(project);
}

@Test
void shouldAddYmls() {
Project project = tmpProject();

githubActionsApplicationService.addYml(project);

assertFilesYml(project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ class GithubActionsDomainServiceTest {
void shouldInit() {
Project project = tmpProject();

assertThatCode(() -> githubActionsDomainService.init(project)).doesNotThrowAnyException();
}

@Test
void shouldAddYml() {
Project project = tmpProject();

assertThatCode(() -> githubActionsDomainService.addYmls(project)).doesNotThrowAnyException();
assertThatCode(() -> githubActionsDomainService.addGitHubActionsForMaven(project)).doesNotThrowAnyException();

verify(projectRepository)
.template(any(Project.class), eq("githubactions/.github/actions/setup/"), eq("action.yml.mustache"), eq(".github/actions/setup/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void shouldInit() throws Exception {
ProjectDTO projectDTO = readFileToObject("json/chips.json", ProjectDTO.class).folder(FileUtils.tmpDirForTest());

mockMvc
.perform(post("/api/github-actions/init").contentType(MediaType.APPLICATION_JSON).content(convertObjectToJsonBytes(projectDTO)))
.perform(post("/api/github-actions/maven").contentType(MediaType.APPLICATION_JSON).content(convertObjectToJsonBytes(projectDTO)))
.andExpect(status().isOk());

Project project = ProjectDTO.toProject(projectDTO);
Expand Down
2 changes: 2 additions & 0 deletions tests-ci/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ callApi() {
springboot() {
callApi "/api/projects/init"
callApi "/api/build-tools/maven"
callApi "/api/github-actions/maven"
callApi "/api/servers/java/base"
callApi "/api/servers/java/jacoco-minimum-coverage"
callApi "/api/servers/spring-boot"
Expand All @@ -41,6 +42,7 @@ springboot() {
springboot_undertow() {
callApi "/api/projects/init"
callApi "/api/build-tools/maven"
callApi "/api/github-actions/maven"
callApi "/api/servers/java/base"
callApi "/api/servers/java/jacoco-minimum-coverage"
callApi "/api/servers/spring-boot"
Expand Down

0 comments on commit 3b26f40

Please sign in to comment.