Skip to content
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
125 changes: 125 additions & 0 deletions .github/workflows/check-submodules-default-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: check-submodules-default-branch

'on':
push:
branches:
- main
- dev
- thin-slots-cases
pull_request:
branches:
- main
- dev
workflow_dispatch:

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

jobs:
check-submodules-default-branch:
runs-on: ubuntu-latest

steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Validate submodules point to their configured branch
shell: bash
run: |
set -euo pipefail

if [[ ! -f .gitmodules ]]; then
echo "No .gitmodules file found. Nothing to validate."
exit 0
fi

mapfile -t submodule_entries < <(git config -f .gitmodules --get-regexp '^submodule\..*\.path$')

if [[ ${#submodule_entries[@]} -eq 0 ]]; then
echo "No submodules found in .gitmodules."
exit 0
fi

failed=0

for entry in "${submodule_entries[@]}"; do
key="${entry%% *}"
path="${entry#* }"
branch_key="${key%.path}.branch"
configured_branch="$(git config -f .gitmodules --get "${branch_key}" || true)"

echo ""
echo "Checking submodule: ${path}"
if [[ -n "${configured_branch}" ]]; then
echo "Configured branch: ${configured_branch}"
fi

if [[ ! -d "${path}" ]]; then
echo "::error title=Missing submodule directory::Submodule path '${path}' is missing in checkout"
failed=1
continue
fi

if ! git -C "${path}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "::error title=Invalid submodule checkout::Path '${path}' is not a valid git repository"
failed=1
continue
fi

sha="$(git -C "${path}" rev-parse HEAD)"
echo "Pinned commit: ${sha}"

git -C "${path}" remote set-branches --add origin '*'
git -C "${path}" fetch --no-tags origin '+refs/heads/*:refs/remotes/origin/*' >/dev/null

if git -C "${path}" rev-parse --is-shallow-repository | grep -q true; then
git -C "${path}" fetch --unshallow --no-tags origin >/dev/null
fi

candidate_branches=()
if [[ -n "${configured_branch}" ]]; then
candidate_branches+=("${configured_branch}")
fi
if git -C "${path}" show-ref --verify --quiet refs/remotes/origin/main; then
candidate_branches+=("main")
fi
if git -C "${path}" show-ref --verify --quiet refs/remotes/origin/master; then
candidate_branches+=("master")
fi

if [[ ${#candidate_branches[@]} -eq 0 ]]; then
echo "::error title=Cannot determine branch::No configured branch or main/master found for submodule '${path}'"
failed=1
continue
fi

is_valid=0
for branch in "${candidate_branches[@]}"; do
if ! git -C "${path}" show-ref --verify --quiet "refs/remotes/origin/${branch}"; then
echo "::warning title=Missing submodule branch::Branch '${branch}' does not exist in '${path}'"
continue
fi
if git -C "${path}" merge-base --is-ancestor "${sha}" "origin/${branch}"; then
echo "OK: ${path} commit belongs to origin/${branch} history"
is_valid=1
break
fi
done

if [[ ${is_valid} -eq 0 ]]; then
echo "::error title=Submodule not on configured history::Submodule '${path}' points to ${sha}, which is not contained in any accepted branch: ${candidate_branches[*]}"
failed=1
fi
done

if [[ ${failed} -ne 0 ]]; then
echo ""
echo "One or more submodules are not aligned with their configured branch history."
exit 1
fi

echo ""
echo "All submodule commits are contained in their configured branch history."
165 changes: 165 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: tests

on:
push:
branches:
- main
- dev
- thin-slots-cases
pull_request:
workflow_dispatch:

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

jobs:
pytest:
name: pytest / python ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.12"]

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

- name: Run tests
run: python -m pytest -vv test/ --durations=0 --junitxml=pytest-results.xml

- name: Upload failed test diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: pytest-results.xml
if-no-files-found: warn

fdtd-integration:
name: fdtd integration
runs-on: ubuntu-latest
timeout-minutes: 45

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Setup Fortran compiler
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: "11"

- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Install HDF5
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

- name: Build fdtd
run: |
cmake -S fdtd -B fdtd/build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DSEMBA_FDTD_ENABLE_MPI=OFF \
-DSEMBA_FDTD_ENABLE_MTLN=OFF \
-DSEMBA_FDTD_ENABLE_TEST=ON
cmake --build fdtd/build -j

- name: Run fdtd native tests
run: ctest --test-dir fdtd/build --output-on-failure

- name: Run caseMaker tests with fdtd
env:
SEMBA_EXE: ${{ github.workspace }}/fdtd/build/bin/semba-fdtd
OMP_NUM_THREADS: "1"
run: python -m pytest -vv test/ --durations=0 --junitxml=pytest-fdtd-results.xml

- name: Upload failed test diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: fdtd-integration-results
path: |
pytest-fdtd-results.xml
fdtd/build/Testing/Temporary/LastTest.log
if-no-files-found: warn

tessellator-smoke:
name: tessellator embedded-surface smoke test
runs-on: ubuntu-latest
timeout-minutes: 45

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

- name: Checkout tessellator submodule
run: git submodule update --init tessellator

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libvtk9-dev ninja-build

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: eed289f6e06a5e7a5c9e6a729671b0a56af7dd69
runVcpkgInstall: false

- name: Build tessellator
run: |
cmake -S tessellator -B tessellator/build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DTESSELLATOR_ENABLE_TESTS=OFF \
-DTESSELLATOR_ENABLE_CGAL=OFF \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build tessellator/build -j

- name: Run embedded-surface case
run: |
rm -rf /tmp/thin-slot-smoke
mkdir -p /tmp/thin-slot-smoke
cp testData/thin_slot/surface/* /tmp/thin-slot-smoke/
cd /tmp/thin-slot-smoke
"${GITHUB_WORKSPACE}/tessellator/build/bin/tessellator" \
-i squareInSquare.embeddedSurface.tessellator.json
test -f SquareInSquare.tessellator.str.vtk
test -f Discretize_Wire.tessellator.str.vtk
test -f squareInSquare.embeddedSurface.tessellator.grid.vtk
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode/settings.json
__pycache__/
*.py[cod]

tmp_cases/
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "tessellator"]
path = tessellator
url = https://github.com/OpenSEMBA/tessellator.git
branch = 112-thin-slots-meshing
[submodule "fdtd"]
path = fdtd
url = https://github.com/OpenSEMBA/fdtd.git
branch = 493-thin-slots-on-surfaces
Loading
Loading