Skip to content

Commit

Permalink
Add workflow to make sure generated CI file is up to date (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue authored Jul 10, 2024
1 parent fcf7881 commit abb1923
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/check_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check Generated CI

on:
pull_request:
push:
branches-ignore:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
update:
name: "Update"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install jinja
run: python -m pip install jinja2
- name: Generate CI
run: .github/workflows/gen_ci.py
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
run: git diff HEAD > ci-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v4
with:
name: ci-fixes
path: ci-fixes.patch
if: ${{ failure() }}
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
- "**.md"

jobs:

build-sysroot-roborio-academic-cortexa9_vfpv3:
name: Build sysroot for roborio-academic-cortexa9_vfpv3
runs-on: ubuntu-latest
Expand Down Expand Up @@ -100,21 +99,18 @@ jobs:
name: raspi-bullseye-armhf-sysroot
path: output/*


build-platform-utils-roborio-academic-cortexa9_vfpv3:
needs: build-sysroot-roborio-academic-cortexa9_vfpv3
strategy:
matrix:
host:
[

{
os-cfg: linux_x86_64,
runner: ubuntu-latest,
container: "docker.io/wpilib/opensdk-ubuntu:20.04",
testable: true,
},

{
os-cfg: windows_x86_64,
runner: ubuntu-latest,
Expand Down Expand Up @@ -185,14 +181,12 @@ jobs:
matrix:
host:
[

{
os-cfg: linux_x86_64,
runner: ubuntu-latest,
container: "docker.io/wpilib/opensdk-ubuntu:20.04",
testable: true,
},

{
os-cfg: windows_x86_64,
runner: ubuntu-latest,
Expand Down Expand Up @@ -263,7 +257,6 @@ jobs:
matrix:
host:
[

{
os-cfg: windows_x86_64,
runner: ubuntu-latest,
Expand Down Expand Up @@ -334,7 +327,6 @@ jobs:
matrix:
host:
[

{
os-cfg: windows_x86_64,
runner: ubuntu-latest,
Expand Down Expand Up @@ -399,7 +391,6 @@ jobs:
name: raspi-bullseye-armhf-${{matrix.host.os-cfg }}
path: output/*


build-platform-utils-raspi-bullseye-armhf-linux-x86_64:
needs: [build-sysroot-raspi-bullseye-armhf]
name: Build raspi-bullseye-armhf for linux_x86_64
Expand Down Expand Up @@ -455,7 +446,6 @@ jobs:
cd raspi-bullseye
rm -rf /usr/aarch64-linux-gnu /usr/arm-linux-gnueabihf
cp -Rp * /usr
- name: Build
run: |
make frontend
Expand Down Expand Up @@ -520,7 +510,6 @@ jobs:
cd bullseye
rm -rf /usr/aarch64-linux-gnu /usr/arm-linux-gnueabihf
cp -Rp * /usr
- name: Build
run: |
make frontend
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "**.md"

jobs:
{% for target in targets.sysroots %}
{%- for target in targets.sysroots %}
build-sysroot-{{ target.os }}-{{ target.port }}:
name: Build sysroot for {{ target.os }}-{{ target.port }}
runs-on: ubuntu-latest
Expand All @@ -34,21 +34,21 @@ jobs:
name: {{ target.os }}-{{ target.port }}-sysroot
path: output/*
{% endfor %}
{% for target in targets.single_stage %}
{%- for target in targets.single_stage %}
build-platform-utils-{{ target.os }}-{{ target.port }}:
needs: build-sysroot-{{ target.os }}-{{ target.port }}
strategy:
matrix:
host:
[
{% if not ((target.os == "bullseye" and target.port == "arm64") or target.os == "raspi-bullseye") %}
{%- if not ((target.os == "bullseye" and target.port == "arm64") or target.os == "raspi-bullseye") %}
{
os-cfg: linux_x86_64,
runner: ubuntu-latest,
container: "docker.io/wpilib/opensdk-ubuntu:20.04",
testable: true,
},
{% endif %}
{%- endif %}
{
os-cfg: windows_x86_64,
runner: ubuntu-latest,
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
name: {{ target.os }}-{{ target.port }}-${{ '{{' }}matrix.host.os-cfg }}
path: output/*
{% endfor %}
{% for task in targets.two_stage %}
{%- for task in targets.two_stage %}
build-platform-utils-{{ task.target.os }}-{{ task.target.port }}-{{ task.host.os }}-{{ task.host.port }}:
needs: [build-sysroot-{{ task.target.os }}-{{ task.target.port }}{% if task.host.os != "linux" or task.host.port != "x86_64" %}, build-platform-utils-{{ task.host.os }}-{{ task.host.port }}-linux-x86_64{% endif %}]
name: Build {{ task.target.os }}-{{ task.target.port }} for {{ task.host.os }}_{{ task.host.port }}
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
cd {{ task.host.os }}
rm -rf /usr/aarch64-linux-gnu /usr/arm-linux-gnueabihf
cp -Rp * /usr
{% endif %}
{%- endif %}
- name: Build
run: |
make frontend
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/gen_ci.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python

from os import path
from jinja2 import Environment, FileSystemLoader
import json

with open(f"targets.json") as f:
workdir = path.dirname(__file__)
with open(path.join(workdir, "targets.json")) as f:
targets = json.load(f)

env = Environment(loader=FileSystemLoader(f"."), autoescape=False)
env = Environment(loader=FileSystemLoader(workdir), autoescape=False, keep_trailing_newline=True)
template = env.get_template("ci.yml.jinja")
contents = template.render(targets=targets)
with open("ci.yml", "w") as f:
with open(path.join(workdir, "ci.yml"), "w") as f:
f.write(contents)

0 comments on commit abb1923

Please sign in to comment.