Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 7a8f50c

Browse files
author
Michael Sauter
authored
Merge pull request #722 from opendevstack/feature/pkg-test
Refactor to ease development of tasks in external Git repositories
2 parents 6db04a4 + c975e53 commit 7a8f50c

File tree

213 files changed

+2749
-13223
lines changed

Some content is hidden

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

213 files changed

+2749
-13223
lines changed

.github/workflows/check-docs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
set -eu
33

44
make docs
5-
if ! git diff --quiet docs tasks; then
6-
echo "Docs / tasks are not up-to-date! Run 'make docs' to update."
5+
if ! git diff --quiet docs; then
6+
echo "Docs are not up-to-date! Run 'make docs' to update."
77
exit 1
88
else
9-
echo "Docs /tasks are up-to-date."
9+
echo "Docs are up-to-date."
1010
fi

.github/workflows/main.yaml

Lines changed: 24 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -11,139 +11,44 @@ env:
1111
IMAGE_BASE: ${{ github.repository }}
1212

1313
jobs:
14-
build-images:
15-
name: Build ODS images
16-
runs-on: ubuntu-latest
17-
strategy:
18-
fail-fast: true
19-
matrix:
20-
image: ["aqua-scan", "finish", "go-toolset", "gradle-toolset", "helm", "node16-npm-toolset", "node18-npm-toolset", "package-image", "pipeline-manager", "python-toolset", "sonar", "start"]
21-
steps:
22-
-
23-
name: Checkout
24-
uses: actions/checkout@v3
25-
with:
26-
fetch-depth: 0
27-
-
28-
name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@v2
30-
with:
31-
driver-opts: |
32-
image=moby/buildkit:master
33-
network=host
34-
-
35-
name: Build image
36-
uses: docker/build-push-action@v3
37-
with:
38-
context: .
39-
push: false
40-
file: build/package/Dockerfile.${{ matrix.image }}
41-
tags: localhost:5000/ods/ods-${{ matrix.image }}:latest
42-
outputs: type=docker,dest=/tmp/image-ods-${{ matrix.image }}.tar
43-
-
44-
name: Upload artifacts
45-
uses: actions/upload-artifact@v3
46-
with:
47-
name: buildx-image-ods-${{ matrix.image }}
48-
path: /tmp/image-ods-${{ matrix.image }}.tar
49-
retention-days: 1
50-
5114
pipeline-tests:
5215
name: Tests
5316
runs-on: ubuntu-latest
54-
needs: build-images
55-
env:
56-
IMAGES: aqua-scan finish go-toolset gradle-toolset helm node16-npm-toolset node18-npm-toolset package-image pipeline-manager python-toolset sonar start
5717
steps:
58-
-
59-
name: Download image artifacts
60-
uses: actions/download-artifact@v3
61-
with:
62-
path: /tmp
6318
-
6419
name: Checkout
6520
uses: actions/checkout@v3
6621
with:
6722
fetch-depth: 0
6823
-
69-
name: Setup KinD cluster with internal registry
70-
working-directory: scripts
71-
run: ./kind-with-registry.sh
72-
-
73-
name: Push images to local registry
74-
run: |
75-
images=(${{ env.IMAGES }})
76-
for image in ${images[*]}
77-
do
78-
echo "::group::Push ods-$image to local registry"
79-
docker load --input /tmp/buildx-image-ods-$image/image-ods-$image.tar
80-
docker push localhost:5000/ods/ods-$image:latest
81-
if [[ "${{ github.event_name }}" == 'pull_request' ]]
82-
then
83-
docker rmi localhost:5000/ods/ods-$image:latest
84-
fi
85-
echo "::endgroup::"
86-
done
87-
-
88-
name: Delete image tarballs
89-
run: |
90-
rm -rf /tmp/buildx-image-*
91-
-
92-
name: Setup kubectl
93-
uses: azure/setup-kubectl@v3
94-
id: install
95-
-
96-
name: Install Tekton Core Components
97-
run: make install-tekton-pipelines
98-
-
99-
name: Show disk space
100-
run: df -h
101-
-
102-
name: Spin up Bitbucket container
103-
run: make run-bitbucket
104-
-
105-
name: Spin up Nexus container
106-
run: make run-nexus
107-
-
108-
name: Spin up SonarQube container
109-
run: make run-sonarqube
110-
-
111-
name: Show disk space
112-
run: df -h
113-
-
114-
name: Setup Go 1.19
115-
uses: actions/setup-go@v3
24+
name: Setup Go
25+
uses: actions/setup-go@v4
11626
with:
117-
go-version: '1.19'
27+
go-version: '1.21'
11828
-
11929
name: Check if docs are up-to-date
12030
run: ./.github/workflows/check-docs.sh
12131
-
12232
name: Run tests
12333
run: |
124-
set -o pipefail
125-
go test -v ./cmd/... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
126-
go test -v ./internal/... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
127-
go test -v ./pkg/... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
128-
go test -timeout 45m -v ./test/tasks/... -always-keep-tmp-workspaces | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
129-
go test -timeout 10m -v ./test/e2e/... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
130-
-
131-
name: Log into ghcr.io
132-
if: ${{ github.event_name != 'pull_request' }}
133-
uses: docker/login-action@v1
134-
with:
135-
registry: ghcr.io
136-
username: ${{ github.actor }}
137-
password: ${{ secrets.GITHUB_TOKEN }}
138-
-
139-
name: Push images to ghcr.io
140-
if: ${{ github.event_name != 'pull_request' }}
141-
run: |
142-
images=(${{ env.IMAGES }})
143-
for image in ${images[*]}
144-
do
145-
echo "::group::Push ods-$image to ghcr.io"
146-
docker tag localhost:5000/ods/ods-$image:latest ghcr.io/${{ env.IMAGE_BASE }}/ods-$image:latest
147-
docker push ghcr.io/${{ env.IMAGE_BASE }}/ods-$image:latest
148-
echo "::endgroup::"
149-
done
34+
make test
35+
# -
36+
# name: Log into ghcr.io
37+
# if: ${{ github.event_name != 'pull_request' }}
38+
# uses: docker/login-action@v1
39+
# with:
40+
# registry: ghcr.io
41+
# username: ${{ github.actor }}
42+
# password: ${{ secrets.GITHUB_TOKEN }}
43+
# -
44+
# name: Push images to ghcr.io
45+
# if: ${{ github.event_name != 'pull_request' }}
46+
# run: |
47+
# images=(${{ env.IMAGES }})
48+
# for image in ${images[*]}
49+
# do
50+
# echo "::group::Push ods-$image to ghcr.io"
51+
# docker tag localhost:5000/ods/ods-$image:latest ghcr.io/${{ env.IMAGE_BASE }}/ods-$image:latest
52+
# docker push ghcr.io/${{ env.IMAGE_BASE }}/ods-$image:latest
53+
# echo "::endgroup::"
54+
# done

CHANGELOG.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ listed in the changelog.
1313
### Fixed
1414

1515
- ods.yaml branch trigger patterns must be lowercase ([#713](https://github.com/opendevstack/ods-pipeline/issues/713))
16-
- Go module name was incorrectly set to `github.com/opendevstack/pipeline`
17-
18-
- sonar-scanner invocations stderr not captured ([#719](https://github.com/opendevstack/ods-pipeline/issues/719))
19-
20-
- sonar-scanner does not start properly: java is lacking tzdb.dat ([#723](https://github.com/opendevstack/ods-pipeline/issues/723))
2116

22-
- update sonar-scanner and cnes-report ([#725](https://github.com/opendevstack/ods-pipeline/issues/725))
23-
24-
- SonarQube doesn't scan FE-related code ([#716](https://github.com/opendevstack/ods-pipeline/issues/716))
17+
- Go module name was incorrectly set to `github.com/opendevstack/pipeline`
2518

2619
### Changed
2720

21+
- Move pipeline tasks to separate repositories. This is a huge change with many implications. Instead of providing build, package and deploy taks as part of the `ods-pipeline` repository, the tasks are no provided by separate repositories, such as `ods-pipeline-go`, `ods-pipeline-sonar`, `ods-pipeline-image`, `ods-pipeline-helm` and so on. The only tasks that are provided by `ods-pipeline` are the start and finish tasks automatically injected into each pipeline. This change allows to have a different lifecycle for each task (or set of tasks). It also benefits maintenance greatly: running the tests for this repository is much faster now (around 10 minutes compared to 35+ minutes earlier). This repository facilitates task creation, maintenance and testing by providing a few Go packages that can be used by task repositories such as `ods-pipeline-helm`. For more information, see [#722](https://github.com/opendevstack/ods-pipeline/pull/722).
22+
2823
- Build tasks streamlining and avoidance of file copies (#678 fixed by [#710](https://github.com/opendevstack/ods-pipeline/pull/710)). This is an incompatible change. Build tasks were adjusted to (mostly) no longer copy build files in a dedicated location. Instead one should adjust the Dockerfile (or other downstream tasks) to directly consume the build outputs from their natural locations. In addition build task skipping now supports parameter `build-extra-inputs`. The package-image task `dockerfile` and `docker-dir` parameters have been changed to assume that the docker context and file are at the repository root. See the PR for further information and the issue for more context.
2924

3025
## [0.13.2] - 2023-07-18

Makefile

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ help: ## Show this help screen.
1515
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
1616
.PHONY: help
1717

18-
check-system: ## Check if system meets prerequisites.
18+
check-system: ## Check if system meets prerequisites for development.
1919
cd scripts && ./check-system.sh
2020
.PHONY: check-system
2121

@@ -36,16 +36,26 @@ lint-shell: ## Run shellcheck.
3636
shellcheck scripts/*.sh build/package/scripts/* deploy/*.sh
3737
.PHONY: lint-shell
3838

39-
##@ Building
40-
41-
tasks: ## Render tasks.
42-
go run cmd/tasks/main.go
43-
.PHONY: tasks
44-
45-
docs: tasks ## Render documentation for tasks.
46-
go run cmd/docs/main.go
39+
docs: ## Render documentation for tasks.
40+
renderedStartTask=$(shell mktemp); \
41+
helm template ods-pipeline deploy/chart --show-only=templates/task-start.yaml > $$renderedStartTask; \
42+
go run github.com/opendevstack/ods-pipeline/cmd/taskdoc \
43+
-task $$renderedStartTask \
44+
-description build/docs/task-start.adoc \
45+
-destination docs/task-start.adoc; \
46+
rm $$renderedStartTask
47+
48+
renderedFinishTask=$(shell mktemp); \
49+
helm template ods-pipeline deploy/chart --show-only=templates/task-finish.yaml > $$renderedFinishTask; \
50+
go run github.com/opendevstack/ods-pipeline/cmd/taskdoc \
51+
-task $$renderedFinishTask \
52+
-description build/docs/task-finish.adoc \
53+
-destination docs/task-finish.adoc; \
54+
rm $$renderedFinishTask
4755
.PHONY: docs
4856

57+
##@ Building
58+
4959
build-artifact-download: build-artifact-download-linux build-artifact-download-darwin-amd64 build-artifact-download-darwin-arm64 build-artifact-download-windows ## Build artifact-download binary for each supported OS/arch.
5060
.PHONY: build-artifact-download
5161

@@ -67,7 +77,7 @@ build-artifact-download-windows: ## Build artifact-download Windows binary.
6777

6878
##@ Testing
6979

70-
test: test-cmd test-internal test-pkg test-tasks test-e2e ## Run complete testsuite.
80+
test: test-cmd test-internal test-pkg test-e2e ## Run complete testsuite.
7181
.PHONY: test
7282

7383
test-cmd: ## Run testsuite of cmd packages.
@@ -82,69 +92,7 @@ test-pkg: ## Run testsuite of public packages.
8292
go test -cover ./pkg/...
8393
.PHONY: test-pkg
8494

85-
test-tasks: ## Run testsuite of Tekton tasks.
86-
go test -v -count=1 -timeout $${ODS_TESTTIMEOUT:-30m} ./test/tasks/...
87-
.PHONY: test-tasks
88-
89-
test-e2e: ## Run testsuite of end-to-end pipeline run.
90-
go test -v -count=1 -timeout $${ODS_TESTTIMEOUT:-10m} ./test/e2e/...
95+
test-e2e: ## Run testsuite of tasks and full pipeline run.
96+
go test -v -count=1 -timeout 20m -skip ^TestPipelineRun ./test/e2e/...
97+
go test -v -count=1 -timeout 10m -run ^TestPipelineRun ./test/e2e/...
9198
.PHONY: test-e2e
92-
93-
clear-tmp-workspaces: ## Clear temporary workspaces created in testruns.
94-
chmod -R u+w test/testdata/workspaces/workspace-*
95-
rm -rf test/testdata/workspaces/workspace-*
96-
.PHONY: clear-tmp-workspaces
97-
98-
##@ KinD (local development environment)
99-
100-
prepare-local-env: create-kind-with-registry build-and-push-images install-tekton-pipelines run-bitbucket run-nexus run-sonarqube ## Prepare local environment from scratch.
101-
.PHONY: prepare-local-env
102-
103-
create-kind-with-registry: ## Create KinD cluster with local registry.
104-
cd scripts && ./kind-with-registry.sh
105-
.PHONY: create-kind-with-registry
106-
107-
install-tekton-pipelines: ## Install Tekton pipelines in KinD cluster.
108-
cd scripts && ./install-tekton-pipelines.sh
109-
.PHONY: install-tekton-pipelines
110-
111-
build-and-push-images: ## Build and push images to local registry.
112-
cd scripts && ./build-and-push-images.sh
113-
.PHONY: build-and-push-images
114-
115-
run-bitbucket: ## Run Bitbucket server (using timebomb license, in "kind" network).
116-
cd scripts && ./run-bitbucket.sh
117-
.PHONY: run-bitbucket
118-
119-
restart-bitbucket: ## Restart Bitbucket server (re-activating timebomb license).
120-
cd scripts && ./restart-bitbucket.sh
121-
.PHONY: restart-bitbucket
122-
123-
run-nexus: ## Run Nexus server (in "kind" network).
124-
cd scripts && ./run-nexus.sh
125-
.PHONY: run-nexus
126-
127-
run-sonarqube: ## Run SonarQube server (in "kind" network).
128-
cd scripts && ./run-sonarqube.sh
129-
.PHONY: run-sonarqube
130-
131-
recreate-kind-cluster: ## Recreate KinD cluster including Tekton tasks.
132-
cd scripts && ./kind-with-registry.sh --recreate
133-
cd scripts && ./install-tekton-pipelines.sh
134-
.PHONY: recreate-kind-cluster
135-
136-
stop-local-env: ## Stop local environment.
137-
cd scripts && ./stop-local-env.sh
138-
.PHONY: stop-local-env
139-
140-
start-local-env: ## Restart stopped local environment.
141-
cd scripts && ./start-local-env.sh
142-
.PHONY: start-local-env
143-
144-
deploy: ## Install ODS pipeline resources in namespace.
145-
ifeq ($(strip $(namespace)),)
146-
@echo "Argument 'namespace' is required, e.g. make deploy namespace=foo-cd"
147-
@exit 1
148-
endif
149-
cd scripts && ./install-inside-kind.sh -n $(namespace)
150-
.PHONY: deploy

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ ODS Pipeline is well suited for regulated development (e.g. medical device softw
2121

2222
### Technical Reference
2323
* [Repository configuration (ods.yaml)](/docs/ods-configuration.adoc)
24-
* Plumbing tasks: [ods-start](/docs/tasks/ods-start.adoc), [ods-finish](/docs/tasks/ods-finish.adoc)
25-
* Build tasks: [ods-build-go](/docs/tasks/ods-build-go.adoc), [ods-build-gradle](/docs/tasks/ods-build-gradle.adoc), [ods-build-npm](/docs/tasks/ods-build-npm.adoc), [ods-build-python](/docs/tasks/ods-build-python.adoc)
26-
* Package tasks: [ods-package-image](/docs/tasks/ods-package-image.adoc)
27-
* Deploy tasks: [ods-deploy-helm](/docs/tasks/ods-deploy-helm.adoc)
24+
* [Start task](/docs/task-start.adoc)
25+
* [Finish task](/docs/task-finish.adoc)
2826

2927
### How-To Guides
3028
* [Working with secrets in Helm](/docs/helm-secrets.adoc)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)