Skip to content

Commit

Permalink
Run make docs
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsauter committed Nov 10, 2023
1 parent 014e5e9 commit 7aa7ad6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 130 deletions.
57 changes: 14 additions & 43 deletions docs/build.adoc
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
// File is generated; DO NOT EDIT.

= ods-pipeline-npm-build
= ods-pipeline-python-build

Builds Node.js applications using npm.

The built-in script executes the following steps:

- check that package.json and package-lock.json exist to require best practice of using lock files. See also link:https://github.com/opendevstack/ods-pipeline/discussions/411[discussion 411]
- linting using `npm run lint`
- build application, using `npm run build`
- test execution, using `npm run test`

For linting to work there needs to be a `lint` task in the `package.json` file,
for example `npx eslint src --format compact`, together with a config file
(`eslintrc.json` or similar) at the root of the working directory. This can
be done by running `eslint --init` or by following the
link:https://eslint.org/docs/user-guide/getting-started[official documentation].
Builds Python applications.

The exact build recipe can be found at
link:https://github.com/opendevstack/ods-pipeline-npm/blob/main/build/images/scripts/build.sh[build/images/scripts/build.sh].
In particular, `npm run build` is expected to place outputs into `dist` and
`npm run test` is expected to create `build/test-results/test/report.xml`
and `build/coverage/{clover.xml,coverage-final.json,lcov.info}`.
link:https://github.com/opendevstack/ods-pipeline-python/blob/main/build/images/scripts/build.sh[build/images/scripts/build.sh].

An example configuration for the test script is:

```
JEST_JUNIT_OUTPUT_DIR='build/test-results/test' JEST_JUNIT_OUTPUT_NAME='report.xml' npx jest --reporters=default --reporters=jest-junit --coverage --coverageDirectory=build/coverage --forceExit ./dist
```
In particular, the Python source files are expected to be located in `src`.

The following artifacts are generated by the build task and placed into `.ods/artifacts/`

* `code-coverage/`
** `clover.xml`
** `coverage-final.json`
** `lcov.info`
* `lint-reports`
** `report.txt`
** `coverage.xml`
* `xunit-reports/`
** `report.xml`

Expand Down Expand Up @@ -67,24 +43,19 @@ 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. You must set this to `"false"` if the build can be affected by files outside `working-dir`. See ADR caching-build-tasks for more details and workarounds.


| build-extra-inputs
|
| List of build source directories (as colon separated string) which in addition working-dir influence the build. These directories are relative to the repository root. If the contents in these directories change the cache is invalidated so that the build task will rebuild from scratch.

| build-script
| /usr/local/bin/build-python
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline-python/blob/main/build/images/scripts/build.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.

| cached-outputs
| dist
| List of build output directories (as colon separated string) to be cached. These directories are relative to the `working-dir` parameter` Common build directories are `dist` (default), `build` and `public`. If empty this could mean that the original sources are being used as build output and no caching of built files are needed. Nonetheless build skipping can still be remain enabled.

| max-line-length
| 120
| Maximum line length.

| build-script
| /usr/local/bin/build-npm
| Build script to execute. The link:https://github.com/opendevstack/ods-pipeline-npm/blob/main/build/images/scripts/build.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.


| node-version
| 18
| Node.js version to use - supported version: 18
| pre-test-script
|
| Script to execute before running tests, relative to the working directory.

|===

Expand Down
111 changes: 24 additions & 87 deletions tasks/build.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,52 @@
# File is generated; DO NOT EDIT.

# Source: tasks/templates/task-ods-build-python.yaml
apiVersion: tekton.dev/v1
kind: 'Task'
kind: Task
metadata:
name: 'ods-build-python'
annotations:
"helm.sh/resource-policy": keep
name: ods-pipeline-python-build
spec:
description: |
Builds Python applications.
Builds python applications.
See https://github.com/opendevstack/ods-pipeline/blob/v0.13.2/docs/tasks/ods-build-python.adoc
See https://github.com/opendevstack/ods-pipeline-python/blob/vlatest/docs/build.adoc
params:
- name: working-dir
description: |
Working directory. The path must be relative to the root of the repository,
without leading `./` and trailing `/`.
type: string
default: "."
- name: output-dir
description: >-
Path to the directory into which outputs should be placed, relative to `working-dir`.
This directory may then later be used as Docker context for example.
type: string
default: docker
- name: cache-build
description: >-
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.
You must set this to `"false"` if the build can be affected by files outside `working-dir`. See ADR caching-build-tasks for more details and workarounds.
type: string
default: "true"
- name: max-line-length
description: Maximum line length.
type: string
default: "120"
- name: pre-test-script
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]
link:https://github.com/opendevstack/ods-pipeline-python/blob/main/build/images/scripts/build.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: max-line-length
description: Maximum line length.
type: string
default: "120"
- name: pre-test-script
description: Script to execute before running tests, relative to the working directory.
type: string
default: ""
results:
- description: The cache location that the build task used. If caching is not enabled this will be an empty string.
name: build-reused-from-location
steps:
- name: build-python
# Image is built from build/package/Dockerfile.python-toolset.
image: 'ghcr.io/opendevstack/ods-pipeline/ods-python-toolset:0.13.2'
# Image is built from build/images/Dockerfile.python-toolset.
image: 'ghcr.io/opendevstack/ods-pipeline-python/python-toolset:latest'
env:
- name: HOME
value: '/tekton/home'
Expand Down Expand Up @@ -83,90 +75,35 @@ spec:
resources:
{}
script: |
supply-sonar-project-properties-default --working-dir=$(params.working-dir)
echo -n "" > $(results.build-reused-from-location.path)
cache_build_key=python
if copy-build-if-cached \
--cache-build=$(params.cache-build) \
--cache-build-key="$cache_build_key" \
--build-extra-inputs=$(params.build-extra-inputs) \
--cache-location-used-path=$(results.build-reused-from-location.path) \
--working-dir=$(params.working-dir) \
--output-dir=$(params.output-dir) \
--debug=${DEBUG} ; then
exit 0
fi
# Default build script is build/package/scripts/build-python.sh.
set +e
$(params.build-script) \
--working-dir=$(params.working-dir) \
--max-line-length=$(params.max-line-length) \
--pre-test-script=$(params.pre-test-script) \
--output-dir=$(params.output-dir) \
--debug=${DEBUG}
build_exit=$?
set -e
copy-artifacts --debug=${DEBUG}
if [ $build_exit -ne 0 ]; then
exit $build_exit
fi
if [ "$(params.cache-build)" == "true" ]; then
cache-build \
--cache-build-key="$cache_build_key" \
--cache-location-used-path=$(results.build-reused-from-location.path) \
--working-dir=$(params.working-dir) \
--output-dir=$(params.output-dir) \
--debug=${DEBUG}
fi
volumeMounts:
- mountPath: /etc/ssl/certs/private-cert.pem
name: private-cert
readOnly: true
subPath: tls.crt
workingDir: $(workspaces.source.path)
- name: scan-with-sonar
# Image is built from build/package/Dockerfile.sonar.
image: 'ghcr.io/opendevstack/ods-pipeline/ods-sonar:0.13.2'
env:
- name: HOME
value: '/tekton/home'
- name: SONAR_URL
valueFrom:
configMapKeyRef:
key: url
name: ods-sonar
- name: SONAR_EDITION
valueFrom:
configMapKeyRef:
key: edition
name: ods-sonar
- name: SONAR_AUTH_TOKEN
valueFrom:
secretKeyRef:
key: password
name: ods-sonar-auth
- name: DEBUG
valueFrom:
configMapKeyRef:
key: debug
name: ods-pipeline
resources: {}
script: |
if [ "$(params.sonar-skip)" = "true" ]; then
echo "Skipping SonarQube analysis"
else
mkdir -p .ods/artifacts/sonarqube-analysis
truststore="${JAVA_HOME}/lib/security/cacerts"
if [ -f /etc/ssl/certs/private-cert.pem ]; then
truststore="$(pwd)/.ods-cache/truststore/cacerts"
configure-truststore --dest-store "${truststore}"
fi
# sonar is built from cmd/sonar/main.go.
sonar \
-working-dir=$(params.working-dir) \
-quality-gate=$(params.sonar-quality-gate) \
-truststore "${truststore}"
fi
cache-build \
--cache-build=$(params.cache-build) \
--cache-build-key="$cache_build_key" \
--build-extra-inputs=$(params.build-extra-inputs) \
--cache-location-used-path=$(results.build-reused-from-location.path) \
--working-dir=$(params.working-dir) \
--debug=${DEBUG}
volumeMounts:
- mountPath: /etc/ssl/certs/private-cert.pem
name: private-cert
Expand Down

0 comments on commit 7aa7ad6

Please sign in to comment.