Skip to content

Commit

Permalink
Update workflows to use composite actions.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 551926076
Change-Id: Ia7b79bfeba2e7ff579aa125dbf4dc992d37b0eaa
  • Loading branch information
jagapiou authored and Copybara-Service committed Jul 28, 2023
1 parent f6dcd2e commit e0bcbf7
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 70 deletions.
15 changes: 15 additions & 0 deletions .github/actions/install-examples/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: install-examples

runs:
using: composite
steps:
- name: Install Melting Pot
uses: ./.github/actions/install-meltingpot

- name: Install requirements for examples
shell: bash
run: pip -r examples/requirements.txt

- name: Show installed dependencies
shell: bash
run: pip list
22 changes: 22 additions & 0 deletions .github/actions/install-meltingpot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: install-meltingpot

inputs:
python-version:
description: Python version
required: false
default: '3.10'
type: string

runs:
using: composite
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ inputs.python-version }}

- name: Install Python dependencies
shell: bash
run: |
pip install --upgrade pip
pip install --editable .[dev]
45 changes: 45 additions & 0 deletions .github/workflows/pylint-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: pylint-examples

on:
push:
branches:
- main
paths:
- '.github/actions/install-examples/action.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pylint-examples.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
pull_request:
branches:
- main
paths:
- '.github/actions/install-examples/action.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pylint-examples.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

permissions: read-all

jobs:
pylint:
name: Lint examples
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Install examples
uses: ./.github/actions/install-examples

- name: Run PyLint on examples
run: pylint --errors-only examples
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Continuous integration tests.

name: pylint
name: pylint-meltingpot

on:
push:
branches:
- main
paths:
- '.github/workflows/pylint.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pylint-meltingpot.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
pull_request:
branches:
- main
paths:
- '.github/workflows/pylint.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pylint-meltingpot.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
Expand All @@ -31,17 +31,13 @@ jobs:
pylint:
name: Lint Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 30
steps:
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install pylint
- name: Run PyLint
run: pylint --disable=C,W,R --recursive=y meltingpot examples

- name: Install Melting Pot
uses: ./.github/actions/install-meltingpot

- name: Run PyLint on Melting Pot
run: pylint --errors-only meltingpot
45 changes: 45 additions & 0 deletions .github/workflows/pytype-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: pytype-examples

on:
push:
branches:
- main
paths:
- '.github/actions/install-examples/action.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pytype-examples.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-examples/action.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pytype-examples.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

permissions: read-all

jobs:
pytype:
name: Typecheck examples
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Install examples
uses: ./.github/actions/install-examples

- name: Run PyType on examples
run: pytype examples
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Continuous integration tests.

name: pytype
name: pytype-meltingpot

on:
push:
branches:
- main
paths:
- '.github/workflows/pytype.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pytype-meltingpot.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/workflows/pytype.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/pytype-meltingpot.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
Expand All @@ -32,24 +32,12 @@ jobs:
name: Typecheck Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: ${{ github.event_name != 'workflow_dispatch' }}
steps:
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install setuptools pytype

- name: Install Melting Pot
run: pip -vvv install .
uses: ./.github/actions/install-meltingpot

- name: Run PyType on Melting Pot
run: pytype meltingpot
- name: Install example requirements
run: pip -vvv install -r examples/requirements.txt
- name: Run PyType on examples
run: pytype examples
30 changes: 10 additions & 20 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# Continuous integration tests.

name: test-examples

on:
push:
branches:
- main
paths:
- '.github/actions/install-examples/action.yml'
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/test-examples.yml'
- 'examples/**'
- 'meltingpot/**'
- 'setup.py'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-examples.yml'
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/test-examples.yml'
- 'examples/**'
- 'meltingpot/**'
- 'setup.py'
- 'pyproject.toml'
workflow_dispatch:

concurrency:
Expand All @@ -28,30 +32,16 @@ concurrency:
permissions: read-all

jobs:
test-examples:
pytest:
name: Test examples
runs-on: ubuntu-latest
env:
SYSTEM_VERSION_COMPAT: 0 # See https://github.com/actions/setup-python/issues/279.
timeout-minutes: 90
steps:
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install setuptools pytest-xdist
- name: Install Melting Pot
run: |
pip -vvv install .
pip list

- name: Install examples
run: |
pip install -r examples/requirements.txt
pip list
uses: ./.github/actions/install-examples

- name: Test examples
run: pytest examples
24 changes: 10 additions & 14 deletions .github/workflows/test-meltingpot.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Continuous integration tests.

name: test-meltingpot

on:
push:
branches:
- main
paths:
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/test-meltingpot.yml'
- 'meltingpot/**'
- 'setup.py'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-meltingpot/action.yml'
- '.github/workflows/test-meltingpot.yml'
- 'meltingpot/**'
- 'setup.py'
- 'pyproject.toml'
workflow_dispatch:

concurrency:
Expand All @@ -26,7 +28,7 @@ concurrency:
permissions: read-all

jobs:
test-meltingpot:
pytest:
name: Test Melting Pot
runs-on: ${{ matrix.os }}
env:
Expand All @@ -41,17 +43,11 @@ jobs:
python-version:
- '3.10'
steps:
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
- name: Checkout Melting Pot
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Install Melting Pot
uses: ./.github/actions/install-meltingpot
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install setuptools pytest-xdist
- name: Install Melting Pot
run: |
pip -vvv install https://github.com/deepmind/meltingpot/archive/${{ github.sha }}.tar.gz
pip list
- name: Test Melting Pot
run: pytest --pyargs meltingpot
run: pytest meltingpot

0 comments on commit e0bcbf7

Please sign in to comment.