|
| 1 | +name: Install Firedrake |
| 2 | + |
| 3 | +inputs: |
| 4 | + os: |
| 5 | + description: Operating system ('linux' or 'macos') |
| 6 | + type: string |
| 7 | + required: true |
| 8 | + source_ref: |
| 9 | + description: Source branch |
| 10 | + type: string |
| 11 | + required: true |
| 12 | + base_ref: |
| 13 | + description: Target branch ('main' or 'release') |
| 14 | + type: string |
| 15 | + required: true |
| 16 | + scalar_type: |
| 17 | + description: Scalar type ('default' or 'complex') |
| 18 | + type: string |
| 19 | + default: default |
| 20 | + gpu: |
| 21 | + description: Target GPU platform |
| 22 | + type: string |
| 23 | + default: none |
| 24 | + deps: |
| 25 | + description: Optional dependencies to install along with Firedrake (e.g. 'check') |
| 26 | + type: string |
| 27 | + default: check |
| 28 | + |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + steps: |
| 32 | + - name: Install system dependencies (1) |
| 33 | + shell: bash |
| 34 | + if: inputs.os == 'linux' |
| 35 | + run: | |
| 36 | + apt-get update |
| 37 | + apt-get -y install curl git python3 python3-venv |
| 38 | +
|
| 39 | + - name: Add NVIDIA CUDA deb repositories |
| 40 | + if: inputs.gpu == 'cuda' |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + deburl=$(python3 ./firedrake-repo/scripts/firedrake-configure --show-extra-repo-pkg-url --gpu-arch cuda) |
| 44 | + debfile=$( basename "${deburl}" ) |
| 45 | + curl -fsSLO "${deburl}" |
| 46 | + dpkg -i "${debfile}" |
| 47 | + apt-get update |
| 48 | +
|
| 49 | + - name: Install system dependencies (2) |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + if [ ${{ inputs.os }} = 'linux' ]; then |
| 53 | + apt-get -y install \ |
| 54 | + $(python3 ./firedrake-repo/scripts/firedrake-configure \ |
| 55 | + --scalar-type ${{ inputs.scalar_type }} \ |
| 56 | + --gpu-arch ${{ inputs.gpu }} \ |
| 57 | + --show-system-packages) |
| 58 | + : # Dependencies needed to run the test suite |
| 59 | + apt-get -y install \ |
| 60 | + fonts-dejavu \ |
| 61 | + graphviz \ |
| 62 | + graphviz-dev \ |
| 63 | + parallel \ |
| 64 | + poppler-utils |
| 65 | + elif [ ${{ inputs.os }} = 'macos' ]; then |
| 66 | + brew install \ |
| 67 | + $(python3 ./firedrake-repo/scripts/firedrake-configure \ |
| 68 | + --scalar-type ${{ inputs.scalar_type }} \ |
| 69 | + --show-system-packages) |
| 70 | + else |
| 71 | + echo "Unrecognised 'os' input: '${{ inputs.os }}" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Install PETSc |
| 76 | + shell: bash |
| 77 | + env: |
| 78 | + EXTRA_OPTIONS: -use_gpu_aware_mpi 0 |
| 79 | + run: | |
| 80 | + : # Clone PETSc |
| 81 | + if [ ${{ inputs.base_ref }} = 'main' ]; then |
| 82 | + git clone --depth 1 https://gitlab.com/petsc/petsc.git --branch connorjward/pcpatch-fixups |
| 83 | + elif [ ${{ inputs.base_ref }} = 'release' ]; then |
| 84 | + git clone --depth 1 \ |
| 85 | + --branch $(python3 ./firedrake-repo/scripts/firedrake-configure --show-petsc-version) \ |
| 86 | + https://gitlab.com/petsc/petsc.git |
| 87 | + else |
| 88 | + echo "Unrecognised 'base_ref' input: '${{ inputs.base_ref }}" |
| 89 | + exit 1 |
| 90 | + fi |
| 91 | +
|
| 92 | + if [ ${{ inputs.os }} = 'linux' ]; then |
| 93 | + NPROCS=8 |
| 94 | + elif [ ${{ inputs.os }} = 'macos' ]; then |
| 95 | + NPROCS=4 |
| 96 | + else |
| 97 | + echo "Unrecognised 'os' input: '${{ inputs.os }}" |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | +
|
| 101 | + cd petsc |
| 102 | + python3 ../firedrake-repo/scripts/firedrake-configure \ |
| 103 | + --scalar-type ${{ inputs.scalar_type }} \ |
| 104 | + --gpu-arch ${{ inputs.gpu }} \ |
| 105 | + --show-petsc-configure-options | \ |
| 106 | + xargs -L1 ./configure \ |
| 107 | + --with-make-np=$NPROCS \ |
| 108 | + --download-slepc |
| 109 | + make |
| 110 | + make check |
| 111 | +
|
| 112 | + - name: Install Firedrake |
| 113 | + shell: bash |
| 114 | + run: | |
| 115 | + export $(python3 ./firedrake-repo/scripts/firedrake-configure \ |
| 116 | + --scalar-type ${{ inputs.scalar_type }} \ |
| 117 | + --gpu-arch ${{ inputs.gpu }} \ |
| 118 | + --show-env) |
| 119 | + export SLEPC_DIR=$PETSC_DIR/$PETSC_ARCH |
| 120 | + : # Disable compiler optimisation to speed up build (especially petsc4py) |
| 121 | + export CFLAGS="-O0" |
| 122 | + env |
| 123 | +
|
| 124 | + python3 -m venv venv |
| 125 | + . venv/bin/activate |
| 126 | +
|
| 127 | + : # Empty the pip cache to ensure that everything is compiled from scratch |
| 128 | + pip cache purge |
| 129 | +
|
| 130 | + if [ ${{ inputs.base_ref }} = 'main' ]; then |
| 131 | + : # Install build dependencies |
| 132 | + pip install "$PETSC_DIR"/src/binding/petsc4py |
| 133 | + pip install -r ./firedrake-repo/requirements-build.txt |
| 134 | +
|
| 135 | + : # Install runtime dependencies that have been removed from the pyproject.toml |
| 136 | + : # because they rely on non-PyPI versions of petsc4py. |
| 137 | + pip install --no-build-isolation --no-deps \ |
| 138 | + "$PETSC_DIR"/"$PETSC_ARCH"/externalpackages/git.slepc/src/binding/slepc4py |
| 139 | + pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git netgen-mesher netgen-occt |
| 140 | +
|
| 141 | + : # We have to pass '--no-build-isolation' to use a custom petsc4py |
| 142 | + EXTRA_PIP_FLAGS='--no-build-isolation' |
| 143 | + elif [ ${{ inputs.base_ref }} = 'release' ]; then |
| 144 | + EXTRA_PIP_FLAGS='' |
| 145 | + else |
| 146 | + echo "Unrecognised 'base_ref' input: '${{ inputs.base_ref }}" |
| 147 | + exit 1 |
| 148 | + fi |
| 149 | +
|
| 150 | + pip install --verbose $EXTRA_PIP_FLAGS \ |
| 151 | + --no-binary h5py \ |
| 152 | + --extra-index-url https://download.pytorch.org/whl/cpu \ |
| 153 | + "./firedrake-repo[${{ inputs.deps }}]" |
| 154 | +
|
| 155 | + firedrake-clean |
| 156 | + pip list |
| 157 | +
|
| 158 | + - name: Run firedrake-check |
| 159 | + shell: bash |
| 160 | + run: | |
| 161 | + . venv/bin/activate |
| 162 | + firedrake-check |
0 commit comments