Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
initial GHA workflows for "build test" and "remote push" (#27)
Browse files Browse the repository at this point in the history
SUMMARY:
* initial set of "actions with a little a" that are the building blocks
for eventual CI system
* "build test" workflow
* "remote push" workflow on `a10g`
* update some requirement files to have packages listed in alphabetical
order

NOTE: this PR is still somewhat nebulas as i'm still working through
building and testing "neuralmagic-vllm" in our automation environment.

TEST:
currently, i'm working through various workflow components, i.e.
"actions with a little a". the bits making up the actions in this PR
have been constructed from my notes along the way.

we can do a "complete" run that includes: linting, building, installing,
and running tests.

GHA link ...
https://github.com/neuralmagic/neuralmagic-vllm/actions/runs/7975058564
`testmo` ... https://neuralmagic.testmo.net/automation/runs/view/8097

Latest GHA link ...
https://github.com/neuralmagic/neuralmagic-vllm/actions/runs/7992489982

---------

Co-authored-by: andy-neuma <andy@neuralmagic.com>
  • Loading branch information
andy-neuma and andy-neuma authored Feb 21, 2024
1 parent 897c4dc commit 64bdde5
Show file tree
Hide file tree
Showing 21 changed files with 574 additions and 26 deletions.
33 changes: 33 additions & 0 deletions .github/actions/nm-build-vllm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build neuralmagic-vllm
description: 'build neuralmagic-vllm'
inputs:
Gi_per_thread:
description: 'requested GiB to reserve per thread'
required: true
python:
description: 'python version, e.g. 3.10.12'
required: true
venv:
description: 'name for python virtual environment'
required: true
outputs:
status:
description: "final build status from 'pip install -e'"
value: ${{ steps.build.outputs.status }}
runs:
using: composite
steps:
- id: build
run: |
# TODO: this is a hack ... fix it later
# pyenv hardcoded ... python version hardcoded ...
COMMIT=${{ github.sha }}
VENV="${{ inputs.venv }}-${COMMIT:0:7}"
source $(pyenv root)/versions/${{ inputs.python }}/envs/${VENV}/bin/activate
pip3 install --index-url http://192.168.201.226:8080/ --trusted-host 192.168.201.226 magic-wand
pip3 install -r requirements.txt
SUCCESS=0
pip3 install -e . || SUCCESS=$?
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
shell: bash
23 changes: 23 additions & 0 deletions .github/actions/nm-lint-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: lint python
description: "runs 'ruff' and reports errors"
outputs:
status:
description: "return code from 'ruff'"
value: ${{ steps.ruff.outputs.status }}
runs:
using: composite
steps:
- id: ruff
run: |
SUCCESS=0
PYTHON_FILES=$(ruff .) || SUCCESS=$?
if [ ${SUCCESS} -ne 0 ]; then
echo "__Python Lint Failures:__" >> $GITHUB_STEP_SUMMARY
echo "${PYTHON_FILES}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo -e "lint: \xE2\x9D\x8C __FAILED__" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/nm-mypy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: mypy
description: "run 'mypy' and report final status"
outputs:
status:
description: "final status from 'mypy'"
value: ${{ steps.mypy.outputs.status }}
runs:
using: composite
steps:
- id: mypy
run: |
SUCCESS=0
mypy || SUCCESS=$?
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
shell: bash
48 changes: 48 additions & 0 deletions .github/actions/nm-run-summary/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: summary
description: 'creates a neuralmagic GHA run summary'
inputs:
label:
description: 'GHA runner label'
required: true
gitref:
description: 'git commit hash or branch name'
required: true
testmo_run_url:
description: 'testmo URL for this particular run'
required: true
python:
description: 'python version info'
required: true
lint_status:
description: 'status from python lint step'
required: true
build_status:
description: 'status from build step'
required: true
test_status:
description: 'status from test step'
required: true
runs:
using: composite
steps:
- run: |
LINT_STATUS=${{ inputs.lint_status }}
LINT_EMOJI=$(./.github/scripts/step-status ${LINT_STATUS})
BUILD_STATUS=${{ inputs.build_status }}
BUILD_EMOJI=$(./.github/scripts/step-status ${BUILD_STATUS})
TEST_STATUS=${{ inputs.test_status }}
TEST_EMOJI=$(./.github/scripts/step-status ${TEST_STATUS})
echo "testmo URL: ${{ inputs.testmo_run_url }}" >> $GITHUB_STEP_SUMMARY
echo ""
echo "| Parameter | |" >> $GITHUB_STEP_SUMMARY
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
echo "| label: | \`${{ inputs.label }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| git sha: | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| github actor: | '${{ github.actor }}' |" >> $GITHUB_STEP_SUMMARY
echo "| gitref: | '${{ inputs.gitref }}' |" >> $GITHUB_STEP_SUMMARY
echo "| branch name: | '${{ github.ref_name }}' |" >> $GITHUB_STEP_SUMMARY
echo "| python: | ${{ inputs.python }} |" >> $GITHUB_STEP_SUMMARY
echo "| lint: | ${LINT_EMOJI} |" >> $GITHUB_STEP_SUMMARY
echo "| build: | ${BUILD_EMOJI} |" >> $GITHUB_STEP_SUMMARY
echo "| test: | ${TEST_EMOJI} |" >> $GITHUB_STEP_SUMMARY
shell: bash
21 changes: 21 additions & 0 deletions .github/actions/nm-set-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: set neuralmagic env
description: 'sets environment variables for neuralmagic'
inputs:
hf_home:
description: 'Hugging Face home'
required: true
runs:
using: composite
steps:
- run: |
echo "HF_HOME=${HF_HOME_TOKEN}" >> $GITHUB_ENV
echo "TORCH_CUDA_ARCH_LIST=8.0+PTX" >> $GITHUB_ENV
echo "PYENV_ROOT=/usr/local/apps/pyenv" >> $GITHUB_ENV
echo "XDG_CONFIG_HOME=/usr/local/apps" >> $GITHUB_ENV
WHOAMI=$(whoami)
echo "PATH=/usr/local/apps/pyenv/plugins/pyenv-virtualenv/shims:/usr/local/apps/pyenv/shims:/usr/local/apps/pyenv/bin:/usr/local/apps/nvm/versions/node/v16.20.2/bin:/usr/local/cuda-12.1/bin:/usr/local/cuda-12.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/${WHOAMI}/.local/bin:" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64::/usr/local/cuda-12.1/lib64:" >> $GITHUB_ENV
echo "PROJECT_ID=12" >> $GITHUB_ENV
env:
HF_HOME_TOKEN: ${{ inputs.hf_home }}
shell: bash
30 changes: 30 additions & 0 deletions .github/actions/nm-set-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: set python
description: 'sets python version and creates venv for neuralmagic'
inputs:
python:
description: 'python version, e.g. 3.10.12'
required: true
venv:
description: 'name for python virtual environment'
required: true
outputs:
version:
description: "result from 'python --version'"
value: ${{ steps.set_python.outputs.version }}
runs:
using: composite
steps:
- id: set_python
run: |
command -v pyenv
pyenv root
pyenv versions
pyenv local ${{ inputs.python }}
COMMIT=${{ github.sha }}
VENV="${{ inputs.venv }}-${COMMIT:0:7}"
pyenv virtualenv ${VENV}
source $(pyenv root)/versions/${{ inputs.python }}/envs/${VENV}/bin/activate
pyenv versions
VERSION=$(python --version)
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
shell: bash
36 changes: 36 additions & 0 deletions .github/actions/nm-test-vllm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: test neuralmagic-vllm
description: "test neuralmagic-vllm via, 'pytest tests/'"
inputs:
test_directory:
description: 'test directory, path is relative to neuralmagic-vllm'
required: true
test_xml:
description: 'filename for xml test results'
required: true
python:
description: 'python version, e.g. 3.10.12'
required: true
venv:
description: 'name for python virtual environment'
required: true
outputs:
status:
description: "final status from 'pytest tests/'"
value: ${{ steps.test.outputs.status }}
runs:
using: composite
steps:
- id: test
run: |
SUCCESS=0
# TODO: this is a hack ... fix it later
# pyenv hardcoded ... python version hardcoded ...
COMMIT=${{ github.sha }}
VENV="${{ inputs.venv }}-${COMMIT:0:7}"
source $(pyenv root)/versions/${{ inputs.python }}/envs/${VENV}/bin/activate
pip3 install --index-url http://192.168.201.226:8080/ --trusted-host 192.168.201.226 magic-wand
pip3 install -r requirements-dev.txt
pytest --junitxml=${{ inputs.test_xml }} ${{ inputs.test_directory }} || SUCCESS=$?
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
shell: bash
35 changes: 35 additions & 0 deletions .github/actions/nm-testmo-run-complete/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: complete testmo run
description: 'complete neuralmagic testmo run'
inputs:
testmo_url:
description: 'testmo URL'
required: true
testmo_token:
description: 'testmo token'
required: true
testmo_run_id:
description: 'testmo run id'
required: true
runs:
using: "composite"
steps:
- run: |
echo "completing TESTMO run ..."
## CHECK testmo_url and token
if [[ -z "${TESTMO_URL}" ]]; then
echo "The TESTMO_URL secret is not defined for this repository"
exit 1
fi
if [[ -z "${TESTMO_TOKEN}" ]]; then
echo "The TESTMO_TOKEN secret is not defined for this repository"
exit 1
fi
## complete testmo run
npx testmo automation:run:complete \
--instance "${TESTMO_URL}" \
--run-id "${TESTMO_RUN_ID}"
env:
TESTMO_URL: ${{ inputs.testmo_url }}
TESTMO_TOKEN: ${{ inputs.testmo_token }}
TESTMO_RUN_ID: ${{ inputs.testmo_run_id }}
shell: bash
59 changes: 59 additions & 0 deletions .github/actions/nm-testmo-run-create/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: create testmo run
description: 'create neuralmagic testmo run and return its ID'
inputs:
testmo_url:
description: 'testmo URL'
required: true
testmo_token:
description: 'testmo token'
required: true
source:
description: "source for testmo, e.g. 'build-test'"
required: true
outputs:
id:
description: 'testmo run id'
value: ${{ steps.testmo_id.outputs.id }}
runs:
using: "composite"
steps:
- name: create run
id: testmo_id
run: |
echo "creating TESTMO run ..."
sudo mkdir -p ${HOME}/.npm
sudo chown -R $(whoami):$(whoami) ${HOME}/.npm
## adjust resources and GHA link
npx testmo automation:resources:add-field --name git --type string --value ${GITHUB_SHA:0:7} --resources resources.json
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
ACTOR=${GITHUB_ACTOR}
BUILD=${ACTOR}-$(whoami)-gpu
echo "name: ${BUILD}"
echo "url: ${RUN_URL}"
npx testmo automation:resources:add-link --name ${BUILD} --url ${RUN_URL} --resources resources.json
## CHECK testmo_url and token
if [[ -z "${TESTMO_URL}" ]]; then
echo "The TESTMO_URL secret is not defined for this repository"
exit 1
fi
if [[ -z "${TESTMO_TOKEN}" ]]; then
echo "The TESTMO_TOKEN secret is not defined for this repository"
exit 1
fi
## construct name
BRANCH_NAME=${GITHUB_REF_NAME}
TMP=${ACTOR}-${BRANCH_NAME}
TESTMO_RUN_NAME=$(echo ${TMP} | awk '{print tolower($0)}')
echo "test run name: ${TESTMO_RUN_NAME}"
## create testmo run
TESTMO_ID=$(npx testmo automation:run:create \
--instance "${TESTMO_URL}" \
--project-id "${PROJECT_ID}" \
--name "${TESTMO_RUN_NAME}" \
--source "${{ inputs.source }}" \
--resources resources.json)
echo "id=${TESTMO_ID}" >> "${GITHUB_OUTPUT}"
env:
TESTMO_URL: ${{ inputs.testmo_url }}
TESTMO_TOKEN: ${{ inputs.testmo_token }}
shell: bash
59 changes: 59 additions & 0 deletions .github/actions/nm-testmo-run-submit-thread/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: submit results to testmo run
description: 'asynchronously submit step results to neuralmagic testmo run'
inputs:
testmo_url:
description: 'testmo URL'
required: true
testmo_token:
description: 'testmo token'
required: true
testmo_run_id:
description: 'testmo run id'
required: true
results:
description: "directory of JUnit '*.xml' formatted result files"
required: true
step_status:
description: 'status of reported step'
required: true
outputs:
status:
description: "status of updating testmo. if there was no update, then 'success' is returned."
value: ${{ steps.submit_thread.outputs.status }}
runs:
using: "composite"
steps:
- id: submit_thread
run: |
ls -al
## if results is non-existent or there aren't results, then nothing to submit ...
REPORT=1
RESULTS=
if [[ ! -d ${{ inputs.results }} ]]; then
REPORT=0
else
RESULTS=$(find ${{ inputs.results }} -type f -name "*.xml")
fi
if [[ -z "${RESULTS}" ]]; then
REPORT=0
fi
## submit results?
SUCCESS=0
if [ ${REPORT} -eq 1 ]; then
echo "submitting results to TESTMO run ..."
## not checking testmo_url and token as this should be
## called between "create" and "complete"
npx testmo automation:run:submit-thread \
--instance ${TESTMO_URL} \
--run-id ${TESTMO_RUN_ID} \
--results ${RESULTS} \
-- ./.github/scripts/step-status ${{ inputs.step_status }}
SUCCESS=$?
fi
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
env:
TESTMO_URL: ${{ inputs.testmo_url }}
TESTMO_TOKEN: ${{ inputs.testmo_token }}
TESTMO_RUN_ID: ${{ inputs.testmo_run_id }}
shell: bash
Loading

0 comments on commit 64bdde5

Please sign in to comment.