Skip to content

Commit 57a089f

Browse files
author
Lucas Yoon
committed
adding renovate and supporting test scripts
1 parent a173e94 commit 57a089f

File tree

17 files changed

+3518
-0
lines changed

17 files changed

+3518
-0
lines changed

.github/validate-stacks.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#
2+
# Copyright 2021-2022 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Validate stacks
17+
18+
on:
19+
push:
20+
branches: [main]
21+
pull_request:
22+
branches: [main]
23+
schedule:
24+
- cron: 0 5 * * *
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
28+
cancel-in-progress: true
29+
30+
env:
31+
MINIKUBE_VERSION: "v1.29.0"
32+
MINIKUBE_RESOURCES: "--memory 14gb --cpus 4"
33+
KUBERNETES_VERSION: "v1.25.2"
34+
TEST_DELTA: false
35+
36+
jobs:
37+
validate-devfile-schema:
38+
name: validate devfile schemas
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Install Go
47+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
48+
with:
49+
go-version: "1.23"
50+
51+
- name: Install Ginkgo
52+
run: go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.13.0
53+
54+
- name: Test delta if on a pull request
55+
if: ${{ github.event_name == 'pull_request' }}
56+
run: echo "TEST_DELTA=true" >> $GITHUB_ENV
57+
58+
- name: Validate stacks
59+
run: bash tests/validate_devfile_schemas.sh
60+
61+
non-terminating:
62+
name: check for non-terminating images
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Setup Minikube
71+
uses: manusa/actions-setup-minikube@0e8062ceff873bd77979f39cf8fd3621416afe4d # v2.13.0
72+
with:
73+
minikube version: ${{ env.MINIKUBE_VERSION }}
74+
kubernetes version: ${{ env.KUBERNETES_VERSION }}
75+
driver: "docker"
76+
github token: ${{ secrets.GITHUB_TOKEN }}
77+
start args: "--addons=ingress ${{ env.MINIKUBE_RESOURCES }}"
78+
79+
- name: Test delta if on a pull request
80+
if: ${{ github.event_name == 'pull_request' }}
81+
run: echo "TEST_DELTA=true" >> $GITHUB_ENV
82+
83+
- name: Check that containers components are non terminating
84+
run: |
85+
go build -C tests/check_non_terminating -o flatten-parent
86+
bash tests/check_non_terminating.sh
87+
88+
odov3:
89+
name: with odo v3
90+
runs-on: ubuntu-latest
91+
needs: [odov2, non-terminating, validate-devfile-schema]
92+
if: success() || failure()
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96+
with:
97+
fetch-depth: 0
98+
99+
- name: Free Disk Space
100+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be #v1.3.1
101+
with:
102+
tool-cache: false
103+
android: true
104+
dotnet: true
105+
haskell: true
106+
large-packages: true
107+
docker-images: true
108+
swap-storage: true
109+
110+
- name: Setup Minikube
111+
uses: manusa/actions-setup-minikube@0e8062ceff873bd77979f39cf8fd3621416afe4d # v2.13.0
112+
with:
113+
minikube version: ${{ env.MINIKUBE_VERSION }}
114+
kubernetes version: ${{ env.KUBERNETES_VERSION }}
115+
driver: "docker"
116+
github token: ${{ secrets.GITHUB_TOKEN }}
117+
start args: "--addons=ingress ${{ env.MINIKUBE_RESOURCES }}"
118+
119+
- name: Install Go
120+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
121+
with:
122+
go-version: "1.23"
123+
124+
- name: Install odo latest version v3
125+
uses: redhat-actions/openshift-tools-installer@2de9a80cf012ad0601021515481d433b91ef8fd5 # v1
126+
with:
127+
odo: "3.16.1"
128+
129+
- name: Install Ginkgo
130+
run: go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.13.0
131+
132+
- name: Check odo version
133+
run: odo version
134+
135+
- name: Test delta if on a pull request
136+
if: ${{ github.event_name == 'pull_request' }}
137+
run: echo "TEST_DELTA=true" >> $GITHUB_ENV
138+
139+
- name: Check the devfile stacks with odo v3
140+
run: bash tests/check_odov3.sh

renovate.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base",
5+
"helpers:pinGitHubActionDigests",
6+
":gitSignOff"
7+
],
8+
"timezone": "America/Toronto",
9+
"schedule": ["on the 2nd and 4th day instance on thursday after 9pm"],
10+
"enabledManagers": ["regex", "github-actions"],
11+
"regexManagers": [
12+
{
13+
"fileMatch": [
14+
"devfile.*y[a]?ml$"
15+
],
16+
"matchStrings": [
17+
"image: (?<depName>\\S*):(?<currentValue>\\S*)"
18+
],
19+
"datasourceTemplate": "docker",
20+
"depNameTemplate": "{{{depName}}}"
21+
}
22+
],
23+
"packageRules": [
24+
{
25+
"matchManagers": ["github-actions"],
26+
"groupName": "github actions",
27+
"groupSlug": "github-actions",
28+
"commitMessageTopic": "{{depName}}"
29+
}
30+
],
31+
"prHourlyLimit": 20,
32+
"prConcurrentLimit": 1
33+
}

tests/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Devfile Registry Testing
2+
3+
- This tests directory has been adapted from https://github.com/devfile/registry/blob/08d595c2ae447332ec5e3fb49209d63a2a5cd6a4/tests/README.md while setting up renovate[https://docs.renovatebot.com/] automation on devfile-samples organization.
4+
5+
## Dependency check
6+
7+
### Prerequisites
8+
9+
- Ensure [yq 4.x](https://github.com/mikefarah/yq/#install) is installed
10+
11+
### Running the build script
12+
13+
- This script performs three actions
14+
- Clones samples from provided `extraDevfileEntries.yaml` under `samples/.cache`
15+
- Creates a `parents.yaml` which contains the dependency tree for parent stacks
16+
- Outputs the child sample paths of parent stacks, `TEST_DELTA=true` will result in only outputting child samples which have changed parent stacks
17+
- The build script takes one optional argument and works off of the current working directory
18+
- `bash tests/build_parents_file.sh`, default samples file is `extraDevfileEntries.yaml`
19+
- `bash tests/build_parents_file.sh <path_to_extraDevfileEntries>`
20+
21+
### Use with testing
22+
23+
- One can test the child samples using the [validate_devfile_schemas](./validate_devfile_schemas/) test suite by performing the following:
24+
```sh
25+
export STACKS=$(bash tests/build_parents_file.sh)
26+
STACKS_DIR=.cache/samples bash tests/validate_devfile_schemas.sh --samples
27+
```
28+
29+
## Validating non-terminating images
30+
31+
### Prerequisites
32+
33+
- Minikube installed, and running.
34+
- `minikube start --memory 8gb` is a good starting point.
35+
- The `none` driver **cannot** be used. Any other driver (`docker`, `hyperkit`, etc) should suffice.
36+
37+
### Running the tests
38+
39+
1) From the root of this repository, run `bash tests/check_non_terminating.sh`.
40+
- The test script will validate each devfile stack under `stacks/`, verifying that the components of type container are terminating.
41+
- The test script retrieves the `image`, `command` and `args` of a container component and uses them to run a pod and wait until it reaches the `Running` state:
42+
```bash
43+
kubectl run test-terminating -n default --attach=false --restart=Never --image="<image>" --command=true -- "<command>" "<args>"
44+
```
45+
- Each container component **must** be non-terminating. If the default `image` entrypoint is terminating an `args` (preferred) or `command` should be specified in the defile (e.g. `["tail", "-f", "/dev/null"]`).
46+
47+
48+
## With odo v3
49+
50+
### Prerequisites
51+
52+
- Minikube or CRC installed, and running.
53+
- CRC should work with default settings.
54+
- Minikube
55+
- `minikube start --memory 8gb` is a good starting point.
56+
- The `none` driver **cannot** be used. Any other driver (`docker`, `hyperkit`, etc) should suffice.
57+
- odo v3.0.0-rc2 or later.
58+
- Go 1.21 or later installed
59+
- `$GOPATH/bin` should be in your `$PATH` or you will have to modify `check_with_odov3.sh` to find `ginkgo` binary.
60+
- Ginkgo CLI installed (`go install github.com/onsi/ginkgo/v2/ginkgo@latest`)
61+
62+
63+
### Running the tests
64+
65+
1) Ensure minikube is running and `minikube ip` reports a valid IP address
66+
2) From the root of this repository, run `bash tests/check_odov3.sh`.
67+
- The test script will validate that every devfile under `stacks` directory works with all the starter projects defined in a given stack.
68+
69+
### Limitations
70+
71+
- Currently, the test expects that all starter projects are web applications that return `HTTP 200` status code on the root path (`/`).
72+
73+
### Running the tests
74+
75+
1) Ensure minikube is running and `minikube ip` reports a valid ip address
76+
77+
2) From the root of this repository, run `bash tests/check_odov2.sh`.
78+
79+
- The test script will validate each devfile stack under `stacks/` with odo, verifying that the stack can be used to build a starter project and that the application is properly built and exposed.
80+
- The test script checks for an HTTP 200 status code to determine "properly exposed".
81+
- Each devfile stack **must** have at least one starter project specified in the devfile.yaml
82+
83+
### Limitations
84+
85+
- If there are multiple starter projects, odo will only use the first starter project mentioned.
86+
- Only `odo create`, `odo url create`, and `odo push` are tested right now. If your devfile stack exposes additional functionality (such as debug, via `odo debug`), we recommend either manually testing that functionality, or setting up your own test scripts in the stack's repository

0 commit comments

Comments
 (0)