diff --git a/src/main/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationService.java b/src/main/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationService.java index 1b4c51e2397..d6361ebfce8 100644 --- a/src/main/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationService.java +++ b/src/main/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationService.java @@ -18,6 +18,6 @@ public void init(Project project) { } public void addYml(Project project) { - githubActionsService.addYml(project); + githubActionsService.addYmls(project); } } diff --git a/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainService.java b/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainService.java index 4d960088030..3f09a879c51 100644 --- a/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainService.java +++ b/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainService.java @@ -5,9 +5,13 @@ public class GithubActionsDomainService implements GithubActionsService { - public static final String SOURCE = "githubactions"; - public static final String GITHUB_ACTIONS_FOLDER = ".github/workflows/"; - public static final String GITHUB_ACTIONS_YML = "github-actions.yml.mustache"; + public static final String GITHUB_ACTIONS_CI_SOURCE_FOLDER = "githubactions/.github/workflows/"; + public static final String GITHUB_ACTIONS_CI_YML = "github-actions.yml.mustache"; + public static final String GITHUB_ACTIONS_CI_DESTINATION_FOLDER = ".github/workflows/"; + + public static final String GITHUB_ACTIONS_SETUP_SOURCE_FOLDER = "githubactions/.github/actions/setup/"; + public static final String GITHUB_ACTIONS_SETUP_YML = "action.yml.mustache"; + public static final String GITHUB_ACTIONS_SETUP_DESTINATION_FOLDER = ".github/actions/setup/"; private final ProjectRepository projectRepository; @@ -17,11 +21,17 @@ public GithubActionsDomainService(ProjectRepository projectRepository) { @Override public void init(Project project) { - addYml(project); + addYmls(project); } @Override - public void addYml(Project project) { - projectRepository.template(project, SOURCE, GITHUB_ACTIONS_YML, GITHUB_ACTIONS_FOLDER); + public void addYmls(Project project) { + projectRepository.template( + project, + GITHUB_ACTIONS_SETUP_SOURCE_FOLDER, + GITHUB_ACTIONS_SETUP_YML, + GITHUB_ACTIONS_SETUP_DESTINATION_FOLDER + ); + projectRepository.template(project, GITHUB_ACTIONS_CI_SOURCE_FOLDER, GITHUB_ACTIONS_CI_YML, GITHUB_ACTIONS_CI_DESTINATION_FOLDER); } } diff --git a/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsService.java b/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsService.java index 8b7a30d7c9e..ecf518881b5 100644 --- a/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsService.java +++ b/src/main/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsService.java @@ -5,5 +5,5 @@ public interface GithubActionsService { void init(Project project); - void addYml(Project project); + void addYmls(Project project); } diff --git a/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/config/GithubActionsBeanConfiguration.java b/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/config/GithubActionsBeanConfiguration.java index 9bf75914150..b087990607d 100644 --- a/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/config/GithubActionsBeanConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/config/GithubActionsBeanConfiguration.java @@ -2,7 +2,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.objenesis.SpringObjenesis; import tech.jhipster.lite.generator.githubactions.domain.GithubActionsDomainService; import tech.jhipster.lite.generator.githubactions.domain.GithubActionsService; import tech.jhipster.lite.generator.project.domain.ProjectRepository; diff --git a/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/primary/rest/GithubActionsResource.java b/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/primary/rest/GithubActionsResource.java index 326dc144160..736a5cfa29b 100644 --- a/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/primary/rest/GithubActionsResource.java +++ b/src/main/java/tech/jhipster/lite/generator/githubactions/infrastructure/primary/rest/GithubActionsResource.java @@ -26,7 +26,7 @@ class GithubActionsResource { @Operation(summary = "Init Github Actions YML file") @ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file") @PostMapping("/init") - @GeneratorStep(id = "init") + @GeneratorStep(id = "github-actions") public void init(@RequestBody ProjectDTO projectDTO) { Project project = ProjectDTO.toProject(projectDTO); githubActionsApplicationService.init(project); diff --git a/src/main/resources/generator/githubactions/.github/actions/setup/action.yml.mustache b/src/main/resources/generator/githubactions/.github/actions/setup/action.yml.mustache new file mode 100644 index 00000000000..dc603d00457 --- /dev/null +++ b/src/main/resources/generator/githubactions/.github/actions/setup/action.yml.mustache @@ -0,0 +1,23 @@ +name: 'Setup' +description: 'Setup environment with Java 17, Node 16.14.0' +runs: + using: 'composite' + steps: + - name: 'Setup: Node.js' + uses: actions/setup-node@v2.5.0 + with: + node-version: 16.14.0 + - name: 'Setup: update NPM' + shell: bash + run: npm install -g npm + - name: 'Setup: Java 17' + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17.x' + - name: 'Setup: check tools' + shell: bash + run: | + node -v + npm -v + java -version diff --git a/src/main/resources/generator/githubactions/github-actions.yml.mustache b/src/main/resources/generator/githubactions/.github/workflows/github-actions.yml.mustache similarity index 100% rename from src/main/resources/generator/githubactions/github-actions.yml.mustache rename to src/main/resources/generator/githubactions/.github/workflows/github-actions.yml.mustache diff --git a/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationServiceIT.java index 52ad5893ac2..4d85f685d2f 100644 --- a/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsApplicationServiceIT.java @@ -24,7 +24,7 @@ void shouldInit() { } @Test - void shouldAddYml() { + void shouldAddYmls() { Project project = tmpProject(); githubActionsApplicationService.addYml(project); diff --git a/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsAssertFiles.java b/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsAssertFiles.java index 68051735b27..a99626935a1 100644 --- a/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsAssertFiles.java +++ b/src/test/java/tech/jhipster/lite/generator/githubactions/application/GithubActionsAssertFiles.java @@ -8,6 +8,7 @@ public class GithubActionsAssertFiles { public static void assertFilesYml(Project project) { assertFileExist(project, ".github/workflows/github-actions.yml"); + assertFileExist(project, ".github/actions/setup/action.yml"); } public static void assertFilesGithubActions(Project project) { diff --git a/src/test/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainServiceTest.java b/src/test/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainServiceTest.java index 562b7e348e6..f94f7fc1cf7 100644 --- a/src/test/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainServiceTest.java +++ b/src/test/java/tech/jhipster/lite/generator/githubactions/domain/GithubActionsDomainServiceTest.java @@ -36,9 +36,11 @@ void shouldInit() { void shouldAddYml() { Project project = tmpProject(); - assertThatCode(() -> githubActionsDomainService.addYml(project)).doesNotThrowAnyException(); + assertThatCode(() -> githubActionsDomainService.addYmls(project)).doesNotThrowAnyException(); verify(projectRepository) - .template(any(Project.class), eq("githubactions"), eq("github-actions.yml.mustache"), eq(".github/workflows/")); + .template(any(Project.class), eq("githubactions/.github/actions/setup/"), eq("action.yml.mustache"), eq(".github/actions/setup/")); + verify(projectRepository) + .template(any(Project.class), eq("githubactions/.github/workflows/"), eq("github-actions.yml.mustache"), eq(".github/workflows/")); } }