Skip to content

Commit

Permalink
Merge branch 'main' into unittst-css
Browse files Browse the repository at this point in the history
  • Loading branch information
cockroacher authored Dec 17, 2024
2 parents daa9a3f + 3b45ed9 commit 7584a7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/regression-test-sitespeed-browsertime-har.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ jobs:
- name: Testing sitespeed.io:s browsertime.har output 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 all --firefox.includeResponseBodies all https://webperf.se"
echo "$command"
echo "TEST A"
sitespeedversion=$(python .github/workflows/verify_result.py --docker-sitespeed-version)
echo "TEST B: $sitespeedversion"
command="docker run --rm -v $(pwd):/sitespeed.io $sitespeedversion -b ${{ matrix.browser }} -n 1 --chrome.includeResponseBodies all --firefox.includeResponseBodies all https://webperf.se"
echo "TEST C: $command"
testresult=$($command)
echo "$testresult"
echo "TEST D: $testresult"
path=$(echo "$testresult" | grep -o "/sitespeed.io/.*")
if [ -n result ]; then
if [ -n "$path" ]; then
har_file=$(find $(pwd) -name "browsertime.har")
if [ -f "$har_file" ]; then
echo "Found browsertime.har at $har_file"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/update-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ 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
29 changes: 18 additions & 11 deletions .github/workflows/verify_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def main(argv):
opts, _ = getopt.getopt(argv, "hlt:d:s:b:", [
"help", "test=", "sample-config=",
"browsertime=",
"docker-sitespeed-version",
"language", "docker="])
except getopt.GetoptError:
print(main.__doc__)
Expand All @@ -489,6 +490,9 @@ def main(argv):
handle_test_result(arg)
elif opt in ("-d", "--docker"): # docker
handle_update_docker()
elif opt in ("--docker-sitespeed-version"): # get docker version used
get_sitespeed_docker_image()
sys.exit(0)

# No match for command so return error code to fail verification
sys.exit(2)
Expand Down Expand Up @@ -564,6 +568,20 @@ def set_file_content(file_path, content):
with open(file_path, 'w', encoding='utf-8', newline='') as file:
file.write(content)

def get_sitespeed_docker_image():
base_directory = Path(os.path.dirname(
os.path.realpath(__file__)) + os.path.sep).parent.parent

our_docker_filepath = os.path.join(base_directory, 'Dockerfile')
if not os.path.exists(our_docker_filepath):
print(f'Dockerfile doesn\'t exists at: {our_docker_filepath}')
return False

our_docker_content = get_file_content(our_docker_filepath)
our_from_os = get_base_os_from_dockerfile(our_docker_content)
our_from_os = our_from_os.replace('FROM ', '')
print(our_from_os)
return our_from_os

def handle_update_docker():
""" Terminate the programme with an error if updating docker contains unexpected content """
Expand Down Expand Up @@ -596,17 +614,6 @@ 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')

Expand Down

0 comments on commit 7584a7c

Please sign in to comment.