From 2f0e8095d3f176cd1961cd8b4a518ed36f80b2ba Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:28:28 +0100 Subject: [PATCH] validating browsertime fields and structure --- ...ression-test-sitespeed-browsertime-har.yml | 60 +++++++++++++++++++ .github/workflows/update-docker.yml | 2 + .github/workflows/verify_result.py | 11 ++++ 3 files changed, 73 insertions(+) create mode 100644 .github/workflows/regression-test-sitespeed-browsertime-har.yml diff --git a/.github/workflows/regression-test-sitespeed-browsertime-har.yml b/.github/workflows/regression-test-sitespeed-browsertime-har.yml new file mode 100644 index 00000000..c23e4eb2 --- /dev/null +++ b/.github/workflows/regression-test-sitespeed-browsertime-har.yml @@ -0,0 +1,60 @@ +name: "Regression Test - Sitespeed.io - Browsertime.har fields and structure" +on: + workflow_dispatch: + push: + paths: + - '**verify_result.py' + - '**regression-test-sitespeed-browsertime-har.yml' +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + browser: ['firefox', 'chrome'] + steps: + - uses: actions/checkout@v4 + - name: Setup QEMU # used to allow multiplatform docker builds + uses: docker/setup-qemu-action@v3 + - name: Setup Docker Buildx # used to allow multiplatform docker builds + uses: docker/setup-buildx-action@v3 + - name: Test includeResponseBodies using ${{ matrix.browser }} + if: always() + run: | + command="docker run --rm -v $(pwd):/sitespeed.io sitespeedio/sitespeed.io:35.7.0 -b ${{ matrix.browser }} -n 1 --chrome.includeResponseBodies html --firefox.includeResponseBodies html https://webperf.se" + echo "$command" + testresult=$($command) + echo "$testresult" + path=$(echo "$testresult" | grep -o "/sitespeed.io/.*") + if [ -n result ]; then + har_file=$(find $(pwd) -name "browsertime.har") + if [ -f "$har_file" ]; then + echo "Found browsertime.har at $har_file" + content=$(cat "$har_file") + if [[ "$content" != *""* ]]; then + echo "Error: browsertime.har is not including html file content" + exit 1 + else + echo "browsertime.har is OK" + fi + else + echo "Error: browsertime.har not found in $path" + exit 1 + fi + else + echo "Error: No path found starting with /sitespeed.io/" + exit 1 + fi + # - name: Check out repository code + # uses: actions/checkout@v4 + # - name: Setup python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.13' # Version range or exact version of a Python version to use, using SemVer's version range syntax + # architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + # - name: Setup dependencies using pip + # run: pip install -r requirements.txt + # - name: RUNNING TEST - LINUX + # run: | + # python default.py -t ${{ matrix.version }} -r -i defaults/sites.json -o data/testresult-${{ matrix.version }}.json --setting ${{ matrix.config }} --setting tests.sitespeed.xvfb=true + # python .github/workflows/verify_result.py -t ${{ matrix.version }} diff --git a/.github/workflows/update-docker.yml b/.github/workflows/update-docker.yml index ef4a5f5e..906bc6ec 100644 --- a/.github/workflows/update-docker.yml +++ b/.github/workflows/update-docker.yml @@ -37,7 +37,9 @@ jobs: Following files may be touched: - Dockerfile + - .github/workflows/regression-test-sitespeed-browsertime-har.yml assignees: 7h3Rabbit reviewers: 7h3Rabbit add-paths: | Dockerfile + .github/workflows/regression-test-sitespeed-browsertime-har.yml diff --git a/.github/workflows/verify_result.py b/.github/workflows/verify_result.py index 16f492a3..12ce2e23 100644 --- a/.github/workflows/verify_result.py +++ b/.github/workflows/verify_result.py @@ -595,6 +595,17 @@ def handle_update_docker(): print('Dockerfile requires update') set_file_content(our_docker_filepath, our_docker_content) print('Dockerfile was updated') + + our_browsertime_har_yml_filepath = os.path.join(base_directory, '.github', 'workflows', 'regression-test-sitespeed-browsertime-har.yml') + if os.path.exists(our_browsertime_har_yml_filepath): + our_from_os = our_from_os.replace('FROM ', '') + sitespeed_from_os = sitespeed_from_os.replace('FROM ', '') + + our_browsertime_har_yml_content = get_file_content(our_browsertime_har_yml_filepath) + our_browsertime_har_yml_content = our_browsertime_har_yml_content.replace(our_from_os, sitespeed_from_os) + print('regression-test-sitespeed-browsertime-har.yml requires update') + set_file_content(our_browsertime_har_yml_filepath, our_browsertime_har_yml_content) + print('regression-test-sitespeed-browsertime-har.yml was updated') else: print('Dockerfile is up to date')