-
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.
- Loading branch information
Showing
5 changed files
with
174 additions
and
1 deletion.
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,44 @@ | ||
name: Ubuntu | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup vcpkg | ||
run: | | ||
chmod +x ./tools/install-vcpkg.sh | ||
./tools/install-vcpkg.sh | ||
- name: Build | ||
run: | | ||
chmod +x ./build.sh | ||
./build.sh clean release | ||
chmod +x ./build/examples/single-thing | ||
chmod +x ./build/examples/multiple-things | ||
chmod +x ./build/examples/gui-thing | ||
chmod +x ./build/test/tests | ||
- name: Integration tests | ||
working-directory: ${{github.workspace}}/tools | ||
run: | | ||
chmod +x ./run-webthing-tester.sh | ||
./run-webthing-tester.sh | ||
- name: Upload binaries | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: binaries | ||
path: | | ||
./build/examples/single-thing | ||
./build/examples/multiple-things | ||
./build/examples/gui-thing | ||
./build/test/tests |
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 @@ | ||
name: Windows | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Setup MSBuild | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- name: Setup vcpkg | ||
run: | | ||
.\tools\install-vcpkg.bat | ||
- name: Build | ||
run: | | ||
.\build.bat clean release | ||
- name: Integration tests | ||
working-directory: .\tools | ||
run: | | ||
python run-webthing-tester-windows.py | ||
- name: Upload binaries | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: binaries | ||
path: | | ||
.\build\examples\Release\single-thing.exe | ||
.\build\examples\Release\multiple-things.exe | ||
.\build\examples\Release\gui-thing.exe | ||
.\build\test\Release\tests.exe |
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
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
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,80 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
import time | ||
import signal | ||
|
||
def run_command(command, cwd=None): | ||
"""Run a shell command.""" | ||
result = subprocess.run(command, shell=True, cwd=cwd, check=True) | ||
return result | ||
|
||
def clone_or_update_webthing_tester_repo(): | ||
"""Clone the repository if it doesn't exist, otherwise update it.""" | ||
|
||
repo_dir = "webthing-tester" | ||
branch = "time-regex-option" | ||
|
||
if os.path.isdir(repo_dir): | ||
print(f"Updating repository in {repo_dir}...") | ||
run_command(f"git pull origin {branch}", cwd=repo_dir) | ||
else: | ||
print(f"Cloning repository to {repo_dir}...") | ||
run_command(f"git clone -b {branch} https://github.com/bw-hro/webthing-tester.git") | ||
|
||
def install_python_dependencies(): | ||
"""Install required Python packages.""" | ||
print("Installing Python dependencies...") | ||
run_command("pip3 install --user -r webthing-tester/requirements.txt") | ||
|
||
def build_webthing_cpp(): | ||
"""Build Webthing-CPP if the binaries do not exist.""" | ||
single_bin = "../build/examples/Release/single-thing.exe" | ||
multis_bin = "../build/examples/Release/multiple-things.exe" | ||
|
||
if not os.path.exists(single_bin) or not os.path.exists(multis_bin): | ||
print("Building Webthing-CPP with examples...") | ||
run_command("build.bat clean release", cwd="..") | ||
else: | ||
print("Binaries already exist, skipping build.") | ||
|
||
def run_example(example_path, time_regex, path_prefix=""): | ||
"""Run the example and test it with webthing-tester.""" | ||
print(f"Running example {example_path}...") | ||
process = subprocess.Popen([example_path]) | ||
|
||
try: | ||
time.sleep(15) # Wait for the example to start | ||
test_command = [ | ||
"python", | ||
"webthing-tester/test-client.py", | ||
"--time-regex", time_regex, | ||
"--debug" | ||
] | ||
if path_prefix: | ||
test_command.extend(["--path-prefix", path_prefix]) | ||
|
||
print(f"Running webthing-tester with {test_command}...") | ||
run_command(" ".join(test_command)) | ||
|
||
finally: | ||
print(f"Terminating example process {example_path}...") | ||
process.terminate() | ||
process.wait() | ||
|
||
def main(): | ||
clone_or_update_webthing_tester_repo() | ||
install_python_dependencies() | ||
build_webthing_cpp() | ||
|
||
# Configure time regex to match timestamps with milliseconds | ||
time_regex = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}[+-]\d{2}:\d{2}$" | ||
|
||
single_example_path = "../build/examples/Release/single-thing.exe" | ||
run_example(single_example_path, time_regex) | ||
|
||
multiple_example_path = "../build/examples/Release/multiple-things.exe" | ||
run_example(multiple_example_path, time_regex, path_prefix="/0") | ||
|
||
if __name__ == "__main__": | ||
main() |