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 8e92f8e
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 140 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: |
which python
pip list
67 changes: 67 additions & 0 deletions .github/actions/install-meltingpot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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: Restore install cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: |
assets
meltingpot/assets
venv
key: install-meltingpot-${{ runner.name }}-py${{ inputs.python-version}}-${{ hashFiles('setup.py') }}
restore-keys:
install-meltingpot-${{ runner.name }}-py${{ inputs.python-version }}

- name: Install Python dependencies
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
pip install --upgrade pip
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -e .[dev]
- name: Save install cache
uses: actions/cache/save@v3
with:
path: |
assets
venv
meltingpot/assets
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

- name: Show installed dependencies
shell: bash
run: |
source venv/bin/activate
which python
which pytest
which pylint
which pytype
which isort
pip list
- name: Debug
shell: bash
run: |
which python
which pytest
which pylint
which pytype
which isort
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/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@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/action.yml'
- '.github/workflows/pylint-meltingpot.yml'
- '.pylintrc'
- 'examples/**'
- 'meltingpot/**'
pull_request:
branches:
- main
paths:
- '.github/actions/install-meltingpot/action.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/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@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/action.yml'
- '.github/workflows/pytype-meltingpot.yml'
- 'examples/**'
- 'meltingpot/**'
- 'pyproject.toml'
pull_request:
branches:
- main
paths:
- '.github/actions/install-meltingpot/action.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.

Loading

0 comments on commit 8e92f8e

Please sign in to comment.