Skip to content

Commit 081315c

Browse files
authored
Added github action in generated project (jhipster#1209)
* Added github ci * Added node setup * Compose with cicd in app generator * Added ci choice in integration test * Fix integration test
1 parent 0a768a9 commit 081315c

File tree

67 files changed

+241
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+241
-69
lines changed

.github/workflows/generator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
node-version: ${{ matrix.node_version }}
2626
- name: 'install required npm version'
27-
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants').NPM_VERSION);")
27+
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants.cjs').NPM_VERSION);")
2828
- run: git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit
2929
shell: bash
3030
- run: npm ci

.github/workflows/test-integration-jwt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
with:
6363
node-version: ${{ matrix.node_version }}
6464
- name: 'install required npm version'
65-
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants').NPM_VERSION);")
65+
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants.cjs').NPM_VERSION);")
6666
- uses: joschi/setup-jdk@v2
6767
with:
6868
java-version: '11' # The OpenJDK version to make available on the path

.github/workflows/test-integration-microservice.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
node-version: ${{ matrix.node_version }}
3737
- name: 'install required npm version'
38-
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants').NPM_VERSION);")
38+
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants.cjs').NPM_VERSION);")
3939
- uses: actions/setup-dotnet@v1
4040
with:
4141
dotnet-version: '6.0.x'

.github/workflows/test-integration-oauth.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
with:
6060
node-version: ${{ matrix.node_version }}
6161
- name: 'install required npm version'
62-
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants').NPM_VERSION);")
62+
run: npm install -g npm@$(node -e "console.log(require('./generators/generator-dotnetcore-constants.cjs').NPM_VERSION);")
6363
- uses: actions/setup-dotnet@v1
6464
with:
6565
dotnet-version: '6.0.x'

generators/app/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable consistent-return */
22
const chalk = require('chalk');
33
const AppGenerator = require('generator-jhipster/generators/app');
4+
const { GENERATOR_CI_CD } = require('generator-jhipster/generators/generator-list');
45
const packagejs = require('../../package.json');
56
const prompts = require('./prompts');
67

@@ -117,7 +118,12 @@ module.exports = class extends AppGenerator {
117118
}
118119

119120
get composing() {
120-
return super._composing();
121+
return {
122+
...super._composing(),
123+
async composeWithCiCd () {
124+
await this.composeWithJHipster(GENERATOR_CI_CD, true);
125+
}
126+
};
121127
}
122128

123129
get loading() {

generators/ci-cd/generator.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import chalk from 'chalk';
22
import CiCdGenerator from 'generator-jhipster/esm/generators/ci-cd';
3+
import { GITHUB, GITLAB } from '../generator-dotnetcore-constants.mjs';
34
import {
45
PRIORITY_PREFIX,
56
PROMPTING_PRIORITY,
@@ -28,8 +29,9 @@ export default class extends CiCdGenerator {
2829
if (this.ciType) return;
2930

3031
const ciTypeChoices = [
31-
{ value: 'gitlab', name: 'Gitlab CI', },
32-
{ value: 'github', name: 'Github Action', },
32+
{ value: GITHUB , name: 'Github Action', },
33+
{ value: GITLAB, name: 'Gitlab CI', },
34+
{ value: 'noci' , name: 'No CI', },
3335
];
3436

3537
const answers = await this.prompt([
@@ -38,7 +40,7 @@ export default class extends CiCdGenerator {
3840
name: 'ciType',
3941
message: `What CI/CD pipeline do you want to generate ?`,
4042
choices: ciTypeChoices,
41-
default: 'github',
43+
default: GITHUB,
4244
},
4345
]);
4446
this.ciType = this.blueprintConfig.ciType = answers.ciType;
@@ -63,7 +65,12 @@ export default class extends CiCdGenerator {
6365
async writingCiFiles() {
6466
await this.writeFiles({
6567
sections: {
66-
files: [{ templates: ['template-file-app'] }],
68+
files: [
69+
{
70+
condition: ctx => ctx.ciType === GITHUB,
71+
templates: ['.github/workflows/dotnet.yml']
72+
},
73+
],
6774
},
6875
context: this,
6976
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: 16
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v3
19+
with:
20+
dotnet-version: 6.0.x
21+
- name: Restore dependencies
22+
run: dotnet restore
23+
- name: Build
24+
run: dotnet build --no-restore
25+
- name: Test
26+
run: dotnet test --no-build --verbosity normal

generators/ci-cd/templates/template-file-app.ejs

Whitespace-only changes.

generators/client/files-angular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
const constants = require('../generator-dotnetcore-constants');
20+
const constants = require('../generator-dotnetcore-constants.cjs');
2121

2222
/* Constants use throughout */
2323
const SERVER_SRC_DIR = constants.SERVER_SRC_DIR;

generators/client/files-blazor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
const constants = require('../generator-dotnetcore-constants');
19+
const constants = require('../generator-dotnetcore-constants.cjs');
2020

2121
/* Constants use throughout */
2222
const CLIENT_SRC_DIR = constants.CLIENT_SRC_DIR;

0 commit comments

Comments
 (0)