Skip to content

./actions

./actions #4

Workflow file for this run

# Copyright (c) 2024 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python Actions
on:
workflow_call:
inputs:
base-package:
description: >
The names of the base Python package.
Will be the one uses for coverage, plyint and mypy
required: true
type: string
dependencies:
description: >
The list of SpiNNaker dependencies to check out. Space-separated
required: true
type: string
test_directories:
description: >
The list of directories to run pytest on. Space-seperated
required: true
type: string
flake8-packages:
description: The names of the Python packages to run flake8 on.
required: true
type: string
check_prereleases:
description: Flag to say if prereleases python versions should be checked
required: false
type: string
default: 'true'
cfg_file:
description: >
Name of the cfg file to be created
excluding the ~./ start and .cfg end
The default string will skip the create cfg stage
A value of ~/.spynnaker.cfg will also trigger setup PyNN
required: false
type: string
default: ''
env:
PRERELEASE: "3.13"
jobs:
validate:
# Everything as checks but do validation steps first
strategy:
matrix:
include:
- runner: ubuntu-latest
python-version: "3.12"
checks: 'validate'
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v4
- name: Install pip, etc
uses: .actions/python-tools
- name: Install mypy
run: pip install mypy
- name: Install Spinnaker Dependencies
uses: ./actions/install-spinn-deps
with:
repositories: ${{ inputs.dependencies }}
install: true
- name: Run Install
uses: ./actions/run-install
- name: Setup PyNN
if: ${{ inputs.cfg_file == 'spynnaker' }}
uses: ./actions/pynn-setup
- name: Create a spynnaker.cfg
if: ${{ inputs.cfg_file != '' }}
uses: ./actions/configure-spynnaker
with:
board-address: spinn-4.cs.man.ac.
cfg_file: ${{ inputs.cfg_file }}
- name: Run rat copyright enforcement
uses: .actions/check-copyrights
with:
config_file: rat_asl20.xml
- name: Build documentation with sphinx
uses: ./actions/sphinx
with:
directory: doc/source
- name: Validate CITATION.cff
uses: dieghernan/cff-validator@main
- name: Lint with flake8
run: flake8 ${{ inputs.flake8-packages }}
- name: Lint with pylint
uses: .actions/pylint
with:
package: ${{ inputs.base-package }}
exitcheck: 31 # Action fails on any message
language: en_GB
rcfile: global_strict
- name: Lint with mypy
run: mypy ${{ inputs.base-package }}
- name: Test with pytest
uses: ./actions/pytest
with:
tests: ${{ inputs.test_directories }}
coverage: ${{ matrix.coverage == 'coverage' }}
cover-packages: ${{ inputs.base-package }}
coveralls-token: ${{ secrets.GITHUB_TOKEN }}
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
checks:
# Everything as tests but do validation steps first
strategy:
matrix:
include:
# prereleases
- runner: ubuntu-24.04
python-version: "3.13"
- runner: ubuntu-latest
python-version: "3.11"
coverage: 'coverage'
- runner: ubuntu-latest
python-version: "3.10"
- runner: ubuntu-22.04
python-version: 3.9
- runner: ubuntu-20.04
python-version: 3.8
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Set up Python ${{ matrix.python-version }}
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.python-version == env.PRERELEASE }}
- name: Checkout
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: actions/checkout@v4
- name: Install pip, etc
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: ./actions/python-tools
- name: Install mypy
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
run: pip install mypy
- name: Install Spinnaker Dependencies
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: ./actions/install-spinn-deps
with:
repositories: ${{ inputs.dependencies }}
install: true
- name: Run Install
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: ./actions/run-install
- name: Setup PyNN
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true') && inputs.cfg_file == 'spynnaker' }}
uses: ./actions/pynn-setup
- name: Create a spynnaker.cfg
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true') && inputs.cfg_file != '' }}
uses: ./actions/configure-spynnaker
with:
board-address: spinn-4.cs.man.ac.
cfg_file: ${{ inputs.cfg_file }}
- name: Lint with flake8
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
run: flake8 ${{ inputs.flake8-packages }}
- name: Lint with pylint
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: ./actions/pylint
with:
package: ${{ inputs.base-package }}
exitcheck: 31 # Action fails on any message
language: en_GB
rcfile: global_strict
- name: Lint with mypy
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
run: mypy ${{ inputs.base-package }}
- name: Test with pytest
if: ${{ matrix.python-version != env.PRERELEASE || inputs.check_prereleases == 'true' }}
uses: ./actions/pytest
with:
tests: ${{ inputs.test_directories }}
coverage: ${{ matrix.coverage == 'coverage' }}
cover-packages: ${{ inputs.base-package }}
coveralls-token: ${{ secrets.GITHUB_TOKEN }}
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
tests:
strategy:
matrix:
include:
- runner: windows-latest
python-version: "3.12"
checks: 'tests'
- runner: windows-2019
python-version: 3.8
checks: 'tests'
- runner: macos-latest
python-version: "3.12"
checks: 'tests'
- runner: macos-11
python-version: 3.8
checks: 'tests'
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v4
- name: Install Spinnaker Dependencies
uses: .actions/install-spinn-deps
with:
repositories: ${{ inputs.dependencies }}
install: true
- name: Run Install
uses: .actions/run-install
- name: Setup PyNN
if: ${{ inputs.cfg_file == 'spynnaker' }}
uses: ./actions/pynn-setup
- name: Create a spynnaker.cfg
if: ${{ inputs.cfg_file != '' }}
uses: ./actions/configure-spynnaker
with:
board-address: spinn-4.cs.man.ac.
cfg_file: ${{ inputs.cfg_file }}
- name: Test with pytest
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
run: pytest ${{ inputs.test_directories }}