Skip to content

Commit

Permalink
Allow to use build script located in repository
Browse files Browse the repository at this point in the history
Closes #536.
  • Loading branch information
michaelsauter committed Jun 9, 2022
1 parent 64d33f0 commit ef7e8ac
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ listed in the changelog.
### Added

- Automatically build images after Helm upgrade ([#525](https://github.com/opendevstack/ods-pipeline/issues/525))
- Allow to use build script located in repository ([#536](https://github.com/opendevstack/ods-pipeline/issues/536))

### Changed

Expand Down
1 change: 1 addition & 0 deletions build/package/scripts/copy-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ tmp_artifacts_dir="${ROOT_DIR}/.ods/tmp-artifacts"

# Copying ods artifacts which are mostly reports (see artifacts.adoc)
echo "Copying build artifacts from $tmp_artifacts_dir to $ods_artifacts_dir"
mkdir -p "$tmp_artifacts_dir"
mkdir -p "$ods_artifacts_dir"
"$CP" -v -r "$tmp_artifacts_dir/." "$ods_artifacts_dir"
13 changes: 11 additions & 2 deletions deploy/ods-pipeline/charts/tasks/templates/task-ods-build-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ spec:
For single build repos enabling build caching has limited benefits. For multi build repos enabling this is recommended unless the build is dependant on files outside of the working directory. See ADR caching-build-tasks for more details and workarounds.
type: string
default: "false"
- name: build-script
description: >-
Build script to execute. The
link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-go.sh[default script]
is located in the container image. If you specify a relative path
instead, it will be resolved from the workspace. See the task definition
for details how the build script is invoked.
type: string
default: "/usr/local/bin/build-go"
- name: pre-test-script
description: Script to execute before running tests, relative to the working directory.
type: string
Expand Down Expand Up @@ -128,9 +137,9 @@ spec:
--debug=${DEBUG} ; then
exit 0
fi
# build-go is build/package/scripts/build-go.sh.
# Default build script is build/package/scripts/build-go.sh.
set +e
build-go \
$(params.build-script) \
--working-dir=$(params.working-dir) \
--enable-cgo=$(params.enable-cgo) \
--go-os=$(params.go-os) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ spec:
This directory may then later be used as Docker context for example.
type: string
default: docker
- name: build-script
description: >-
Build script to execute. The
link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-gradle.sh[default script]
is located in the container image. If you specify a relative path
instead, it will be resolved from the workspace. See the task definition
for details how the build script is invoked.
type: string
default: "/usr/local/bin/build-gradle"
- name: sonar-quality-gate
description: Whether the SonarQube quality gate needs to pass for the task to succeed.
type: string
Expand Down Expand Up @@ -182,8 +191,8 @@ spec:
resources:
{{- (.Values.gradle).resources | default dict | toYaml | nindent 8 }}
script: |
# build-gradle is build/package/scripts/build-gradle.sh.
build-gradle \
# Default build script is build/package/scripts/build-gradle.sh.
$(params.build-script) \
--working-dir=$(params.working-dir) \
--output-dir=$(params.output-dir) \
--gradle-additional-tasks="$(params.gradle-additional-tasks)" \
Expand Down
13 changes: 11 additions & 2 deletions deploy/ods-pipeline/charts/tasks/templates/task-ods-build-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ spec:
For single build repos enabling build caching has limited benefits. For multi build repos enabling this is recommended unless the build is dependant on files outside of the working directory. See ADR caching-build-tasks for more details and workarounds.
type: string
default: "false"
- name: build-script
description: >-
Build script to execute. The
link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-npm.sh[default script]
is located in the container image. If you specify a relative path
instead, it will be resolved from the workspace. See the task definition
for details how the build script is invoked.
type: string
default: "/usr/local/bin/build-npm"
- name: sonar-quality-gate
description: Whether quality gate needs to pass.
type: string
Expand Down Expand Up @@ -152,9 +161,9 @@ spec:
--debug=${DEBUG} ; then
exit 0
fi
# build-npm is build/package/scripts/build-npm.sh.
# Default build script is build/package/scripts/build-npm.sh.
set +e
build-npm \
$(params.build-script) \
--working-dir=$(params.working-dir) \
--output-dir=$(params.output-dir) \
--debug=${DEBUG} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ spec:
description: Script to execute before running tests, relative to the working directory.
type: string
default: ""
- name: build-script
description: >-
Build script to execute. The
link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-python.sh[default script]
is located in the container image. If you specify a relative path
instead, it will be resolved from the workspace. See the task definition
for details how the build script is invoked.
type: string
default: "/usr/local/bin/build-python"
- name: sonar-quality-gate
description: Whether quality gate needs to pass.
type: string
Expand Down Expand Up @@ -122,9 +131,9 @@ spec:
--debug=${DEBUG} ; then
exit 0
fi
# build-python is build/package/scripts/build-python.sh.
# Default build script is build/package/scripts/build-python.sh.
set +e
build-python \
$(params.build-script) \
--working-dir=$(params.working-dir) \
--max-line-length=$(params.max-line-length) \
--pre-test-script=$(params.pre-test-script) \
Expand Down
7 changes: 6 additions & 1 deletion docs/design/software-design-specification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Input parameters:
* `go-arch`: sets target architecture (`GOARCH`)
* `output-dir`: sets destination directory of built binary
* `pre-test-script`: specifies script to run prior to tests
* `build-script`: specifies path to build script
* `sonar-quality-gate`: enables quality gate check
* `sonar-skip`: skips SonarQube analysis
* `cache-build`: if 'true' build skipping is enabled.
Expand Down Expand Up @@ -167,6 +168,7 @@ Input parameters:
* `gradle-additional-tasks`: additional gradle tasks to be passed to the gradle build
* `gradle-options`: options to be passed to the gradle build
* `output-dir`: sets destination directory of built binary
* `build-script`: specifies path to build script
* `sonar-quality-gate`: enables quality gate check
* `sonar-skip`: skips SonarQube analysis

Expand Down Expand Up @@ -268,7 +270,9 @@ a| The task defines two steps:
This step supports build skipping (executing SDS-SHARED-5 and/or SDS-SHARED-4 if enabled with parameter `cache-build`)
. Analyze source code (referencing SDS-SHARED-1 and executing SDS-SHARED-2)

Input parameters: TODO
Input parameters:

* `build-script`: specifies path to build script

| SDS-TASK-14
| `ods-python-toolset` container image
Expand Down Expand Up @@ -311,6 +315,7 @@ Input parameters:
* `copy-node-modules`: enables copying node_modules directory to the output directory
* `max-lint-warnings`: maximum of allowed linting warnings after which eslint will exit with an error
* `lint-file-ext`: file extensions to lint
* `build-script`: specifies path to build script
* `sonar-quality-gate`: enables quality gate check
* `sonar-skip`: skips SonarQube analysis
* `cache-build`: if 'true' build skipping is enabled.
Expand Down
15 changes: 15 additions & 0 deletions docs/design/software-requirements-specification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ a| The task shall build a Go module based Go binary.
| SRS-TASK-BUILD-GO-7
| See SRS-TASK-SHARED-3.

| SRS-TASK-BUILD-GO-8
| See SRS-TASK-SHARED-4.

|===

==== Task `ods-build-gradle`
Expand All @@ -191,6 +194,9 @@ a| The task shall run tests, creating code coverage and xUnit report.
| SRS-TASK-BUILD-GRADLE-4
| See SRS-TASK-SHARED-2.

| SRS-TASK-BUILD-GRADLE-5
| See SRS-TASK-SHARED-4.

|===

==== Task `ods-build-python`
Expand Down Expand Up @@ -220,6 +226,9 @@ a| The task shall build a Python application.
| SRS-TASK-BUILD-PYTHON-6
| See SRS-TASK-SHARED-3.

| SRS-TASK-BUILD-PYTHON-7
| See SRS-TASK-SHARED-4.

|===

==== Task `ods-build-npm`
Expand Down Expand Up @@ -248,6 +257,9 @@ a| The task shall build a Node.JS application using npm.
| SRS-TASK-BUILD-NPM-6
| See SRS-TASK-SHARED-3.

| SRS-TASK-BUILD-NPM-7
| See SRS-TASK-SHARED-4.

|===


Expand Down Expand Up @@ -316,6 +328,9 @@ a| The task shall be able to run in a subdirectory of the checked out repository
| SRS-TASK-SHARED-3
a| The task shall be able to optionally use a build output and report cache so that future execution of build scripts can be skipped if the subdirectory of the checked out repository did not change.

| SRS-TASK-SHARED-4
a| The task shall be configurable to use a build script located in the workspace instead of the built-in build script.

|===

=== Aritfact Download Requirements
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks/ods-build-go.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ without leading `./` and trailing `/`.
| If enabled tasks uses or populates cache with the output dir contents (and artifacts) so that a build can be skipped if the `working-dir` contents did not change. For single build repos enabling build caching has limited benefits. For multi build repos enabling this is recommended unless the build is dependant on files outside of the working directory. See ADR caching-build-tasks for more details and workarounds.


| build-script
| /usr/local/bin/build-go
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-go.sh[default script] is located in the container image. If you specify a relative path instead, it will be resolved from the workspace. See the task definition for details how the build script is invoked.


| pre-test-script
|
| Script to execute before running tests, relative to the working directory.
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks/ods-build-gradle.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ without leading `./` and trailing `/`.
| Path to the directory into which the resulting Java application jar should be copied, relative to `working-dir`. This directory may then later be used as Docker context for example.


| build-script
| /usr/local/bin/build-gradle
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-gradle.sh[default script] is located in the container image. If you specify a relative path instead, it will be resolved from the workspace. See the task definition for details how the build script is invoked.


| sonar-quality-gate
| false
| Whether the SonarQube quality gate needs to pass for the task to succeed.
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks/ods-build-npm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ without leading `./` and trailing `/`.
| If enabled tasks uses or populates cache with the output dir contents (and artifacts) so that a build can be skipped if the `working-dir` contents did not change. For single build repos enabling build caching has limited benefits. For multi build repos enabling this is recommended unless the build is dependant on files outside of the working directory. See ADR caching-build-tasks for more details and workarounds.


| build-script
| /usr/local/bin/build-npm
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-npm.sh[default script] is located in the container image. If you specify a relative path instead, it will be resolved from the workspace. See the task definition for details how the build script is invoked.


| sonar-quality-gate
| false
| Whether quality gate needs to pass.
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks/ods-build-python.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ without leading `./` and trailing `/`.
| Script to execute before running tests, relative to the working directory.


| build-script
| /usr/local/bin/build-python
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline/blob/master/build/package/scripts/build-python.sh[default script] is located in the container image. If you specify a relative path instead, it will be resolved from the workspace. See the task definition for details how the build script is invoked.


| sonar-quality-gate
| false
| Whether quality gate needs to pass.
Expand Down

0 comments on commit ef7e8ac

Please sign in to comment.