Skip to content

Commit

Permalink
Update workflows to use composite actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jagapiou committed Jul 28, 2023
1 parent b380cb1 commit 7be3027
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 140 deletions.
14 changes: 14 additions & 0 deletions .github/actions/install-examples/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
run: pip install matplotlib
- name: Show installed dependencies
shell: bash
run: pip list
39 changes: 39 additions & 0 deletions .github/actions/install-meltingpot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: install-meltingpot

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

runs:
using: composite
steps:
- name: Set up Python
id: setup
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Show Cache
shell: bash
run: |
echo "cache-hit=${{ steps.setup.outputs.cache-hit }}"
pip cache list
- name: Show contents
shell: bash
run: ls -la
- name: Show mp contents
shell: bash
run: ls -la meltingpot
- name: Install Python dependencies
if: ! steps.setup.outputs.cache-hit
shell: bash
run: |
pip install -e .[dev]
pip cache list
- name: Show installed dependencies
shell: bash
run: pip list
43 changes: 43 additions & 0 deletions .github/workflows/pylint-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: pylint-examples

on:
push:
branches:
- main
paths:
- '.github/actions/install-examples.yml'
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pylint-examples.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
pull_request:
branches:
- main
paths:
- '.github/actions/install-examples.yml'
- '.github/actions/install-meltingpot.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 Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout Melting Pot
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Install examples
uses: ./.github/actions/install-examples
- name: Run PyLint on examples
run: pylint --errors-only examples
41 changes: 41 additions & 0 deletions .github/workflows/pylint-meltingpot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: pylint-meltingpot

on:
push:
branches:
- main
paths:
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pylint-meltingpot.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
pull_request:
branches:
- main
paths:
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pylint-meltingpot.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 Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Melting Pot
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Install Melting Pot
uses: ./.github/actions/install-meltingpot
- name: Run PyLint on Melting Pot
run: pylint --errors-only meltingpot
47 changes: 0 additions & 47 deletions .github/workflows/pylint.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/pytype-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: pytype-examples

on:
push:
branches:
- main
paths:
- '.github/actions/install-examples.yml'
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pytype-examples.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-examples.yml'
- '.github/actions/install-meltingpot.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 Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Melting Pot
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Install examples
uses: ./.github/actions/install-examples
- name: Run PyType on examples
run: pytype examples
41 changes: 41 additions & 0 deletions .github/workflows/pytype-meltingpot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: pytype-meltingpot

on:
push:
branches:
- main
paths:
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pytype-meltingpot.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-meltingpot.yml'
- '.github/workflows/pytype-meltingpot.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 Melting Pot
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Melting Pot
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Install Melting Pot
uses: ./.github/actions/install-meltingpot
- name: Run PyType on Melting Pot
run: pytype meltingpot
55 changes: 0 additions & 55 deletions .github/workflows/pytype.yml

This file was deleted.

28 changes: 8 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.yml'
- '.github/actions/install-meltingpot.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 @@ -31,27 +35,11 @@ jobs:
test-examples:
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
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Install examples
run: |
pip install -r examples/requirements.txt
pip list
uses: ./.github/actions/install-examples
- name: Test examples
run: pytest examples
Loading

0 comments on commit 7be3027

Please sign in to comment.