Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Github Actions support #717

Merged
merged 4 commits into from
Mar 5, 2022

Conversation

Hawkurane
Copy link
Contributor

Fixes #422

You can do:

POST /api/projects/init
POST /api/github-actions/init

@codecov
Copy link

codecov bot commented Feb 14, 2022

Codecov Report

Merging #717 (3b26f40) into main (6d005dc) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##                main      #717   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      1312      1321    +9     
===========================================
  Files            247       251    +4     
  Lines           4101      4124   +23     
  Branches          71        71           
===========================================
+ Hits            4101      4124   +23     
Impacted Files Coverage Δ
...s/application/GithubActionsApplicationService.java 100.00% <100.00%> (ø)
...thubactions/domain/GithubActionsDomainService.java 100.00% <100.00%> (ø)
...ructure/config/GithubActionsBeanConfiguration.java 100.00% <100.00%> (ø)
...astructure/primary/rest/GithubActionsResource.java 100.00% <100.00%> (ø)
...infrastructure/primary/rest/SpringDocResource.java
...ngdoc/application/SpringDocApplicationService.java
...ver/springboot/mvc/springdoc/domain/SpringDoc.java
...t/mvc/springdoc/domain/SpringDocDomainService.java
...rastructure/config/SpringDocBeanConfiguration.java
...ver/springboot/mvc/springdoc/domain/Springdoc.java 100.00% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d005dc...3b26f40. Read the comment docs.


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.objenesis.SpringObjenesis;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange import

@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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be github-actions, as init is already used


@Override
public void addYml(Project project) {
projectRepository.template(project, SOURCE, GITHUB_ACTIONS_YML, GITHUB_ACTIONS_FOLDER);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pascalgrimaud
Copy link
Member

You could add the api to one of config, in generate.sh

@pascalgrimaud
Copy link
Member

I'm changing it to draft, as there are still some work to do

@pascalgrimaud pascalgrimaud marked this pull request as draft March 5, 2022 11:15
@Hawkurane
Copy link
Contributor Author

Hello @pascalgrimaud i've just pushed the changes concerning the reviews you've made me.

Concerning the generate.sh i'm unsure how to approach this since I don't think there's any real way of checking generated github-actions files besides visually looking the website itself...

If you have any advice LMK :)

@Hawkurane Hawkurane marked this pull request as ready for review March 5, 2022 16:42
@pascalgrimaud
Copy link
Member

Thanks a lot @Hawkurane

About real final tests, I plan to automate a generated project + push to a repository, so it will trigger github actions there :-)

import tech.jhipster.lite.generator.project.domain.Project;

public interface GithubActionsService {
void init(Project project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename to: addGitHubActionsForMaven

public interface GithubActionsService {
void init(Project project);

void addYmls(Project project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need this


@RestController
@RequestMapping("/api/github-actions/")
@Tag(name = "Github Actions")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Tag(name = "Github Actions")
@Tag(name = "GitHub Actions")

this.githubActionsApplicationService = githubActionsApplicationService;
}

@Operation(summary = "Init Github Actions YML file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Operation(summary = "Init Github Actions YML file")
@Operation(summary = "Add GitHub Actions YML files")

}

@Operation(summary = "Init Github Actions YML file")
@ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file")
@ApiResponse(responseCode = "500", description = "An error occurred while adding GitHub Actions")


@Operation(summary = "Init Github Actions YML file")
@ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file")
@PostMapping("/init")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@PostMapping("/init")
@PostMapping("/maven")

@ApiResponse(responseCode = "500", description = "An error occurred while initializing the github-actions.yml.mustache file")
@PostMapping("/init")
@GeneratorStep(id = "github-actions")
public void init(@RequestBody ProjectDTO projectDTO) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename to addGitHubActionsForMaven, but if you don't like it, simply ignore my comment

Comment on lines 9 to 27
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem with indent

Suggested change
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: 20
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

@pascalgrimaud
Copy link
Member

and your code works well (after fixing the indent): see pascalgrimaud/jhlite-sample-app#1

@Hawkurane
Copy link
Contributor Author

@pascalgrimaud thank you for the review,
In the end, i've added a callApi "/api/github-actions/maven" step every time there's a call for the maven build-tools. WDYT?

@pascalgrimaud
Copy link
Member

@Hawkurane : I'd prefer to put it in fullapp as it's specific, but in the end, it won't impact the build, so it's fine, like you wish :)

@pascalgrimaud pascalgrimaud merged commit c8a2937 into jhipster:main Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: GitHub Actions
2 participants