Support find cache + gh action for core mlc actions #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MLC core actions test | |
on: | |
pull_request: | |
branches: [ "main", "dev" ] | |
paths: | |
- '.github/workflows/test-mlc-core-actions.yml' | |
- '**' | |
- '!**.md' | |
jobs: | |
test_mlc_core_actions: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.12", "3.8"] | |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Configure git longpaths (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
git config --system core.longpaths true | |
- name: Install mlcflow from the pull request's source repository and branch | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --ignore-installed --verbose pip setuptools | |
python -m pip install . | |
- name: Define helper functions | |
shell: bash | |
run: | | |
# Function to validate a repository after pulling | |
validate_repo() { | |
local repo_path="$1" | |
local repo_json_path="$2" | |
local expected_branch="$3" | |
if [ ! -d "$repo_path" ]; then | |
echo "Repository folder $repo_path not found. Exiting with failure." | |
exit 1 | |
fi | |
if [ ! -f "$repo_json_path" ]; then | |
echo "File $repo_json_path does not exist. Exiting with failure." | |
exit 1 | |
fi | |
if ! grep -q "$repo_path" "$repo_json_path"; then | |
echo "Path $repo_path not found in $repo_json_path. Exiting with failure." | |
exit 1 | |
fi | |
CURRENT_BRANCH=$(git -C "$repo_path" rev-parse --abbrev-ref HEAD) | |
if [ "$CURRENT_BRANCH" != "$expected_branch" ]; then | |
echo "Expected branch '$expected_branch', but found '$CURRENT_BRANCH'. Exiting with failure." | |
exit 1 | |
fi | |
} | |
- name: Test 1 - pull repo - Pull a forked MLOps repository | |
env: | |
GH_MLC_REPO_PATH_FORK: "$HOME/MLC/repos/anandhu-eng@mlperf-automations" | |
GH_MLC_REPO_JSON_PATH: "$HOME/MLC/repos/repos.json" | |
run: | | |
mlc pull repo anandhu-eng@mlperf-automations --checkout=dev | |
validate_repo "$GH_MLC_REPO_PATH_FORK" "$GH_MLC_REPO_JSON_PATH" "dev" | |
- name: Test 2 - pull repo - Test conflicting repo scenario | |
env: | |
GH_MLC_REPO_PATH: "$HOME/MLC/repos/anandhu-eng@mlperf-automations" | |
GH_MLC_REPO_JSON_PATH: "$HOME/MLC/repos/repos.json" | |
run: | | |
mlc pull repo mlcommons@mlperf-automations --checkout=dev | |
validate_repo "$GH_MLC_REPO_PATH" "$GH_MLC_REPO_JSON_PATH" "dev" | |
if grep -q "$GH_MLC_REPO_PATH_FORK" "$GH_MLC_REPO_JSON_PATH"; then | |
echo "Path $GH_MLC_REPO_PATH_FORK also found in $GH_MLC_REPO_JSON_PATH. This should have been replaced. Exiting with failure." | |
exit 1 | |
fi | |
- name: Test 3 - list repo - List the existing repositories | |
run: | | |
mlc list repo | |
- name: Test 4 - rm repo - Remove the forked mlperf-automation repo | |
env: | |
GH_MLC_REPO_PATH_FORK: "$HOME/MLC/repos/anandhu-eng@mlperf-automations" | |
GH_MLC_REPO_JSON_PATH: "$HOME/MLC/repos/repos.json" | |
run: | | |
mlc rm repo anandhu-eng@mlperf-automations | |
if [ -d "$GH_MLC_REPO_PATH_FORK" ]; then | |
echo "Repository folder $GH_MLC_REPO_PATH found. It should ideally be deleted. Exiting with failure." | |
exit 1 | |
fi | |
- name: Test 5 - find cache - Cache not present | |
run: | | |
mlc find cache --tags=detect,os 2>&1 | tee test5.log | |
if ! grep -q "No cache entry found for the specified tags!" test5.log; then | |
exit 1 | |
fi | |
- name: Test 6 - run script - Output being used for testing mlc cache | |
run: | | |
mlc run script --tags=get,imagenet-aux --quiet | |
mlc run script --tags=get,imagenet-aux,_from.dropbox --quiet | |
- name: Test 7 - find cache - More than one cache present | |
run: | | |
mlc find cache --tags=get,imagenet-aux 2>&1 | tee test7.log | |
mlc find cache --tags=detect,os 2>&1 | tee test5.log | |
if grep -q "No cache entry found for the specified tags!" test5.log; then | |
exit 1 | |
fi |