Skip to content

Commit 2f7a1c1

Browse files
committed
ci: Init e2e testing in CI
Adds a github action triggering an end to end test of edgehog on backend changes. Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
1 parent 6148478 commit 2f7a1c1

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# This file is part of Edgehog.
3+
#
4+
# Copyright 2025 SECO Mind Srl
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
20+
21+
name: export-container
22+
description: "Export backend conteatiner into a `backend.tar` artifact."
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Create image tar
27+
shell: bash
28+
run: |
29+
docker image save edgehogdevicemanager/edgehog-backend:latest -o backend.tar
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
path: backend.tar
33+
name: backend.tar
34+
if-no-files-found: error
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# This file is part of Edgehog.
3+
#
4+
# Copyright 2025 SECO Mind Srl
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
20+
21+
name: import container
22+
description: "Export backend conteatiner into a `backend.tar` artifact."
23+
runs:
24+
using: "composite"
25+
steps:
26+
- uses: actions/download-artifact@v5
27+
- name: Import backend container
28+
shell: bash
29+
run: |
30+
docker image load < backend.tar

.github/workflows/backend-test.yaml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ on:
2525
push:
2626
paths:
2727
- "backend/**"
28+
- "tools/e2e_test/**"
2829
- ".tool-versions"
2930
- ".github/workflows/backend-test.yaml"
3031
branches:
@@ -34,6 +35,7 @@ on:
3435
pull_request:
3536
paths:
3637
- "backend/**"
38+
- "tools/e2e_test/**"
3739
- ".tool-versions"
3840
- ".github/workflows/backend-test.yaml"
3941

@@ -280,4 +282,59 @@ jobs:
280282
steps:
281283
- uses: actions/checkout@v5
282284
- name: Build Docker image
283-
run: docker build .
285+
run: docker build . -t edgehogdevicemanager/edgehog-backend:latest
286+
- uses: ./.github/actions/export-container
287+
288+
e2e-test:
289+
name: End to end
290+
runs-on: ubuntu-24.04
291+
needs: build-docker-image
292+
env:
293+
CARGO_TERM_COLOR: always
294+
SCCACHE_GHA_ENABLED: "true"
295+
RUSTC_WRAPPER: "sccache"
296+
RUST_LOG: "debug"
297+
steps:
298+
- name: Checkout repository
299+
uses: actions/checkout@v5
300+
with:
301+
show-progress: false
302+
- name: Setup Rust toolchain
303+
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
304+
- uses: mozilla-actions/sccache-action@v0.0.9
305+
- uses: extractions/setup-just@v3
306+
- name: Install astartectl
307+
uses: jaxxstorm/action-install-gh-release@v1.10.0
308+
with:
309+
repo: astarte-platform/astartectl
310+
# Cache astarte docker images
311+
- name: Cache Docker images.
312+
uses: ScribeMD/docker-cache@0.5.0
313+
with:
314+
key: docker-${{ runner.os }}
315+
- name: Init Astarte repo
316+
shell: bash
317+
run: |
318+
just _check-system-prereqs _check-astarte-prereqs _configure-system _init-astarte
319+
- uses: ./.github/actions/import-container
320+
- name: Init edgehog
321+
run: |
322+
docker compose up -d
323+
- name: Provision astarte realm
324+
timeout-minutes: 2
325+
run: |
326+
just _wait-astarte _create-astarte-realm
327+
# Skipping `_wait-for-edgehog`: the previous step should be way longer
328+
# than what is needed.
329+
- name: Provision edgehog tenant
330+
timeout-minutes: 2
331+
run: |
332+
just _create-edgehog-tenant
333+
- name: Check containers
334+
if: ${{ failure() }}
335+
run: |
336+
docker compose logs
337+
- name: Run e2e test suite
338+
working-directory: tools/e2e_test
339+
run: |
340+
cargo test

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ _init-edgehog:
104104
_create-edgehog-tenant edgehog-hostname="api.edgehog.localhost":
105105
#!/usr/bin/env bash
106106
admin_jwt=$(cat backend/priv/repo/seeds/keys/admin_jwt.txt)
107-
curl -sf -X POST "http://{{edgehog-hostname}}/admin-api/v1/tenants" \
107+
curl --fail-with-body -X POST "http://{{edgehog-hostname}}/admin-api/v1/tenants" \
108108
-H "Content-Type: application/vnd.api+json" \
109109
-H "Accept: application/vnd.api+json" \
110110
-H "Authorization: Bearer $admin_jwt" \

0 commit comments

Comments
 (0)