Skip to content

Commit e220cbd

Browse files
authored
fix: Optimize image builds (#2445)
* Ignore tests in ui tasks when packaging for images Signed-off-by: Carson Cook <carson.cook@ibm.com> * Exclude tests from apiml common lib packaging Signed-off-by: Carson Cook <carson.cook@ibm.com> * Add full build and test before image building Signed-off-by: Carson Cook <carson.cook@ibm.com> * Install only required deps in ui images Signed-off-by: Carson Cook <carson.cook@ibm.com>
1 parent 5fd8b31 commit e220cbd

File tree

10 files changed

+59
-8
lines changed

10 files changed

+59
-8
lines changed

.github/workflows/image-publish-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
default: 'all'
2020

2121
jobs:
22-
build-services:
22+
build-test-services:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v2
@@ -41,7 +41,7 @@ jobs:
4141

4242
publish-images:
4343
needs:
44-
- build-services
44+
- build-test-services
4545
uses: zowe/api-layer/.github/workflows/build-conformant-images.yml@master
4646
with:
4747
service: ${{ github.event.inputs.service }}

.github/workflows/image-snapshot-release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ on:
55
branches: [ master, v2.x.x ]
66

77
jobs:
8+
build-test-services:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- uses: ./.github/actions/setup
16+
17+
- name: Build and test services
18+
run: ./gradlew build
19+
20+
- uses: ./.github/actions/teardown
21+
822
publish-images:
23+
needs:
24+
- build-test-services
925
uses: zowe/api-layer/.github/workflows/build-conformant-images.yml@master
1026
with:
1127
forceNoRelease: true

.github/workflows/image-specific-release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@ on:
88
required: true
99

1010
jobs:
11+
build-test-services:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.head_ref }}
17+
18+
- uses: ./.github/actions/setup
19+
20+
- name: Build and test services
21+
run: ./gradlew build
22+
23+
- uses: ./.github/actions/teardown
24+
1125
publish-images:
26+
needs:
27+
- build-test-services
1228
uses: zowe/api-layer/.github/workflows/build-conformant-images.yml@master
1329
with:
1430
version: ${{ github.event.inputs.release_version }}

api-catalog-ui/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ node {
1515
nodeProjectDir = file("${project.projectDir}/frontend")
1616
}
1717

18+
if (project.hasProperty('omitDevDependencies')) {
19+
npmInstall.args = ['--production', '--omit=dev'] // different args for different npm versions
20+
}
21+
1822
// =================================================
1923
//
2024
// Please manage all task dependencies in here and

containers/api-catalog-services/prepare.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ cleanUpWorkingFolder
4242
api_catalog_package="api-catalog-package"
4343
apiml_common_package="apiml-common-lib-package"
4444

45-
buildPackage $api_catalog_package "packageApiCatalog"
46-
buildPackage $apiml_common_package "packageCommonLib"
45+
ignoredUiTasks="$(getIgnoredUiTasks "api-catalog-ui")"
46+
buildPackage $api_catalog_package "packageApiCatalog -PomitDevDependencies ${ignoredUiTasks}"
47+
buildApimlCommonPackage
4748

4849
preparePackage $api_catalog_package
4950
preparePackage $apiml_common_package "apiml-common-lib"

containers/discovery-service/prepare.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ discovery_package="discovery-package"
4343
apiml_common_package="apiml-common-lib-package"
4444

4545
buildPackage $discovery_package "packageDiscovery"
46-
buildPackage $apiml_common_package "packageCommonLib"
46+
buildApimlCommonPackage
4747

4848
preparePackage $discovery_package
4949
preparePackage $apiml_common_package "apiml-common-lib"

containers/gateway-service/prepare.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ gateway_package="gateway-package"
4343
apiml_common_package="apiml-common-lib-package"
4444

4545
buildPackage $gateway_package "packageApiGateway"
46-
buildPackage $apiml_common_package "packageCommonLib"
46+
buildApimlCommonPackage
4747

4848
preparePackage $gateway_package
4949
preparePackage $apiml_common_package "apiml-common-lib"

containers/metrics-service/prepare.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ cleanUpWorkingFolder
4242
metrics_package="metrics-service-package"
4343
apiml_common_package="apiml-common-lib-package"
4444

45-
buildPackage $metrics_package "packageMetricsService"
46-
buildPackage $apiml_common_package "packageCommonLib"
45+
ignoredUiTasks="$(getIgnoredUiTasks "metrics-service-ui")"
46+
buildPackage $metrics_package "packageMetricsService -P omitDevDependencies ${ignoredUiTasks}"
47+
buildApimlCommonPackage
4748

4849
preparePackage $metrics_package
4950
preparePackage $apiml_common_package "apiml-common-lib"

containers/prepare-utils.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ function cleanUpWorkingFolder {
6363
mkdir -p "${BASE_DIR}/${WORK_DIR}"
6464
}
6565

66+
function getIgnoredUiTasks {
67+
ui_project=$1
68+
echo "-x ${ui_project}:test -x ${ui_project}:npmLint"
69+
}
70+
6671
function buildPackage {
6772
service_package=$1
6873
package_task=$2
@@ -75,6 +80,10 @@ function buildPackage {
7580
fi
7681
}
7782

83+
function buildApimlCommonPackage {
84+
buildPackage "apiml-common-lib-package" "packageCommonLib -x gateway-service:test -x discovery-service:test -x api-catalog-services:test -x api-catalog-ui:test -x api-catalog-ui:npmLint"
85+
}
86+
7887
function preparePackage {
7988
service_package=$1
8089
subdirectory=$2

metrics-service-ui/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ node {
2020
nodeProjectDir = file("${project.projectDir}/frontend")
2121
}
2222

23+
if (project.hasProperty('omitDevDependencies')) {
24+
npmInstall.args = ['--production', '--omit=dev'] // different args for different npm versions
25+
}
26+
2327
// =================================================
2428
//
2529
// Please manage all task dependencies in here and

0 commit comments

Comments
 (0)