From 31c8c6076e4d4c9ebc3203ff8693fc909180570d Mon Sep 17 00:00:00 2001 From: John Agapiou Date: Tue, 10 Dec 2024 09:06:46 -0800 Subject: [PATCH] Use requirements.txt in workflows PiperOrigin-RevId: 704732399 Change-Id: I535d649eb91d50aa3278d2939e967999499b6f84 --- .github/actions/install-examples/action.yml | 57 ------------------- .../action.yml | 15 ++--- .github/workflows/test-examples.yml | 12 ++-- .github/workflows/test-meltingpot.yml | 8 ++- 4 files changed, 19 insertions(+), 73 deletions(-) delete mode 100644 .github/actions/install-examples/action.yml rename .github/actions/{install-meltingpot => install}/action.yml (83%) diff --git a/.github/actions/install-examples/action.yml b/.github/actions/install-examples/action.yml deleted file mode 100644 index 608fc4fc..00000000 --- a/.github/actions/install-examples/action.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: install-examples - -inputs: - python-version: - description: Python version - required: false - default: '3.11' - type: string - -runs: - using: composite - steps: - - name: Install Melting Pot - id: install-meltingpot - uses: ./.github/actions/install-meltingpot - with: - python-version: ${{ inputs.python-version }} - - - name: Restore Examples installation - id: restore - uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 - with: - path: venv - key: install-examples-${{ steps.install-meltingpot.outputs.key }}-${{ hashFiles('examples/requirements.txt') }} - - - name: Activate venv - shell: bash - run: | - echo "${PWD}/venv/bin" >> $GITHUB_PATH - - - name: Install requirements for examples - if: steps.restore.outputs.cache-hit != 'true' - shell: bash - run: | - pip install -r examples/requirements.txt - - - name: Show installation - shell: bash - run: | - which python - python --version - which pip - pip --version - which pylint - pylint --version - which pytest - pytest --version - which pytype - pytype --version - pip list - - - name: Save Examples installation - if: steps.restore.outputs.cache-hit != 'true' - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 - with: - path: venv - key: ${{ steps.restore.outputs.cache-primary-key }} diff --git a/.github/actions/install-meltingpot/action.yml b/.github/actions/install/action.yml similarity index 83% rename from .github/actions/install-meltingpot/action.yml rename to .github/actions/install/action.yml index 262466f5..9c73ef2b 100644 --- a/.github/actions/install-meltingpot/action.yml +++ b/.github/actions/install/action.yml @@ -1,4 +1,4 @@ -name: install-meltingpot +name: install inputs: python-version: @@ -34,16 +34,16 @@ runs: else exit 1 fi - echo "key=${name}-${version}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('setup.py') }}" >> $GITHUB_OUTPUT + echo "key=${name}-${version}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}" >> $GITHUB_OUTPUT - - name: Restore Melting Pot installation + - name: Restore installation id: restore uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: | meltingpot/assets venv - key: install-meltingpot-${{ steps.cache-key.outputs.key }} + key: install-${{ steps.cache-key.outputs.key }} - name: Create venv if: steps.restore.outputs.cache-hit != 'true' @@ -56,11 +56,12 @@ runs: run: | echo "${PWD}/venv/bin" >> $GITHUB_PATH - - name: Install Melting Pot + - name: Install if: steps.restore.outputs.cache-hit != 'true' shell: bash run: | - pip install --editable .[dev] + pip install --require-virtualenv --require-hashes -r requirements.txt + pip install --require-virtualenv --no-deps --no-index --no-build-isolation --editable . - name: Show installation shell: bash @@ -77,7 +78,7 @@ runs: pytype --version pip list - - name: Save Melting Pot installation + - name: Save installation if: steps.restore.outputs.cache-hit != 'true' uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index cd30df89..36a8c878 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -5,25 +5,25 @@ on: branches: - main paths: - - '.github/actions/install-examples/action.yml' - - '.github/actions/install-meltingpot/action.yml' + - '.github/actions/install/action.yml' - '.github/workflows/test-examples.yml' - '.pylintrc' - 'examples/**' - 'meltingpot/**' - 'pyproject.toml' + - 'requirements.txt' - 'setup.py' pull_request: branches: - main paths: - - '.github/actions/install-examples.yml' - - '.github/actions/install-meltingpot.yml' + - '.github/actions/install/action.yml' - '.github/workflows/test-examples.yml' - '.pylintrc' - 'examples/**' - 'meltingpot/**' - 'pyproject.toml' + - 'requirements.txt' - 'setup.py' workflow_dispatch: @@ -42,8 +42,8 @@ jobs: - name: Checkout Melting Pot uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - name: Install examples - uses: ./.github/actions/install-examples + - name: Install Melting Pot + uses: ./.github/actions/install - name: Test examples run: pytest examples diff --git a/.github/workflows/test-meltingpot.yml b/.github/workflows/test-meltingpot.yml index 1e3a817f..03ed1435 100644 --- a/.github/workflows/test-meltingpot.yml +++ b/.github/workflows/test-meltingpot.yml @@ -5,21 +5,23 @@ on: branches: - main paths: - - '.github/actions/install-meltingpot/action.yml' + - '.github/actions/install/action.yml' - '.github/workflows/test-meltingpot.yml' - '.pylintrc' - 'meltingpot/**' - 'pyproject.toml' + - 'requirements.txt' - 'setup.py' pull_request: branches: - main paths: - - '.github/actions/install-meltingpot/action.yml' + - '.github/actions/install/action.yml' - '.github/workflows/test-meltingpot.yml' - '.pylintrc' - 'meltingpot/**' - 'pyproject.toml' + - 'requirements.txt' - 'setup.py' workflow_dispatch: @@ -38,7 +40,7 @@ jobs: uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Install Melting Pot - uses: ./.github/actions/install-meltingpot + uses: ./.github/actions/install - name: Test Melting Pot run: pytest meltingpot