Skip to content

Commit

Permalink
Add CI to Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryNessCTR committed Jan 10, 2023
1 parent 1888905 commit 16e957a
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 0 deletions.
253 changes: 253 additions & 0 deletions .github/workflows/build-all-parallel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@

# This is a faster workflow that parallelizes the jobs in a matrix so
# we can get faster results than waiting for the standard build_all_frc_projects
# powershell script

name: Build all FRC Projects

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

strategy:
fail-fast: false
matrix:
include:
- project-name: 'CANCoder'
directory: 'C++ General/CANCoder'
- project-name: 'CANdle'
directory: 'C++ General/CANdle'
- project-name: 'CANdle-MultiAnimation'
directory: 'C++ General/CANdle-MultiAnimation'
- project-name: 'CANifier Demo'
directory: 'C++ General/CANifier Demo'
- project-name: 'CANifier Quadrature'
directory: 'C++ General/CANifier Quadrature'
- project-name: 'Config All'
directory: 'C++ General/Config All'
- project-name: 'Current Limit'
directory: 'C++ General/Current Limit'
- project-name: 'CurrentClosedLoop'
directory: 'C++ General/CurrentClosedLoop'
- project-name: 'DifferentialDrive'
directory: 'C++ General/DifferentialDrive'
- project-name: 'GetParameter'
directory: 'C++ General/GetParameter'
- project-name: 'LimitSwitch'
directory: 'C++ General/LimitSwitch'
- project-name: 'Mecanum'
directory: 'C++ General/Mecanum'
- project-name: 'MotionMagic'
directory: 'C++ General/MotionMagic'
- project-name: 'MotionProfile'
directory: 'C++ General/MotionProfile'
- project-name: 'MotionProfileArc_Simple'
directory: 'C++ General/MotionProfileArc_Simple'
- project-name: 'MotionProfile_Simple'
directory: 'C++ General/MotionProfile_Simple'
- project-name: 'MotorSafety'
directory: 'C++ General/MotorSafety'
- project-name: 'Orchestra'
directory: 'C++ General/Orchestra'
- project-name: 'PigeonSmartDash'
directory: 'C++ General/PigeonSmartDash'
- project-name: 'PigeonStraight'
directory: 'C++ General/PigeonStraight'
- project-name: 'PositionClosedLoop'
directory: 'C++ General/PositionClosedLoop'
- project-name: 'RemoteClosedLoop'
directory: 'C++ General/RemoteClosedLoop'
- project-name: 'RemoteLimitSwitch'
directory: 'C++ General/RemoteLimitSwitch'
- project-name: 'RemoteSoftLimit'
directory: 'C++ General/RemoteSoftLimit'
- project-name: 'SetSensorPosition'
directory: 'C++ General/SetSensorPosition'
- project-name: 'Tachometer'
directory: 'C++ General/Tachometer'
- project-name: 'VelocityClosedLoop'
directory: 'C++ General/VelocityClosedLoop'
- project-name: 'DifferentialDrive'
directory: 'C++ Talon FX (Falcon 500)/DifferentialDrive'
- project-name: 'MotionMagic'
directory: 'C++ Talon FX (Falcon 500)/MotionMagic'
- project-name: 'MotionProfileArc_Simple'
directory: 'C++ Talon FX (Falcon 500)/MotionProfileArc_Simple'
- project-name: 'MotionProfile_Simple'
directory: 'C++ Talon FX (Falcon 500)/MotionProfile_Simple'
- project-name: 'Music-Orchestra'
directory: 'C++ Talon FX (Falcon 500)/Music-Orchestra'
- project-name: 'Music-Tone'
directory: 'C++ Talon FX (Falcon 500)/Music-Tone'
- project-name: 'ArcadeDrive_ArbFeedForward'
directory: 'Java General/ArcadeDrive_ArbFeedForward'
- project-name: 'BrakeCoast'
directory: 'Java General/BrakeCoast'
- project-name: 'CANCoder'
directory: 'Java General/CANCoder'
- project-name: 'CANdle'
directory: 'Java General/CANdle'
- project-name: 'CANdle MultiAnimation'
directory: 'Java General/CANdle MultiAnimation'
- project-name: 'CANifier Demo'
directory: 'Java General/CANifier Demo'
- project-name: 'CANifier Quadrature'
directory: 'Java General/CANifier Quadrature'
- project-name: 'Config All'
directory: 'Java General/Config All'
- project-name: 'Current Limit'
directory: 'Java General/Current Limit'
- project-name: 'CurrentClosedLoop'
directory: 'Java General/CurrentClosedLoop'
- project-name: 'DifferentialDrive'
directory: 'Java General/DifferentialDrive'
- project-name: 'DifferentialDrive_Simulation'
directory: 'Java General/DifferentialDrive_Simulation'
- project-name: 'DriveStraight_AuxPigeon'
directory: 'Java General/DriveStraight_AuxPigeon'
- project-name: 'DriveStraight_AuxQuadrature'
directory: 'Java General/DriveStraight_AuxQuadrature'
- project-name: 'DriveStraight_Pigeon'
directory: 'Java General/DriveStraight_Pigeon'
- project-name: 'GetParameter'
directory: 'Java General/GetParameter'
- project-name: 'MagEncoder_Absolute'
directory: 'Java General/MagEncoder_Absolute'
- project-name: 'MagEncoder_Relative'
directory: 'Java General/MagEncoder_Relative'
- project-name: 'MotionMagic'
directory: 'Java General/MotionMagic'
- project-name: 'MotionMagic_ArbFeedForward'
directory: 'Java General/MotionMagic_ArbFeedForward'
- project-name: 'MotionMagic_AuxStraightPigeon'
directory: 'Java General/MotionMagic_AuxStraightPigeon'
- project-name: 'MotionMagic_AuxStraightQuadrature'
directory: 'Java General/MotionMagic_AuxStraightQuadrature'
- project-name: 'MotionMagic_TalonFX_AuxStraightPigeon'
directory: 'Java General/MotionMagic_TalonFX_AuxStraightPigeon'
- project-name: 'MotionProfile'
directory: 'Java General/MotionProfile'
- project-name: 'MotionProfileArc_Simple'
directory: 'Java General/MotionProfileArc_Simple'
- project-name: 'MotionProfile_AuxMotionProfileArc'
directory: 'Java General/MotionProfile_AuxMotionProfileArc'
- project-name: 'MotionProfile_Simple'
directory: 'Java General/MotionProfile_Simple'
- project-name: 'MotorSafety'
directory: 'Java General/MotorSafety'
- project-name: 'Pigeon2'
directory: 'Java General/Pigeon2'
- project-name: 'PigeonIMU'
directory: 'Java General/PigeonIMU'
- project-name: 'PositionClosedLoop'
directory: 'Java General/PositionClosedLoop'
- project-name: 'PositionClosedLoop_AuxFeedForward'
directory: 'Java General/PositionClosedLoop_AuxFeedForward'
- project-name: 'PositionClosedLoop_AuxStraightPigeon'
directory: 'Java General/PositionClosedLoop_AuxStraightPigeon'
- project-name: 'PositionClosedLoop_AuxStraightQuadrature'
directory: 'Java General/PositionClosedLoop_AuxStraightQuadrature'
- project-name: 'RemoteLimitSwitch'
directory: 'Java General/RemoteLimitSwitch'
- project-name: 'RemoteSoftLimit'
directory: 'Java General/RemoteSoftLimit'
- project-name: 'SixTalonArcadeDrive'
directory: 'Java General/SixTalonArcadeDrive'
- project-name: 'Tachometer'
directory: 'Java General/Tachometer'
- project-name: 'VelocityClosedLoop'
directory: 'Java General/VelocityClosedLoop'
- project-name: 'VelocityClosedLoop_ArbFeedForward'
directory: 'Java General/VelocityClosedLoop_ArbFeedForward'
- project-name: 'VelocityClosedLoop_AuxStraightPigeon'
directory: 'Java General/VelocityClosedLoop_AuxStraightPigeon'
- project-name: 'VelocityClosedLoop_AuxStraightQuadrature'
directory: 'Java General/VelocityClosedLoop_AuxStraightQuadrature'
- project-name: 'ArcadeDrive_ArbFeedForward'
directory: 'Java Talon FX (Falcon 500)/ArcadeDrive_ArbFeedForward'
- project-name: 'Current Limit'
directory: 'Java Talon FX (Falcon 500)/Current Limit'
- project-name: 'DifferentialDrive'
directory: 'Java Talon FX (Falcon 500)/DifferentialDrive'
- project-name: 'DifferentialDrive_Simulation'
directory: 'Java Talon FX (Falcon 500)/DifferentialDrive_Simulation'
- project-name: 'DriveStraight_AuxIntegratedSensor'
directory: 'Java Talon FX (Falcon 500)/DriveStraight_AuxIntegratedSensor'
- project-name: 'DriveStraight_AuxPigeon'
directory: 'Java Talon FX (Falcon 500)/DriveStraight_AuxPigeon'
- project-name: 'DriveStraight_Pigeon'
directory: 'Java Talon FX (Falcon 500)/DriveStraight_Pigeon'
- project-name: 'IntegratedSensor'
directory: 'Java Talon FX (Falcon 500)/IntegratedSensor'
- project-name: 'MotionMagic'
directory: 'Java Talon FX (Falcon 500)/MotionMagic'
- project-name: 'MotionMagic_ArbFeedForward'
directory: 'Java Talon FX (Falcon 500)/MotionMagic_ArbFeedForward'
- project-name: 'MotionMagic_AuxStraightIntegratedSensor'
directory: 'Java Talon FX (Falcon 500)/MotionMagic_AuxStraightIntegratedSensor'
- project-name: 'MotionMagic_AuxStraightPigeon'
directory: 'Java Talon FX (Falcon 500)/MotionMagic_AuxStraightPigeon'
- project-name: 'MotionProfile'
directory: 'Java Talon FX (Falcon 500)/MotionProfile'
- project-name: 'MotionProfileArc_Simple'
directory: 'Java Talon FX (Falcon 500)/MotionProfileArc_Simple'
- project-name: 'MotionProfile_AuxMotionProfileArc'
directory: 'Java Talon FX (Falcon 500)/MotionProfile_AuxMotionProfileArc'
- project-name: 'MotionProfile_Simple'
directory: 'Java Talon FX (Falcon 500)/MotionProfile_Simple'
- project-name: 'Music - Orchestra'
directory: 'Java Talon FX (Falcon 500)/Music - Orchestra'
- project-name: 'Music - Single Tone'
directory: 'Java Talon FX (Falcon 500)/Music - Single Tone'
- project-name: 'PositionClosedLoop'
directory: 'Java Talon FX (Falcon 500)/PositionClosedLoop'
- project-name: 'PositionClosedLoop_AuxFeedForward'
directory: 'Java Talon FX (Falcon 500)/PositionClosedLoop_AuxFeedForward'
- project-name: 'PositionClosedLoop_AuxStraightIntegratedSensor'
directory: 'Java Talon FX (Falcon 500)/PositionClosedLoop_AuxStraightIntegratedSensor'
- project-name: 'PositionClosedLoop_AuxStraightPigeon'
directory: 'Java Talon FX (Falcon 500)/PositionClosedLoop_AuxStraightPigeon'
- project-name: 'RemoteLimitSwitch'
directory: 'Java Talon FX (Falcon 500)/RemoteLimitSwitch'
- project-name: 'RemoteSoftLimit'
directory: 'Java Talon FX (Falcon 500)/RemoteSoftLimit'
- project-name: 'SixTalonArcadeDrive'
directory: 'Java Talon FX (Falcon 500)/SixTalonArcadeDrive'
- project-name: 'VelocityClosedLoop'
directory: 'Java Talon FX (Falcon 500)/VelocityClosedLoop'
- project-name: 'VelocityClosedLoop_ArbFeedForward'
directory: 'Java Talon FX (Falcon 500)/VelocityClosedLoop_ArbFeedForward'
- project-name: 'VelocityClosedLoop_AuxStraightIntegratedSensor'
directory: 'Java Talon FX (Falcon 500)/VelocityClosedLoop_AuxStraightIntegratedSensor'
- project-name: 'VelocityClosedLoop_AuxStraightPigeon'
directory: 'Java Talon FX (Falcon 500)/VelocityClosedLoop_AuxStraightPigeon'

# The type of runner that the job will run on
runs-on: ubuntu-latest

# This grabs the WPILib docker container
container: wpilib/roborio-cross-ubuntu:2023-22.04

steps:
- uses: actions/checkout@v3

# Declares the repository safe and not under dubious ownership.
- name: Add repository to git safe directories
working-directory: ${{ matrix.directory }}}
run: git config --global --add safe.directory $GITHUB_WORKSPACE

# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Runs a single command using the runners shell
- name: Compile and run tests on robot code for project ${{ matrix.project-name }}}
run: ./gradlew build
16 changes: 16 additions & 0 deletions build_all_frc_projects.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$Depth = 1
$Exclude_dirs = "HERO C#", ".github"
$Levels = '/*' * $Depth

$ErrorActionPreference = "Stop"

Get-ChildItem -Directory "./$Levels" -Exclude $Exclude_dirs |
ForEach-Object {
Push-Location $_.FullName
echo "Building example $_"
./gradlew build
if (-not $?) {
throw "Example $_ failed to build"
}
Pop-Location
}
64 changes: 64 additions & 0 deletions build_parallel_workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import os

WORKFLOW_TEMPLATE = """
# This is a faster workflow that parallelizes the jobs in a matrix so
# we can get faster results than waiting for the standard build_all_frc_projects
# powershell script
name: Build all FRC Projects
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
strategy:
fail-fast: false
matrix:
include:{projects_as_matrix}
# The type of runner that the job will run on
runs-on: ubuntu-latest
# This grabs the WPILib docker container
container: wpilib/roborio-cross-ubuntu:2023-22.04
steps:
- uses: actions/checkout@v3
# Declares the repository safe and not under dubious ownership.
- name: Add repository to git safe directories
working-directory: ${{{{ matrix.directory }}}}}}
run: git config --global --add safe.directory $GITHUB_WORKSPACE
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Runs a single command using the runners shell
- name: Compile and run tests on robot code for project ${{{{ matrix.project-name }}}}}}
run: ./gradlew build
"""

PROJECT_MATRIX_TEMPLATE = """
- project-name: '{project_name}'
directory: '{project_dir}'"""

PROJECTS_TO_SEARCH = ["C++ General", "C++ Talon FX (Falcon 500)", "Java General", "Java Talon FX (Falcon 500)"]


project_matrix = []
for project_dir in PROJECTS_TO_SEARCH:
# Find every project in here and build up an array of strings to generate the workflow file
for project in os.listdir(project_dir):
project_matrix.append(PROJECT_MATRIX_TEMPLATE.format(project_name=project, project_dir=f"{project_dir}/{project}"))

with open(".github/workflows/build-all-parallel.yml", "w", encoding="utf-8") as workflow_file:
workflow_file.write(WORKFLOW_TEMPLATE.format(projects_as_matrix="".join(project_matrix)))

0 comments on commit 16e957a

Please sign in to comment.