From 36c446a5caaa3db50a44a70f3c2bd4a62a31ef9d Mon Sep 17 00:00:00 2001 From: James Kunstle Date: Fri, 24 Jan 2025 18:24:10 -0800 Subject: [PATCH] adds smoke test workflow users can dispatch a workflow that runs smoke tests against a selected branch Signed-off-by: James Kunstle --- .github/workflows/smoke-tests.yaml | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/smoke-tests.yaml diff --git a/.github/workflows/smoke-tests.yaml b/.github/workflows/smoke-tests.yaml new file mode 100644 index 00000000..79dd18a5 --- /dev/null +++ b/.github/workflows/smoke-tests.yaml @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: Apache-2.0 + +name: "Run smoke tests via Tox::pytest" +# These tests will be long running and require accelerated hardware. +# They will help to verify that the library is *functionally* correct but +# will not try to verify that the libary is *correct*. + +on: + # TEMP - only runs when manually invoked + # and only runs against branches in the repo. + workflow_dispatch: + inputs: + branch: + type: string + default: main + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + start-ec2-runner: + uses: ./.github/workflows/reusable-start-ec2-runner.yaml + with: + aws_region: ${{vars.AWS_REGION}} + aws_ami: ${{vars.AWS_EC2_AMI}} + aws_ec2_runner_variant: ${{vars.SMOKETEST_EC2_INSTANCE_TYPE}} # requires accelerators + secrets: inherit + + run-smoke-tests: + needs: + - start-ec2-runner + runs-on: ${{needs.start-ec2-runner.outputs.runner_label}} + # It is important that this job has no write permissions and has + # no access to any secrets. This part is where we are running + # untrusted code from PRs. + permissions: {} + steps: + - name: "Harden runner" + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.1 + with: + egress-policy: audit + + - name: "Install packages" + run: | + cat /etc/os-release + sudo dnf install -y gcc gcc-c++ make git python3.11 python3.11-devel + + - name: "Verify cuda environment is setup" + run: | + export CUDA_HOME="/usr/local/cuda" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64" + export PATH="$PATH:$CUDA_HOME/bin" + nvidia-smi + + - name: "Checkout code" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + ref: ${{inputs.branch}} + + # installs in $GITHUB_WORKSPACE/venv. + # only has to install Tox because Tox will do the other virtual environment management. + - name: "Setup Python virtual environment" + run: | + python3.11 -m venv --upgrade-deps venv + . venv/bin/activate + pip install tox + + - name: "Show disk utilization BEFORE tests" + run: | + df -h + + - name: "Run unit tests with Tox and Pytest" + run: | + source venv/bin/activate + tox -e py3-smoke + + - name: "Show disk utilization AFTER tests" + run: | + df -h + + stop-ec2-runner: + needs: + - start-ec2-runner + - run-smoke-tests + if: ${{ always() }} + uses: ./.github/workflows/reusable-stop-ec2-runner.yaml + with: + aws_region: ${{vars.AWS_REGION}} + aws_ec2_runner_label: ${{needs.start-ec2-runner.outputs.runner_label}} + aws_ec2_runner_instance_id: ${{needs.start-ec2-runner.outputs.runner_instance_id}} + secrets: inherit