Skip to content

Commit

Permalink
Adds a flag for just printing the version and quiting (#41)
Browse files Browse the repository at this point in the history
* Adds a flag for just printing the version and quiting

* Validate execution in updated workflow
  • Loading branch information
jlb6740 authored Jul 25, 2024
1 parent bd78ab3 commit 91715ba
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/compile-and-run-x64.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# This is a workflow triggered by PR or triggered manually
# Runs quick performance tests and reports the comparison against HEAD
# Test should take less than 10 minutes to run on current self-hosted devices
name: "Compile and Run on x64"
name: "Validate Build"

# Controls when the action will run.
on:
push:
on: push

# Env variables
env:
SG_COMMIT: 2ab01ac
GITHUB_CONTEXT: ${{ toJson(github) }}

jobs:
Compile_and_Run_All:
name: Compile and run wasm-score benchmarks
Validate_Build:
name: Validate Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "$GITHUB_CONTEXT"
- run: |
# Create and Push Branch
./build.sh
docker run -i wasmscore /bin/bash wasmscore.sh
docker run -i wasmscore /bin/bash wasmscore.sh -t quickrun_all
- name: Checkout code
uses: actions/checkout@v3

- name: Print context
run: echo "$GITHUB_CONTEXT"

- name: Build container
run: ./build.sh

- name: Check Version
run: docker run wasmscore -v

- name: Check QuickRun
run: docker run wasmscore -t quickrun_all

2 changes: 1 addition & 1 deletion config.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Global variables used by scripts for docker building and launching
IMAGE_NAME="wasmscore"
IMAGE_VERSION="v0.1.3.c052603"
IMAGE_VERSION="v0.2.0.8174ad4"
30 changes: 25 additions & 5 deletions wasmscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
help="Dump run results to the given file",
)

parser.add_argument(
"-v",
"--version",
action="store_true",
help="Check the build version",
)

# Global Variables
args = parser.parse_args()
Expand Down Expand Up @@ -886,23 +892,33 @@ def print_verbose(string):

def check_version():
"""Check the version of the sightglass-cli"""

build_version = subprocess.check_output(
"grep 'IMAGE_VERSION' config.inc | cut -d '\"' -f 2 ",
shell=True,
text=True,
stderr=subprocess.STDOUT,
).strip()
print(f"Version: {build_version}")

build_sha = subprocess.check_output(
"grep 'IMAGE_VERSION' config.inc | cut -d '\"' -f 2 | cut -c 2- | cut -d '.' -f 4",
shell=True,
text=True,
stderr=subprocess.STDOUT,
).strip()
calculated_build_version = subprocess.check_output(
calculated_build_sha = subprocess.check_output(
"find . -type f -name '*.wasm' | sort -d | xargs -I{} sha1sum add_time_metric.diff build.sh requirements.txt Dockerfile wasmscore.py {} | sha1sum | cut -c 1-7 | awk '{print $1}'",
shell=True,
text=True,
stderr=subprocess.STDOUT,
).strip()
if (build_version == calculated_build_version):
print(f"Build SHA: {build_version} vs {calculated_build_version} (calculated) (run valid)")
if (build_sha == calculated_build_sha):
print(f"Build sha: {build_sha} vs {calculated_build_sha} (calculated) (run is valid)")
else:
print(f"Build SHA: {build_version} vs {calculated_build_version} (calculated) (**run invalid**)")
return (build_version == calculated_build_version)
print(f"Build SHA: {build_sha} vs {calculated_build_sha} (calculated) (run is invalid)")

return (build_sha == calculated_build_sha)


def main():
Expand All @@ -911,6 +927,10 @@ def main():
print_verbose("WasmScore")
check_version()

if ARGS_DICT["version"]:
print("")
return

if ARGS_DICT["list"]:
print("")
print("Tests\n------")
Expand Down

0 comments on commit 91715ba

Please sign in to comment.