forked from ika-rwth-aachen/carlos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ika-rwth-aachen#8 from ika-rwth-aachen/feature/aut…
…omated-testing-dev
- Loading branch information
Showing
15 changed files
with
909 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: 'evaluate-scenario' | ||
description: 'Sets up the CARLOS framework and runs a specified scenario for evaluation or testing' | ||
|
||
inputs: | ||
|
||
# Simulator Options | ||
|
||
simulator-image: | ||
description: 'Image of the CARLA simulator' | ||
default: rwthika/carla-simulator:server | ||
|
||
simulator-offscreen: | ||
description: 'Disables visual output of the simulator' | ||
default: true | ||
|
||
# Scenario Runner Options | ||
|
||
scenario-runner-image: | ||
description: 'Image of the CARLA scenario runner' | ||
default: rwthika/carla-scenario-runner:latest | ||
|
||
scenario-folder-path: | ||
description: 'Path to folder containing the scenario(s) and optional catalogs subfolder' | ||
required: true | ||
|
||
scenario-file-name: | ||
description: 'Filename of scenario' | ||
required: true | ||
|
||
# Other Options | ||
|
||
compose-file-path: | ||
description: 'Location of Compose file for the setup. Generated from template if file does not exist' | ||
|
||
compose-template-path: | ||
description: 'Path to template that is used for generating a new Compose file from environment variables' | ||
|
||
outputs: | ||
|
||
compose-file: | ||
description: 'Compose file generated by the setup step and used for running the scenario(s)' | ||
value: ${{ steps.setup-carlos.outputs.compose-file }} | ||
|
||
runs: | ||
|
||
using: 'composite' | ||
steps: | ||
- name: Setup CARLOS | ||
id: setup-carlos | ||
shell: bash | ||
run: ${GITHUB_ACTION_PATH}/scripts/setup-carlos.sh | ||
env: | ||
SIMULATOR_IMAGE: ${{ inputs.simulator-image }} | ||
SIMULATOR_OFFSCREEN: ${{ inputs.simulator-offscreen }} | ||
SCENARIO_RUNNER_IMAGE: ${{ inputs.scenario-runner-image }} | ||
SCENARIO_FOLDER_PATH: ${{ inputs.scenario-folder-path }} | ||
SCENARIO_FILE_NAME: ${{ inputs.scenario-file-name }} | ||
COMPOSE_FILE_PATH: ${{ inputs.compose-file-path }} | ||
COMPOSE_TEMPLATE_PATH: ${{ inputs.compose-template-path }} | ||
GITHUB_ACTION_PATH: ${GITHUB_ACTION_PATH} | ||
|
||
- name: Run scenario | ||
shell: bash | ||
run: ${GITHUB_ACTION_PATH}/scripts/run-scenario.sh | ||
|
||
- name: Cleanup CARLOS | ||
shell: bash | ||
if: always() | ||
run: ${GITHUB_ACTION_PATH}/scripts/cleanup-carlos.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
services: | ||
|
||
carla-simulator: | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [gpu] | ||
privileged: True | ||
environment: | ||
DISPLAY: $DISPLAY | ||
volumes: | ||
- /tmp/.X11-unix:/tmp/.X11-unix | ||
image: $SIMULATOR_IMAGE | ||
command: bash -ic './CarlaUE4.sh -nosound $SIMULATOR_FLAGS 2>/dev/null' | ||
|
||
carla-scenario-runner: | ||
depends_on: | ||
carla-simulator: | ||
condition: service_healthy | ||
volumes: | ||
- $SCENARIO_FOLDER_PATH:/scenarios | ||
image: $SCENARIO_RUNNER_IMAGE | ||
command: bash -ic "python ./scenario_runner.py --host carla-simulator --openscenario /scenarios/$SCENARIO_FILE_NAME --output" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_FILE_PATH="${COMPOSE_FILE_PATH:-"$GITHUB_ACTION_PATH/compose.yml"}" | ||
|
||
# kill and remove remaining CARLOS setup | ||
docker compose -f $COMPOSE_FILE_PATH kill | ||
docker compose -f $COMPOSE_FILE_PATH down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_FILE_PATH="${COMPOSE_FILE_PATH:-"$GITHUB_ACTION_PATH/compose.yml"}" | ||
|
||
# start scenario runner to evaluate scenario | ||
docker compose -f $COMPOSE_FILE_PATH run --rm carla-scenario-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_FILE_PATH="${COMPOSE_FILE_PATH:-"$GITHUB_ACTION_PATH/compose.yml"}" | ||
COMPOSE_TEMPLATE_PATH="${COMPOSE_TEMPLATE_PATH:-"$GITHUB_ACTION_PATH/files/template.yml"}" | ||
|
||
if [ "$SIMULATOR_OFFSCREEN" = true ]; then | ||
export SIMULATOR_FLAGS="-RenderOffScreen" | ||
fi | ||
|
||
# generate compose file from template and environment variables | ||
if [ ! -f $COMPOSE_FILE_PATH ]; then | ||
(envsubst < $COMPOSE_TEMPLATE_PATH) > $COMPOSE_FILE_PATH | ||
fi | ||
|
||
# provide full compose file as output | ||
echo "compose-file<<EOF" >> $GITHUB_OUTPUT | ||
echo "$(cat $COMPOSE_FILE_PATH)" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
|
||
# start simulator | ||
xhost +local: | ||
docker compose -f $COMPOSE_FILE_PATH up -d carla-simulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: 'generate-job-matrix' | ||
description: 'Generates a matrix from files/directories selected by a query string to dynamically create jobs' | ||
|
||
inputs: | ||
|
||
starting-point: | ||
description: 'Location from which recursive search starts' | ||
default: '.' | ||
|
||
query-string: | ||
description: 'Shell pattern that is used for matching and selecting file/directory names' | ||
default: '' | ||
|
||
max-depth: | ||
description: 'How many levels to descend at most for selection of results (1 targets the directory of the starting-point)' | ||
default: 100 | ||
|
||
exclude-string: | ||
description: 'Shell pattern that is used to exclude file/directory names from the final result' | ||
default: '' | ||
|
||
outputs: | ||
|
||
matrix: | ||
description: 'JSON string which can be turned to a matrix definition by using fromJson()' | ||
value: ${{ steps.generator.outputs.matrix }} | ||
|
||
runs: | ||
|
||
using: 'composite' | ||
steps: | ||
- id: generator | ||
run: ${GITHUB_ACTION_PATH}/scripts/generate.sh -d ${{ inputs.max-depth }} -e "${{ inputs.exclude-string }}" ${{ inputs.starting-point }} "${{ inputs.query-string }}" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
usage() { | ||
echo "Usage: $0 [-d maxdepth] [-e exclude-path] STARTING-POINT QUERY-STRING" | ||
echo "STARTING-POINT : Location from where search should start" | ||
echo "QUERY-STRING : UNIX pattern used for matching and selecting results. Needs to be \"quoted\"" | ||
echo "max-depth : Descend at most max-depth levels from STARTING-POINT" | ||
echo "exclude-string : Exclude paths matching this UNIX pattern from final result. Needs to be \"quoted\"" | ||
echo "-----" | ||
echo "Example: $0 -d 3 . \"*.xosc\"" | ||
} | ||
|
||
args=() | ||
|
||
while getopts "hd:e:" flag; do | ||
case "$flag" in | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
d) args=(-maxdepth "$OPTARG" "${args[@]}");; | ||
e) args+=(-not -path "$OPTARG");; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND-1)) # return to usual handling of positional args | ||
if [ $# -lt 2 ]; then | ||
usage | ||
exit 1 | ||
fi | ||
startingPoint=$1 | ||
queryStr=$2 | ||
|
||
matrixArray=$(find ~+/$startingPoint "${args[@]}" -name "$queryStr") | ||
|
||
printf %"s\n" "Selected paths:" "$matrixArray" | ||
echo "$matrixArray" | \ | ||
jq --slurp --raw-input 'split("\n")[:-1]' | \ | ||
jq "{\"filepath\": .[] }" | \ | ||
jq -c '(.filepath / "/" | {filedir: (.[0:-1] | join("/")),filename: .[-1]})' | \ | ||
jq -sc "{ \"include\": . }" \ | ||
> matrix.tmp | ||
echo "MATRIX=$(cat ./matrix.tmp)" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: automated-testing | ||
on: push | ||
jobs: | ||
generate-scenario-job-matrix: | ||
runs-on: self-hosted | ||
outputs: | ||
matrix: ${{ steps.generate.outputs.matrix }} | ||
name: generate scenario job matrix | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: generate | ||
uses: ./.github/actions/generate-job-matrix | ||
with: | ||
starting-point: ./utils/scenarios | ||
query-string: '*.xosc' | ||
exclude-string: '*/catalogs/*' | ||
|
||
evaluate-required-scenarios: | ||
needs: generate-scenario-job-matrix | ||
runs-on: self-hosted | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.generate-scenario-job-matrix.outputs.matrix) }} | ||
name: Eval ${{ matrix.filename }} | ||
steps: | ||
- run: rm -rf * | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/evaluate-scenario | ||
with: | ||
scenario-folder-path: ${{ matrix.filedir }} | ||
scenario-file-name: ${{ matrix.filename }} | ||
simulator-image: rwthika/carla-simulator:server | ||
simulator-offscreen: true | ||
|
||
generate-opt-scenario-job-matrix: | ||
needs: evaluate-required-scenarios | ||
runs-on: self-hosted | ||
outputs: | ||
opt-matrix: ${{ steps.generate-opt.outputs.matrix }} | ||
name: generate optional scenario job matrix | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: generate-opt | ||
uses: ./.github/actions/generate-job-matrix | ||
with: | ||
starting-point: ./utils/scenarios | ||
query-string: '*.xosc.opt' | ||
exclude-string: '*/catalogs/*' | ||
|
||
evaluate-optional-scenarios: | ||
needs: generate-opt-scenario-job-matrix | ||
runs-on: self-hosted | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.generate-opt-scenario-job-matrix.outputs.opt-matrix) }} | ||
name: Eval ${{ matrix.filename }} | ||
steps: | ||
- run: rm -rf * | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/evaluate-scenario | ||
continue-on-error: true | ||
with: | ||
scenario-folder-path: ${{ matrix.filedir }} | ||
scenario-file-name: ${{ matrix.filename }} | ||
simulator-image: rwthika/carla-simulator:server | ||
simulator-offscreen: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.