Skip to content

Commit

Permalink
Use cache in install-meltingpot to speed up testing
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 552450804
Change-Id: I3681e88a0032ac5fc4fdbd824f5ad3dd8faeb36b
  • Loading branch information
jagapiou authored and Copybara-Service committed Jul 31, 2023
1 parent 53e2dce commit 9cf7b78
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion .github/actions/install-meltingpot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,60 @@ inputs:
runs:
using: composite
steps:
- name: Get current runner
id: os-info
shell: bash
run: |
if [ "${RUNNER_OS}" = 'macOS' ]; then
echo "name=$(sw_vers -productName)" >> $GITHUB_OUTPUT
echo "version=$(sw_vers -productVersion)" >> $GITHUB_OUTPUT
elif [ "${RUNNER_OS}" = 'Linux' ]; then
echo "name=$(lsb_release -i -s)" >> $GITHUB_OUTPUT
echo "version=$(lsb_release -r -s)" >> $GITHUB_OUTPUT
else
exit 1
fi
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
cache-dependency-path: setup.py

- name: Restore Melting Pot installation
id: restore
uses: actions/cache/restore@v3
with:
path: |
meltingpot/assets
venv
key: install-meltingpot-${{ steps.os-info.outputs.name }}-${{ steps.os-info.outputs.version }}-py${{ inputs.python-version}}-${{ hashFiles('setup.py') }}
restore-keys: |
install-meltingpot-${{ steps.os-info.outputs.name }}-${{ steps.os-info.outputs.version }}-py${{ inputs.python-version }}-
- name: Install Python dependencies
- name: Install Melting Pot
if: steps.restore.outputs.cache-hit != 'true'
shell: bash
run: |
pip install --upgrade pip
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install --editable .[dev]
- name: Save Melting Pot installation
if: steps.restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
meltingpot/assets
venv
key: ${{ steps.restore.outputs.cache-primary-key }}

- name: Activate virtual environment
shell: bash
run: |
source venv/bin/activate
pip list
echo "PATH=${PATH}" >> $GITHUB_ENV

0 comments on commit 9cf7b78

Please sign in to comment.