-
Notifications
You must be signed in to change notification settings - Fork 19
87 lines (78 loc) · 2.97 KB
/
robot-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Robot Test images
on:
push:
branches:
- main*
pull_request:
branches:
- main*
jobs:
prepare-sdk:
name: Prepare SDK for Robot Testing
runs-on: ubuntu-latest
outputs:
# Names of every Test Case defined
test_cases: ${{ steps.get_tests.outputs.test_cases }}
container_tag: ${{ steps.ver.outputs.container_tag }}
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4
# Import SDK image and initialize workspace
- name: Extract DevContainer Version
id: ver
run: |
CONTAINER_TAG=$(cat .devcontainer/devcontainer.json | grep "ghcr.io" | awk -F ":" '{print $3}' | awk -F "\"" '{print $1}')
echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
# Generate Test Matrix
- name: Generate Test Matrix
id: get_tests
run: |
sudo apt-get update && sudo apt-get install -y python3 python3-venv python3-pip
python3 -m pip install --upgrade pip
pip install robotframework
echo "test_cases=$(./robot_tests/tools/extract_cases_names.py ./robot_tests/images.robot)" >> $GITHUB_OUTPUT
Test:
runs-on: ubuntu-latest
needs: prepare-sdk
strategy:
fail-fast: false
matrix:
test_case:
${{ fromJson(needs.prepare-sdk.outputs.test_cases) }}
steps:
- uses: actions/checkout@v4
- run: |
sudo apt-get update && sudo apt-get install -y python3 python3-venv python-is-python3 binfmt-support qemu-user-static
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull DevContainer
id: pull_dev
run: docker pull ghcr.io/elektrobit/ebcl_dev_container:${{ needs.prepare-sdk.outputs.container_tag }}
# Replace '/' in Test Case Names with '_'
# '/' not allowed in File Names
- name: Sanitize Test Name
id: sanitize
run: |
test_name="${{ matrix.test_case }}"
sanitized_test_name=$(echo "$test_name" | tr '/' '_') # Replace slashes with underscores
echo "sanitized_test_name=$sanitized_test_name" >> $GITHUB_ENV
- name: Run Robot Test in dev container
id: robot
uses: devcontainers/ci@v0.3
with:
runCmd: |
robot --outputdir ./robot_tests --test "${{ matrix.test_case }}" ./robot_tests/images.robot
- name: Upload test report
# Upload artifacts always when Robot Test failed but never when prepare steps fail.
if: ${{ failure() && steps.pull_dev.conclusion == 'success' && steps.sanitize.conclusion == 'success'}}
uses: actions/upload-artifact@v4
with:
name: "report-${{ env.sanitized_test_name }}"
path: |
./robot_tests/report.html
./robot_tests/output.xml
./robot_tests/log.html