Skip to content

Commit

Permalink
Add GHA CI to subdirs and sync with main CI (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolecheetham authored Dec 9, 2024
1 parent 8d1a018 commit 3e743ec
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 0 deletions.
34 changes: 34 additions & 0 deletions drake_ament_cmake_installed/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: MIT-0

---
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * *'
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
ros_humble_ament_cmake_installed:
name: ros 2 humble
runs-on: ubuntu-latest
container: ubuntu:jammy
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
working-directory: drake_ament_cmake_installed
run: .github/ros_humble_setup
shell: bash
- name: ament_cmake_installed build and test
working-directory: drake_ament_cmake_installed
run: .github/ci_build_test
shell: bash
38 changes: 38 additions & 0 deletions drake_bazel_download/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: MIT-0

---
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * *'
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
ubuntu_jammy_bazel_download:
name: ubuntu 22.04 jammy
runs-on: ubuntu-latest
container: ubuntu:jammy
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
working-directory: drake_bazel_download
run: .github/ubuntu_setup
shell: bash
- name: install_bazelisk
working-directory: drake_bazel_download
run: setup/install_bazelisk
shell: bash
- name: bazel_download build and test
working-directory: drake_bazel_download
run: .github/ci_build_test
shell: bash
34 changes: 34 additions & 0 deletions drake_catkin_installed/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: MIT-0

---
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * *'
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
ubuntu_jammy_catkin_installed:
name: ubuntu 22.04 jammy
runs-on: ubuntu-latest
container: ubuntu:jammy
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
working-directory: drake_catkin_installed
run: .github/ubuntu_setup
shell: bash
- name: catkin_installed build and test
working-directory: drake_catkin_installed
run: .github/ci_build_test
shell: bash
59 changes: 59 additions & 0 deletions drake_cmake_installed/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-License-Identifier: MIT-0

---
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * *'
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
macos_sonoma_arm_cmake_installed:
name: macos sonoma 14 arm
runs-on: macos-14
steps:
- name: checkout
uses: actions/checkout@v4
# See issue https://github.com/actions/setup-python/issues/577. There is
# some kind of environment conflict between the symlinks found in the
# GitHub Actions runner and `brew upgrade python` where `brew` detects and
# refuses to overwrite symlinks. The cause for our runs is not clear,
# we do not use that action, but if that issue is closed this section
# can be removed.
- name: sanitize GHA / brew python environment
run: |
# Remove the symlinks that cause issues.
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
sudo rm -rf /Library/Frameworks/Python.framework/
- name: setup
working-directory: drake_cmake_installed
run: setup/install_prereqs
shell: zsh -efuo pipefail {0}
- name: cmake_installed build and test
working-directory: drake_cmake_installed
run: .github/ci_build_test
shell: zsh -efuo pipefail {0}
ubuntu_jammy_cmake_installed:
name: ubuntu 22.04 jammy
runs-on: ubuntu-latest
container: ubuntu:jammy
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
working-directory: drake_cmake_installed
run: .github/ubuntu_setup
shell: bash
- name: cmake_installed build and test
working-directory: drake_cmake_installed
run: .github/ci_build_test
shell: bash
34 changes: 34 additions & 0 deletions drake_cmake_installed_apt/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: MIT-0

---
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * *'
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
ubuntu_jammy_cmake_installed_apt:
name: ubuntu 22.04 jammy
runs-on: ubuntu-latest
container: ubuntu:jammy
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
working-directory: drake_cmake_installed_apt
run: .github/ubuntu_apt_setup
shell: bash
- name: cmake_installed_apt build and test
working-directory: drake_cmake_installed_apt
run: .github/ci_build_test
shell: bash
40 changes: 40 additions & 0 deletions private/test/file_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import logging
import os
import re
import sys
from pathlib import Path

Expand Down Expand Up @@ -66,6 +67,14 @@
),
)

GITHUB_WORKFLOWS = (
"ament_cmake_installed",
"bazel_download",
"catkin_installed",
"cmake_installed",
"cmake_installed_apt",
)

found_errors = False


Expand Down Expand Up @@ -110,11 +119,42 @@ def check(index: int, paths: tuple[str]):
error(f"{prologue} do not all match")


def gha_workflow_check(workflow_name: str):
"""Enforces the subdir_ci to have the contents of root_ci up until
it reaches the jobs: line plus the content in the subdir_ workflow
after jobs: is mentioned.
"""
root_ci_path = ".github/workflows/ci.yml"
subdir_workflow_path = f".github/workflows/{workflow_name}.yml"
subdir_ci_path = f"drake_{workflow_name}/.github/workflows/ci.yml"
sep = "\njobs:\n"

# Read all files into memory and check sep occurs once in each file.
content = {}
for path in [root_ci_path, subdir_workflow_path, subdir_ci_path]:
try:
with open(path, "r", encoding="utf-8") as f:
content[path] = f.read()
if len(re.findall(sep, content[path])) != 1:
error(f"{workflow_name}'s {path} contents are invalid")
except IOError:
error(f"Missing {workflow_name} file {path}")

# Workflow check.
events = content[root_ci_path].split(sep)[0]
ex_jobs = sep + content[subdir_workflow_path].split(sep)[1]

if events + ex_jobs != content[subdir_ci_path]:
error(f"{workflow_name} subdir CI does not match")


def main():
logging.basicConfig(format="%(levelname)s: %(message)s")
os.chdir(Path(__file__).parent.parent.parent)
for i, paths in enumerate(COPIES):
check(i, paths)
for workflow in GITHUB_WORKFLOWS:
gha_workflow_check(workflow)
sys.exit(1 if found_errors else 0)


Expand Down

0 comments on commit 3e743ec

Please sign in to comment.