Skip to content

[EBLINUX-26382] Create robustness test with robot framework #207

[EBLINUX-26382] Create robustness test with robot framework

[EBLINUX-26382] Create robustness test with robot framework #207

Workflow file for this run

name: Robot Test images
on:
push:
branches:
- main*
pull_request:
branches:
- main*
jobs:
prepare-sdk:
name: Prepare SDK for Robot Testing
runs-on: ubuntu-22.04
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-22.04
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