Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use shared volume to cache packages #217

Merged
merged 8 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 72 additions & 15 deletions .github/workflows/build_and_test_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,27 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check if pip cache exists
whitneywhtsang marked this conversation as resolved.
Show resolved Hide resolved
env:
# Increase this value to reset cache
CACHE_NUMBER: 1
run: |
PIP_CACHE_KEY="pip-3.9-${{ hashFiles('.pre-commit-config.yaml') }}-${{ env.CACHE_NUMBER }}"
PIP_CACHE="/cache/$PIP_CACHE_KEY"
echo "PIP_CACHE=$PIP_CACHE" >> "${GITHUB_ENV}"
if [[ -d $PIP_CACHE ]]; then
echo "Python cache found for key $PIP_CACHE_KEY"
echo $PIP_CACHE > .pip-cache
mkdir -p $HOME/.cache
ln -s $PIP_CACHE $HOME/.cache/pip
else
echo "Python cache not found for key $PIP_CACHE_KEY"
fi

- name: Install Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
.pre-commit-config.yaml

- name: Run pre-commit checks
run: |
Expand All @@ -38,6 +52,14 @@ jobs:
python3 -m pre_commit run --all-files --verbose yapf &> /dev/null || true
python3 -m pre_commit run --all-files --verbose

- name: Save pip cache
if: ${{ hashFiles('.pip-cache') == '' }}
run: |
TMPDIR=/cache/${{ github.run_id }}-$RANDOM
mkdir $TMPDIR
cp -r $HOME/.cache/pip/* $TMPDIR/
mv $TMPDIR $PIP_CACHE

integration-tests:
name: Integration tests
runs-on:
Expand All @@ -51,30 +73,57 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check if pip cache exists
env:
# Increase this value to reset cache
CACHE_NUMBER: 1
run: |
PIP_CACHE_KEY="pip-3.9-${{ hashFiles('python/pyproject.toml', 'python/setup.py') }}-${{ env.CACHE_NUMBER }}"
PIP_CACHE="/cache/$PIP_CACHE_KEY"
echo "PIP_CACHE=$PIP_CACHE" >> "${GITHUB_ENV}"
if [[ -d $PIP_CACHE ]]; then
echo "Python cache found for key $PIP_CACHE_KEY"
echo $PIP_CACHE > .pip-cache
mkdir -p $HOME/.cache
ln -s $PIP_CACHE $HOME/.cache/pip
else
echo "Python cache not found for key $PIP_CACHE_KEY"
fi

- name: Install Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
python/pyproject.toml
python/setup.py

- name: Read packages from cache
id: packages-cache
uses: actions/cache@v3

- name: Check if packages cache exists
env:
# Increase this value to reset cache
CACHE_NUMBER: 1
with:
path: /home/runner/packages
key: packages-${{ hashFiles('scripts/compile-triton.sh', 'cmake/llvm-hash.txt') }}-${{ env.CACHE_NUMBER }}
run: |
PACKAGES_CACHE_KEY="packages-${{ hashFiles('scripts/compile-triton.sh', 'cmake/llvm-hash.txt') }}-${{ env.CACHE_NUMBER }}"
PACKAGES_CACHE="/cache/$PACKAGES_CACHE_KEY"
echo "PACKAGES_CACHE=$PACKAGES_CACHE" >> "${GITHUB_ENV}"
if [[ -d $PACKAGES_CACHE ]]; then
echo "Packages cache found for key $PACKAGES_CACHE_KEY"
echo $PACKAGES_CACHE > .packages-cache
ln -s $PACKAGES_CACHE $HOME/packages
else
echo "Packages cache not found for key $PACKAGES_CACHE_KEY"
fi

- name: Build packages
if: steps.packages-cache.outputs.cache-hit != 'true'
if: ${{ hashFiles('.packages-cache') == '' }}
run: |
./scripts/compile-triton.sh

- name: Save packages cache
if: ${{ hashFiles('.packages-cache') == '' }}
run: |
TMPDIR=/cache/${{ github.run_id }}-$RANDOM
mkdir $TMPDIR
cp -r $HOME/packages/* $TMPDIR/
mv $TMPDIR $PACKAGES_CACHE

- name: Build Triton
run: |
cd python
Expand Down Expand Up @@ -111,3 +160,11 @@ jobs:
run: |
cd python/build/*cmake*
ctest

- name: Save pip cache
if: ${{ hashFiles('.pip-cache') == '' }}
run: |
TMPDIR=/cache/${{ github.run_id }}-$RANDOM
mkdir $TMPDIR
cp -r $HOME/.cache/pip/* $TMPDIR/
mv $TMPDIR $PIP_CACHE