Skip to content

Commit

Permalink
Add separate step for building node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
vivid-cpreston committed Apr 11, 2024
1 parent 8bfcd5b commit 39e0542
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 14 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ name: DEV Deploy - Manual Trigger
on:
workflow_dispatch:

env:
API_VERSION: "3.2.0"

jobs:
build-underwriting-api:
uses: ./.github/workflows/build-package.yml
secrets: inherit
with:
ENVIRONMENT: DEV
MICROSERVICE_NAME: cirras-underwriting-api
EXPORT_FILE: CIRRAS_UNDERWRITING_API_swagger.json
EXPORT_PATH: cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/target/swagger.json

build-underwriting-listener-api:
uses: ./.github/workflows/build-package.yml
Expand All @@ -18,9 +23,22 @@ jobs:
ENVIRONMENT: DEV
MICROSERVICE_NAME: cirras-underwriting-listener-api

build-and-upload-npm-modules:
uses: ./.github/workflows/build-npm.yml
secrets: inherit
needs: build-underwriting-api
with:
ENVIRONMENT: DEV
MICROSERVICE_NAME: cirras-underwriting-ngclient-lib
DOWNLOAD_FILE: CIRRAS_UNDERWRITING_API_swagger.json
DOWNLOAD_PATH: cirras-underwriting-ngclient-lib/cirras-underwriting-ngclient-lib/src/main/angular/src/swagger/swagger.json

build-underwriting-war:
uses: ./.github/workflows/build-package.yml
secrets: inherit
needs: build-and-upload-npm-modules
with:
ENVIRONMENT: DEV
MICROSERVICE_NAME: cirras-underwriting-war
DOWNLOAD_FILE: cirras-underwriting-api-${{ env.API_VERSION }}.tgz
DOWNLOAD_PATH: cirras-underwriting-war/cirras-underwriting-war/src/main/angular/cirras-underwriting-api-${{ env.API_VERSION }}.tgz
75 changes: 75 additions & 0 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: build npm-lib

on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
MICROSERVICE_NAME:
required: true
type: string
EXPORT_MODULE:
required: false
type: string
DOWNLOAD_FILE:
required: false
type: string
DOWNLOAD_PATH:
required: false
type: string

jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT }}
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'

- name: Set up nodejs
uses: actions/setup-node@v4
with:
node-version: 14

#NOTE: necessary to build client-war
- name: Add .npmrc file
run: echo -e '${{ secrets.NPMRC }}' > ~/.npmrc

- name: download files from other jobs
if: ${{ inputs.DOWNLOAD_FILE }}
uses: actions/download-artifact
with:
name: ${{ inputs.DOWNLOAD_FILE}}
path: ${{ inputs.DOWNLOAD_PATH}}

- name:
run:
cd ${{ inputs.MICROSERVICE_NAME }}/${{ inputs.MICROSERVICE_NAME }}/src/main/angular
npm install
npm run generate
npm run build
npm pack

- name: Extract version number
id: getVersion
run: echo "VERSION_NUMBER=$(grep -Po -m 1 '(?<=<version>)[0-9\.]+' ${{ inputs.MICROSERVICE_NAME }}/pom.xml )" >> $GITHUB_OUTPUT

- name: upload module
uses: actions/upload-artifact
with:
name: ${{inputs.EXPORT_MODULE}}
path: ${{ inputs.MICROSERVICE_NAME }}/${{ inputs.MICROSERVICE_NAME }}/src/main/angular/${{ inputs.EXPORT_MODULE}}-${{ steps.getVersion.outputs.VERSION_NUMBER }}.tgz


38 changes: 25 additions & 13 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ on:
MICROSERVICE_NAME:
required: true
type: string
EXPORT_FILE:
required: false
type: string
EXPORT_PATH:
required: false
type: string
DOWNLOAD_FILE:
required: false
type: string
DOWNLOAD_PATH:
required: false
type: string

env:
DIRECTORY_SUFFIX: ${{ contains(inputs.MICROSERVICE_NAME, '-api') && '-rest-endpoints' || '' }}
Expand Down Expand Up @@ -40,26 +52,26 @@ jobs:
- name: Add .npmrc file
run: echo -e '${{ secrets.NPMRC }}' > ~/.npmrc

#NOTE: necessary to build client-war until service account with write permissions is available
#TODO: remove this, revert changes to cirras-underwriting-war package.json
- name: Install npm module dependency for -war
run: |
if ${{ contains(inputs.MICROSERVICE_NAME, '-war')}}; then
mvn --settings=settings.xml --batch-mode --update-snapshots -f cirras-underwriting-api/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} install
cp cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/target/swagger.json cirras-underwriting-ngclient-lib/cirras-underwriting-ngclient-lib/src/main/angular/src/swagger/swagger.json
cd cirras-underwriting-ngclient-lib/cirras-underwriting-ngclient-lib/src/main/angular
npm install
npm run generate
npm run build
fi
exit 0
- name: download files from other jobs
if: ${{ inputs.DOWNLOAD_FILE }}
uses: actions/download-artifact
with:
name: ${{ inputs.DOWNLOAD_FILE}}
path: ${{ inputs.DOWNLOAD_PATH}}

- name: Build with Maven
run: |
export MAVEN_OPTS="-Xmx3072m -XX:MaxMetaspaceSize=512m"
export NODE_OPTIONS="--max-old-space-size=4096"
mvn --settings=settings.xml --batch-mode --update-snapshots -f ${{ inputs.MICROSERVICE_NAME }}/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} package
- name: Export file between jobs
uses: actions/upload-artifact
if: ${{ inputs.EXPORT_FILE }}
with:
name: ${{ inputs.EXPORT_FILE }}
path: ${{ inputs.EXPORT_PATH }}

- name: Cache local Maven repository
uses: actions/cache@v2
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target/
**/generated/**
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@angular/router": "^13.4.0",
"@angular/service-worker": "^13.4.0",
"@busacca/ng-pick-datetime": "^9.0.2",
"@cirras/cirras-underwriting-api": "file:/home/runner/work/nr-brmb-pim/nr-brmb-pim/cirras-underwriting-ngclient-lib/cirras-underwriting-ngclient-lib/src/main/angular",
"@cirras/cirras-underwriting-api": "file:./cirras-underwriting-api-3.2.0.tgz",
"@ng-select/ng-select": "^5.0.3",
"@ngrx/effects": "^13.2.0",
"@ngrx/entity": "^13.2.0",
Expand Down

0 comments on commit 39e0542

Please sign in to comment.