Skip to content

Commit

Permalink
remove requirement of workflow permission
Browse files Browse the repository at this point in the history
  • Loading branch information
cockroacher committed Dec 17, 2024
1 parent 6d6c384 commit 8f3d2b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ 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"
$sitespeedversion=$(echo python .github/workflows/verify_result.py --docker-sitespeed-version)
command="docker run --rm -v $(pwd):/sitespeed.io $sitespeedversion -b ${{ matrix.browser }} -n 1 --chrome.includeResponseBodies all --firefox.includeResponseBodies all https://webperf.se"
echo "$command"
testresult=$($command)
echo "$testresult"
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 8f3d2b3

Please sign in to comment.