Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/github_action #221

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Language: Cpp
BasedOnStyle: Google
IndentWidth: 4
TabWidth: 4
UseTab: Never
AllowShortFunctionsOnASingleLine: Empty

SortIncludes: Never

NamespaceIndentation: None

BraceWrapping:
AfterNamespace: true
AfterFunction: true
AfterControlStatement: true
AfterClass: true
SplitEmptyFunction: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false

AlignAfterOpenBracket: Align
AlignOperands: false
AccessModifierOffset: -4

BreakBeforeBraces: Custom

BinPackParameters: false
BinPackArguments: false
Cpp11BracedListStyle: false

PointerAlignment: Left

SpacesInContainerLiterals: true
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: false

AllowAllParametersOfDeclarationOnNextLine: false

CommentPragmas: '^!|^@'
SpaceAfterTemplateKeyword: false

ContinuationIndentWidth: 8
ConstructorInitializerIndentWidth: 4
BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: false

SpaceBeforeCtorInitializerColon: false
SpacesInAngles: true
SpacesInParentheses: true
SpacesInSquareBrackets: true
SpaceInEmptyParentheses: true
SpaceInEmptyBlock: true

ColumnLimit: 140
89 changes: 89 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Clang-Format Check and Fix

on:
push:
branches:
- develop

jobs:
format-check:
if: ${{ !contains(github.event.head_commit.message, 'Apply clang-format') }}
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}
fetch-depth: 1
persist-credentials: true

- name: Install Clang-Format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
clang-format --version

- name: Ensure the previous commit is available
run: |
# Try to fetch the commit corresponding to github.event.before
git fetch origin ${{ github.event.before }} --depth=1

- name: Get list of changed files
id: changed-files
run: |
CHANGED_FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -E "\.(cpp|h|c)$" || true)
echo "Changed files:"
echo "$CHANGED_FILES"
if [ -z "$CHANGED_FILES" ]; then
echo "No changed files detected."
echo "files=" >> "$GITHUB_OUTPUT"
else
# Use heredoc syntax to correctly handle multi-line output
echo "files<<EOF" >> "$GITHUB_OUTPUT"
echo "$CHANGED_FILES" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
fi

- name: Run Clang-Format on Changed Files
run: |
if [ -z "${{ steps.changed-files.outputs.files }}" ]; then
echo "No changed C/C++ files detected. Exiting."
else
echo "Running clang-format on the following files:"
echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n'
# Using newline as the delimiter for xargs
echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n' | xargs -r clang-format -style=file -i
fi

- name: Check for Formatting Differences
id: check_diff
run: |
# Instead of exiting with non-zero, check if there is any diff and store that as an output.
if git diff --quiet; then
echo "No formatting differences."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "Formatting differences detected."
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Auto-commit Formatting Changes
if: steps.check_diff.outputs.changed == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
# Commit only if there is something to commit.
git commit -m "Apply clang-format" || exit 0
branch=${GITHUB_REF#refs/heads/}
git push origin HEAD:"$branch"


- name: Report Success or Failure
run: |
if [ "${{ steps.check_diff.outputs.changed }}" == "true" ]; then
echo "Formatting issues were detected and fixed."
else
echo "Code is properly formatted."
fi
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 89 files
+0 −4 .github/sync.yml
+31 −0 .github/workflows/sync-tudat-space.yml
+0 −22 .github/workflows/sync.yml
+13 −0 .gitignore
+107 −46 README.md
+0 −72 clean_py_notebooks.py
+0 −41 convert_py_to_ipynb.py
+174 −0 create_scripts.py
+21 −0 environment.yaml
+0 −12 environment.yml
+429 −0 estimation/SiMDA_240512.csv
+360 −99 estimation/covariance_estimated_parameters.ipynb
+265 −113 estimation/covariance_estimated_parameters.py
+761 −0 estimation/covariance_propagation_example.ipynb
+538 −0 estimation/covariance_propagation_example.py
+2,052 −0 estimation/data/mrorange2006-2013.txt
+168 −89 estimation/estimation_dynamical_models.ipynb
+68 −47 estimation/estimation_dynamical_models.py
+155 −112 estimation/estimation_with_mpc.ipynb
+150 −129 estimation/estimation_with_mpc.py
+226 −137 estimation/full_estimation_example.ipynb
+176 −103 estimation/full_estimation_example.py
+117 −68 estimation/galilean_moons_state_estimation.ipynb
+72 −48 estimation/galilean_moons_state_estimation.py
+320 −0 estimation/grail_examples_functions.py
+20 −0 estimation/grail_inputs/grail_macromodel.txt
+8 −0 estimation/grail_inputs/grail_materials.txt
+578 −0 estimation/grail_odf_estimation.py
+447 −0 estimation/grail_residuals.py
+405 −0 estimation/grail_spice_fit.py
+2,168 −0 estimation/improved_estimation_with_mpc.ipynb
+1,312 −0 estimation/improved_estimation_with_mpc.py
+309 −0 estimation/load_pds_files.py
+535 −0 estimation/mro_range_estimation.ipynb
+362 −0 estimation/mro_range_estimation.py
+1,282 −0 estimation/mro_residuals_analysis.py
+220 −99 estimation/retrieving_mpc_observation_data.ipynb
+165 −90 estimation/retrieving_mpc_observation_data.py
+ kernels/kernel_juice.bsp
+ kernels/kernel_noe.bsp
+146 −96 mission_design/cassini1_mga_optimization.ipynb
+181 −98 mission_design/cassini1_mga_optimization.py
+32 −17 mission_design/earth_mars_transfer_window.ipynb
+37 −18 mission_design/earth_mars_transfer_window.py
+168 −167 mission_design/hodographic_shaping_mga_optimization.ipynb
+170 −142 mission_design/hodographic_shaping_mga_optimization.py
+1,236 −0 mission_design/low_thrust_earth_mars_transfer_window.ipynb
+939 −0 mission_design/low_thrust_earth_mars_transfer_window.py
+1,191 −0 mission_design/mga_trajectories.ipynb
+109 −72 mission_design/mga_trajectories.py
+ propagation/callisto_map.jpg
+191 −121 propagation/coupled_translational_rotational_dynamics.ipynb
+410 −170 propagation/coupled_translational_rotational_dynamics.py
+ propagation/europa_map.jpg
+ propagation/ganymede_map.jpg
+13 −19 propagation/impact_manifolds_lpo_cr3bp.ipynb
+95 −87 propagation/impact_manifolds_lpo_cr3bp.py
+ propagation/input/juice_mat_crema_5_1_150lb_v01.bsp
+595 −0 propagation/juice_flybys.ipynb
+416 −0 propagation/juice_flybys.py
+54 −38 propagation/keplerian_satellite_orbit.ipynb
+52 −45 propagation/keplerian_satellite_orbit.py
+70 −51 propagation/linear_sensitivity_analysis.ipynb
+80 −71 propagation/linear_sensitivity_analysis.py
+0 −1,193 propagation/mga_trajectories.ipynb
+78 −61 propagation/perturbed_satellite_orbit.ipynb
+86 −71 propagation/perturbed_satellite_orbit.py
+79 −57 propagation/reentry_trajectory.ipynb
+84 −61 propagation/reentry_trajectory.py
+50 −42 propagation/separation_satellites_diff_drag.ipynb
+77 −64 propagation/separation_satellites_diff_drag.py
+15 −19 propagation/solar_system_propagation.ipynb
+36 −36 propagation/solar_system_propagation.py
+24 −29 propagation/thrust_between_Earth_Moon.ipynb
+105 −121 propagation/thrust_between_Earth_Moon.py
+717 −0 propagation/thrust_satellite_engine.ipynb
+525 −0 propagation/thrust_satellite_engine.py
+128 −166 propagation/two_stage_rocket_ascent.ipynb
+204 −197 propagation/two_stage_rocket_ascent.py
+29 −29 pygmo/asteroid_orbit_optimization/aoo_custom_environment.ipynb
+61 −50 pygmo/asteroid_orbit_optimization/aoo_custom_environment.py
+38 −33 pygmo/asteroid_orbit_optimization/aoo_design_space_exploration.ipynb
+84 −77 pygmo/asteroid_orbit_optimization/aoo_design_space_exploration.py
+65 −37 pygmo/asteroid_orbit_optimization/aoo_optimization.ipynb
+81 −66 pygmo/asteroid_orbit_optimization/aoo_optimization.py
+13 −12 pygmo/himmelblau_minimization.ipynb
+31 −26 pygmo/himmelblau_minimization.py
+6 −0 templates/clean_py/conf.json
+17 −0 templates/clean_py/index.py.j2