1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00

Add user dispatchable workflow definition.

This adds a event trigger for 'workflow_dispatch' so that a user can
trigger, via the web UI, a build/test for a subset of implementations.
This commit is contained in:
Joel Martin 2021-04-21 14:23:30 -05:00
parent 71412ebdd8
commit cbb8b57319
2 changed files with 28 additions and 6 deletions

View File

@ -1,6 +1,14 @@
name: Build and Test
on: [push, pull_request]
on:
push: {}
pull_request: {}
workflow_dispatch:
inputs:
impls:
description: 'Space separated list of impls to test (or all)'
required: true
default: 'all'
jobs:
get-matrix:
@ -13,9 +21,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- id: files
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: kanaka/get-changed-files@v1
- id: get-matrix-step
run: ./get-ci-matrix.py ${{ steps.files.outputs.all }}
run: |
export OVERRIDE_IMPLS="${{ github.event.inputs.impls }}" # "
echo "OVERRIDE_IMPLS: ${OVERRIDE_IMPLS}"
./get-ci-matrix.py ${{ steps.files.outputs.all }}
linux:
needs: get-matrix

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import json
import os
import re
import sys
import yaml
@ -9,6 +10,8 @@ IMPLS_FILE = "IMPLS.yml"
RE_IGNORE = re.compile(r'(^LICENSE$|^README.md$|^docs/|^process/)')
RE_IMPL = re.compile(r'^impls/(?!lib|tests)([^/]*)/')
OVERRIDE_IMPLS = os.environ.get('OVERRIDE_IMPLS', '').split()
def impl_text(impl):
s = "IMPL=%s" % impl['IMPL']
for k, v in impl.items():
@ -22,15 +25,22 @@ code_changes = set([c for c in all_changes if not RE_IGNORE.search(c)])
# actual changes to implementations
impl_changes = set([c for c in all_changes if RE_IMPL.search(c)])
# names of changed implementations
changed_impls = set([RE_IMPL.search(c).groups()[0] for c in impl_changes])
run_impls = set([RE_IMPL.search(c).groups()[0] for c in impl_changes])
do_full = (len(code_changes) != len(impl_changes))
# If we have non-implementation code changes then we will add all
# implementations to the test matrix
do_full = (len(code_changes) != len(impl_changes))
if OVERRIDE_IMPLS:
run_impls = OVERRIDE_IMPLS
if 'all' in OVERRIDE_IMPLS:
do_full = True
print("OVERRIDE_IMPLS: %s" % OVERRIDE_IMPLS)
print("code_changes: %s (%d)" % (code_changes, len(code_changes)))
print("impl_changes: %s (%d)" % (impl_changes, len(impl_changes)))
print("changed_impls: %s (%d)" % (changed_impls, len(changed_impls)))
print("run_impls: %s (%d)" % (run_impls, len(run_impls)))
print("do_full: %s" % do_full)
# Load the full implementation description file
@ -40,7 +50,7 @@ all_impls = yaml.safe_load(open(IMPLS_FILE))
linux_impls = []
macos_impls = []
for impl in all_impls['IMPL']:
if do_full or impl['IMPL'] in changed_impls:
if do_full or impl['IMPL'] in run_impls:
if 'OS' in impl and impl['OS'] == 'macos':
macos_impls.append(impl_text(impl))
else: