From da15a246088042a92e4ae2f12f498ac13d07d79e Mon Sep 17 00:00:00 2001 From: Angelyr Date: Fri, 10 May 2024 13:15:39 -0400 Subject: [PATCH] added system tests --- .github/workflows/systems.yml | 63 +++++++++++++++++++++++++++++ .github/workflows/test_on_system.py | 38 +++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/systems.yml create mode 100644 .github/workflows/test_on_system.py diff --git a/.github/workflows/systems.yml b/.github/workflows/systems.yml new file mode 100644 index 000000000..a3f689f6a --- /dev/null +++ b/.github/workflows/systems.yml @@ -0,0 +1,63 @@ +name: Systems +on: + schedule: + # Sunday 4:30 UTC or 00:30 EDT + - cron: '30 4 * * 0' + +concurrency: + group: systems-omega_h + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + matrix: + machine: ["Perlmutter", "Frontier"] + + steps: + + - name: checkout omega_h + uses: actions/checkout@v4 + with: + path: omega_h + + - name: setup python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: install packing + run: sudo apt install python3-packaging + + - name: install globus + run: | + python -m ensurepip --upgrade --user + python -m pip install globus-compute-endpoint + + - name: use globus + working-directory: omega_h/.github/workflows + env: + GLOBUS_ID: ${{ secrets.GLOBUS_COMPUTE_ID }} + GLOBUS_SECRET: ${{ secrets.GLOBUS_COMPUTE_SECRET }} + run: | + export GLOBUS_COMPUTE_CLIENT_ID="$GLOBUS_ID" + export GLOBUS_COMPUTE_CLIENT_SECRET="$GLOBUS_SECRET" + if [ ${{matrix.machine}} == Perlmutter ]; then TARGET_ENDPOINT=0dd4499a-8d76-4977-bae9-841e4bb2f616; fi + if [ ${{matrix.machine}} == Frontier ]; then TARGET_ENDPOINT=d625c6cf-de7a-4228-ac44-56247a642fe0; fi + python test_on_system.py ${{ github.event.repository.name }} ${{ github.sha }} $TARGET_ENDPOINT + + - name: print build log + working-directory: omega_h/.github/workflows + run: cat omega_h-test-result/Build.log + + - name: print test log + working-directory: omega_h/.github/workflows + run: cat omega_h-test-result/Test.log + + - name: check failed test + working-directory: omega_h/.github/workflows + run: if grep "Failed" omega_h-test-result/Test.log; then return 1; fi + + \ No newline at end of file diff --git a/.github/workflows/test_on_system.py b/.github/workflows/test_on_system.py new file mode 100644 index 000000000..1c1f6d539 --- /dev/null +++ b/.github/workflows/test_on_system.py @@ -0,0 +1,38 @@ +# How to use +# 1. Login to https://app.globus.org/settings/developers and copy a project app id and secret +# 2. Use the id and secret to create and endpoint https://funcx.readthedocs.io/en/latest/sdk.html#client-credentials-with-clients +# $ export FUNCX_SDK_CLIENT_ID="b0500dab-ebd4-430f-b962-0c85bd43bdbb" +# $ export FUNCX_SDK_CLIENT_SECRET="ABCDEFGHIJKLMNOP0123456789=" +# 3. Set up an endpoint on the computer that will run the tests, using these instructions: https://funcx.readthedocs.io/en/latest/endpoints.html +# 4. Create install-test.sh and run-test.sh on target computer + +from globus_compute_sdk import Executor +import sys +import os + +name = sys.argv[1] +branch = sys.argv[2] +endpoint = sys.argv[3] + +def run_on_endpoint(name, branch): + import subprocess + + install = subprocess.run(["./install-test.sh "+name+" "+branch], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + if install.returncode == 1: + return (install, None) + + result = subprocess.run(["./run-test.sh "+name], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + return (install, result) + +gce = Executor(endpoint_id = endpoint) +future = gce.submit(run_on_endpoint, name, branch) +result = future.result() + +os.popen("mkdir -p "+name+"-result").read() +with open(name+"-result/Build.log", "w") as text_file: + text_file.write("%s" % result[0].stdout) + text_file.close() +if result[0].returncode == 0: + with open(name+"-result/Test.log", "w") as text_file: + text_file.write("%s" % result[1].stdout) + text_file.close()