Skip to content

test multiple

test multiple #421

Workflow file for this run

# Allows to test multiple projects in a matrix.
# - found out which projects to test
# - if any, test them in a matrix
# This runs on:
# - workflow_call: this is used by pr_flow.yml to test multiple projects
# - workflow_dispatch: to manually trigger tests
# - schedule: once a month for all of them
name: test multiple
on:
workflow_call:
inputs:
projects:
description: JSON-like list of projects
type: string
required: true
type:
description: hack
type: string
required: true
workflow_dispatch:
inputs:
all:
description: all the projects
type: boolean
default: false
required: true
projects:
description: comma-separated list
type: string
required: false
schedule:
# 3rd day of the month at 2 (avoiding 1st day that may have more load)
- cron: '0 2 3 * *'
jobs:
inferprojects:
runs-on: 'ubuntu-latest'
timeout-minutes: 10
defaults:
run:
shell: bash -l {0}
outputs:
projects: ${{ steps.set-projects.outputs.projects }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: install deps
# Minimal required deps to run the following script
run: pip install doit pyyaml
- name: infer project list
id: set-projects
run: |
EVENTNAME="${{ github.event_name }}"
ALL="${{ inputs.all }}"
# IMPORTANT: the single quote here matters to preserve the JSON structure of the data
INPUTS='${{ inputs.projects }}'
echo $INPUTS
if [ "${{ inputs.type }}" == "workflow_call" ]; then
# IMPORTANT: same comment as above.
PROJECTS=$INPUTS
elif [ "$EVENTNAME" == "workflow_dispatch" ]; then
if [ "$ALL" == "true" ]; then
PROJECTS=$(doit util_list_project_dir_names | tail -n -1)
else
echo "$INPUTS" > .projects
PROJECTS=$(doit util_list_comma_separated_projects | tail -n -1)
rm .projects
fi
elif [ "$EVENTNAME" == "schedule" ]; then
PROJECTS=$(doit util_list_project_dir_names | tail -n -1)
fi
echo "Projects: $PROJECTS"
echo "PROJECTS=$PROJECTS" >> $GITHUB_OUTPUT
test:
needs: inferprojects
if: needs.inferprojects.outputs.projects != '[]'
name: Test projects
strategy:
fail-fast: false
matrix:
project: ${{ fromJson(needs.inferprojects.outputs.projects) }}
uses: ./.github/workflows/test_one.yml
with:
project: ${{ matrix.project }}
secrets: inherit