Skip to content

Commit

Permalink
Add workflow to run all the distros
Browse files Browse the repository at this point in the history
  • Loading branch information
rluzuriaga authored Aug 15, 2024
1 parent 918ca3c commit b74eccb
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/run_all_distros.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Run all distros - FOG install tests

on:
workflow_dispatch:

defaults:
run:
shell: bash

permissions:
actions: write
contents: write

jobs:
get-all-distros-matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set matrix of distros
id: set-matrix
run: |
cd .github/workflows/
json_array=$(jq -n '[]')
for distro_file in $(ls distro_*); do
json_array=$(echo "$json_array" | jq --arg distro "$distro_file" '. + [$distro]')
done
matrix=$(echo "{\"distros\": $json_array}" | jq -c .)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
run-distro:
needs: get-all-distros-matrix
runs-on: ubuntu-22.04
strategy:
matrix:
${{ fromJson(needs.get-all-distros-matrix.outputs.matrix) }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run all distros
run: gh workflow run ${{ matrix.distros }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check-if-successful:
needs: [get-all-distros-matrix, run-distro]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.get-all-distros-matrix.outputs.matrix) }}

steps:
- name: Wait a minute for the runs to start
run: sleep 60

- name: Get run IDs
run: |
run_id=$(gh run list --repo ${{ github.repository }} --workflow ${{ matrix.distros }} --json databaseId --limit 1 | jq -r '.[0].databaseId')
echo "RUN_ID=$run_id" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check if distro workflow passed or failed
run: |
run_status=""
while [[ $run_status != "success" && $run_status != "failure" ]]; do
sleep 15
run_status=$(gh run view --repo ${{ github.repository }} ${{ env.RUN_ID }} --exit-status --json conclusion | jq -r '.conclusion')
done
if [[ $run_status == "failure" ]]; then
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b74eccb

Please sign in to comment.