Skip to content

Commit 4595d87

Browse files
Improve reusability of components (#53)
* Split taskfiles by components (#49) * Reusable GitHub action for deploy components (#50) * GitHub Action workflow_dispatch support (#54) * ci(integrations): remove trigger from test CI workflow * Remove embedded helm charts (#57) * ci: run GW test on latest ubuntu * chore: add missing default tasks * fix(integrations): change default dirctl bin path * fix: exclude default task for better autocompletion * fix(integrations): solve var collision & remove hardcoded url * fix(integrations): replace fix path to dirctl bin path * chore(integrations): update readme task commands --------- Signed-off-by: Árpád Csepi <[email protected]> Signed-off-by: Peter Balogh <[email protected]> Co-authored-by: Peter Balogh <[email protected]>
1 parent 89d2e67 commit 4595d87

File tree

26 files changed

+759
-534
lines changed

26 files changed

+759
-534
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
name: Deploy agntcy components
6+
description: Deploy agntcy components for integration testing
7+
inputs:
8+
checkout-repository:
9+
description: 'Checkout AGNTCY repository'
10+
required: false
11+
default: 'false'
12+
checkout-path:
13+
description: 'Path to checkout AGNTCY repository'
14+
required: false
15+
default: ''
16+
deploy-gateway:
17+
description: 'Deploy gateway to a kind cluster'
18+
required: false
19+
default: 'false'
20+
gateway-image-tag:
21+
description: 'Set gateway container image version'
22+
required: false
23+
default: ''
24+
deploy-directory:
25+
description: 'Deploy directory to a kind cluster'
26+
required: false
27+
default: 'false'
28+
directory-image-tag:
29+
description: 'Set directory container image version'
30+
required: false
31+
default: ''
32+
kind-cluster-name:
33+
description: 'Set kind cluster name where components are deployed'
34+
required: false
35+
default: 'agntcy-test'
36+
kind-cluster-namespace:
37+
description: 'Set cluster namespace where components are deployed'
38+
required: false
39+
default: 'default'
40+
github-repository-ref:
41+
description: 'Set a ref for git checkout'
42+
required: false
43+
default: 'main'
44+
install-kind-dependency:
45+
description: 'KinD installer'
46+
required: false
47+
default: 'false'
48+
kind-binary-version:
49+
description: 'Installed KinD version'
50+
required: false
51+
default: 'v0.27.0'
52+
install-taskfile-dependency:
53+
description: 'Taskfile installer'
54+
required: false
55+
default: 'false'
56+
57+
runs:
58+
using: composite
59+
steps:
60+
- name: Checkout agntcy repository
61+
if: ${{ inputs.checkout-repository != 'false' }}
62+
uses: actions/checkout@v4
63+
with:
64+
repository: 'agntcy/csit'
65+
ref: ${{ inputs.github-repository-ref }}
66+
path: ${{ inputs.checkout-path }}
67+
68+
- name: Install KinD
69+
if: ${{ inputs.install-kind-depedency != 'false' }}
70+
shell: bash
71+
run: |
72+
ARCH=""
73+
if [ $(uname -m) = x86_64 ]; then
74+
ARCH="amd64"
75+
elif [ $(uname -m) = aarch64 ]; then
76+
ARCH="arm64"
77+
else
78+
echo "Unkown architecture, abort!"
79+
exit 1
80+
fi
81+
82+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${{ inputs.kind-binary-version }}/kind-linux-$ARCH
83+
84+
chmod +x ./kind
85+
sudo mv ./kind /usr/local/bin/kind
86+
87+
- name: Install Taskfile
88+
if: ${{ inputs.install-taskfile-depedency != 'false' }}
89+
uses: arduino/setup-task@v2
90+
with:
91+
version: 3.x
92+
93+
- name: Create kind cluster
94+
shell: bash
95+
run: |
96+
task -d ./${{ inputs.checkout-path }} integrations:kind:create \
97+
KIND_CLUSTER_NAME=${{ inputs.kind-cluster-name }}
98+
99+
- name: Deploy Gateway
100+
if: ${{ inputs.deploy-gateway != 'false' }}
101+
shell: bash
102+
run: |
103+
task -d ./${{ inputs.checkout-path }} integrations:gateway:test-env:deploy \
104+
GATEWAY_IMAGE_TAG=${{ inputs.gateway-image-tag }} \
105+
KIND_CLUSTER_NAME=${{ inputs.kind-cluster-name }} \
106+
HELM_NAMESPACE=${{ inputs.kind-cluster-namespace }}
107+
108+
- name: Deploy Directory
109+
if: ${{ inputs.deploy-directory != 'false' }}
110+
shell: bash
111+
run: |
112+
task -d ./${{ inputs.checkout-path }} integrations:directory:test-env:deploy \
113+
DIRECTORY_IMAGE_TAG=${{ inputs.directory-image-tag }} \
114+
KIND_CLUSTER_NAME=${{ inputs.kind-cluster-name }} \
115+
HELM_NAMESPACE=${{ inputs.kind-cluster-namespace }}

.github/workflows/test-integrations.yaml

+49-43
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,46 @@
33

44
name: test-integrations
55
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
610
workflow_dispatch:
711
inputs:
8-
destroy-cluster:
9-
description: 'Destroy test cluster'
10-
required: false
11-
default: true
12-
type: boolean
13-
python-version:
14-
description: 'Python version to install'
15-
required: false
16-
default: '3.12'
17-
kind-version:
12+
kind_version:
1813
description: 'Kind version'
1914
required: false
2015
default: '0.24.0'
21-
16+
override_directory_image_tag:
17+
description: 'Directory image tag'
18+
required: false
19+
default: ''
20+
override_gateway_image_tag:
21+
description: 'Gateway image tag'
22+
required: false
23+
default: ''
2224
jobs:
25+
set-kind-version:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
kind-version: ${{steps.set-kind-version.outputs.kind-version }}
29+
steps:
30+
- name: Set KinD version
31+
id: set-kind-version
32+
env:
33+
KIND_VERSION: '0.24.0'
34+
shell: bash
35+
run: |
36+
if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then
37+
KIND_VERSION="${{ inputs.kind_version }}"
38+
fi
39+
40+
echo "Set KinD version to: $KIND_VERSION"
41+
echo "kind-version=$KIND_VERSION" >> "$GITHUB_OUTPUT"
42+
2343
run-tests-gateway:
24-
runs-on: ubuntu-22.04
44+
needs: [ set-kind-version ]
45+
runs-on: ubuntu-latest
2546

2647
permissions:
2748
contents: 'read'
@@ -51,19 +72,13 @@ jobs:
5172
- name: Setup K8S Tools
5273
uses: ./.github/actions/setup-k8s
5374
with:
54-
kind-version: ${{ inputs.kind-version }}
75+
kind-version: ${{ needs.set-kind-version.outputs.kind-version }}
5576

56-
- name: Create kind cluster
57-
run: |
58-
cd integrations
59-
task kind:create
60-
shell: bash
61-
62-
- name: Deploy agntcy agp
63-
run: |
64-
cd integrations
65-
task test:env:gateway:deploy
66-
shell: bash
77+
- name: Deploy Gateway
78+
uses: ./.github/actions/deploy-components
79+
with:
80+
deploy-gateway: 'true'
81+
gateway-image-tag: ${{ inputs.override_gateway_image_tag }}
6782

6883
- name: Run simple gateway tests
6984
env:
@@ -72,12 +87,11 @@ jobs:
7287
AZURE_DEPLOYMENT_NAME: ${{ vars.AZURE_DEPLOYMENT_NAME }}
7388
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
7489
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
75-
run: |
76-
cd integrations
77-
task test:gateway
90+
run: task integrations:gateway:test
7891
shell: bash
7992

8093
run-tests-directory:
94+
needs: [ set-kind-version ]
8195
runs-on: ubuntu-latest
8296

8397
permissions:
@@ -108,22 +122,14 @@ jobs:
108122
- name: Setup K8S Tools
109123
uses: ./.github/actions/setup-k8s
110124
with:
111-
kind-version: ${{ inputs.kind-version }}
125+
kind-version: ${{ needs.set-kind-version.outputs.kind-version }}
112126

113-
- name: Create kind cluster
114-
run: |
115-
cd integrations
116-
task kind:create
117-
shell: bash
118-
119-
- name: Deploy agntcy dir
120-
run: |
121-
cd integrations
122-
task test:env:directory:deploy
123-
shell: bash
127+
- name: Deploy Directory
128+
uses: ./.github/actions/deploy-components
129+
with:
130+
deploy-directory: 'true'
131+
directory-image-tag: ${{ inputs.override_directory_image_tag}}
124132

125-
- name: Run agent build tests
126-
run: |
127-
cd integrations
128-
task test:directory
133+
- name: Run Directory tests
134+
run: task integrations:directory:test
129135
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: test-remote-workflow-dispatch-trigger
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
trigger-integration-workflow:
10+
runs-on: ubuntu-latest
11+
permissions: write-all # TODO: Find the correct permission or create PAT token
12+
steps:
13+
- name: Repository Dispatch
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
await github.rest.actions.createWorkflowDispatch({
18+
owner: 'agntcy',
19+
repo: 'csit',
20+
workflow_id: 'test-integrations.yaml',
21+
ref: 'feat/gh-action-repository-dispatch',
22+
inputs: {
23+
override_gateway_image_tag: '0.3.11',
24+
override_directory_image_tag: 'v0.2.1',
25+
},
26+
});
27+
debug: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: test-reusable-components-action
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
run-tests-gateway:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Environment
18+
uses: ./.github/actions/deploy-components
19+
with:
20+
deploy-gateway: "true"
21+
deploy-directory: "true"
22+
install-kind-dependency: "true"
23+
install-taskfile-dependency: "true"
24+
25+
- name: Check deployments
26+
shell: bash
27+
run: |
28+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
29+
30+
chmod +x kubectl && mv ./kubectl /usr/local/bin
31+
kubectl get deployments

.github/workflows/test-samples.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: ./.github/actions/detect-changes
2828
id: detect-changes
2929
with:
30-
dirs: $(find ./samples \( -name 'pyproject.toml' -o -name 'Taskfile.yaml' \) | xargs -n1 dirname | sort -u)
30+
dirs: $(find ./samples -mindepth 2 \( -name 'pyproject.toml' -o -name 'Taskfile.yml' \) | xargs -n1 dirname | sort -u)
3131

3232
test:
3333
name: Test on samples

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ It requires the following tools to be installed on local machine:
8888
```bash
8989
cd integrations
9090
task kind:create
91-
task test:env:directory:deploy
92-
task test:directory
91+
task directory:test-env:deploy
92+
task directory:test
9393
```
9494

9595
We can focus on specified tests:
9696
```bash
97-
task test:directory:compiler
97+
task directory:test:compiler
9898
```
9999

100100
After we finish the tests we can destroy the test cluster
@@ -182,9 +182,9 @@ Before pushing your changes, test them locally to ensure everything works as exp
182182

183183
```bash
184184
task kind:create
185-
task test:env:new-componet:deploy
186-
task test:new-component
187-
task test:env:new-componet:cleanup
185+
task new-componet:test-env:deploy
186+
task new-component:test
187+
task new-componet:test-env:cleanup
188188
task kind:destroy
189189
```
190190

Taskfile.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
version: '3'
6+
7+
silent: true
8+
9+
includes:
10+
integrations:
11+
taskfile: ./integrations/Taskfile.yml
12+
dir: ./integrations
13+
excludes: [default]
14+
vars:
15+
DIRECTORY_IMAGE_TAG: '{{ .DIRECTORY_IMAGE_TAG }}'
16+
GATEWAY_IMAGE_TAG: '{{ .GATEWAY_IMAGE_TAG }}'
17+
18+
samples:
19+
taskfile: ./samples/Taskfile.yml
20+
dir: ./samples
21+
excludes: [default]
22+
23+
tasks:
24+
default:
25+
cmd: task -l

0 commit comments

Comments
 (0)