Skip to content

Commit 39b8ffc

Browse files
Create composite actions for building bsk
1 parent 023d4ad commit 39b8ffc

3 files changed

Lines changed: 181 additions & 0 deletions

File tree

.github/actions/build/action.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: build
2+
description: >
3+
Sets up a cross-platform build environment for Basilisk and performs
4+
either a Conan-based build or a pip-based build.
5+
inputs:
6+
python-version:
7+
description: Python version
8+
required: true
9+
build-mode:
10+
required: false
11+
default: conan
12+
conan-args:
13+
required: false
14+
default: ""
15+
extra-apt:
16+
required: false
17+
default: ""
18+
is-canary:
19+
description: If a canary build is being performed.
20+
required: false
21+
default: false
22+
install-doc-reqs:
23+
description: If documentation requirements should be installed.
24+
required: false
25+
default: false
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ inputs.python-version }}
33+
cache: "pip"
34+
cache-dependency-path: |
35+
requirements_dev.txt
36+
requirements_doc.txt
37+
requirements.txt
38+
39+
- name: Install Linux System Deps.
40+
if: runner.os == 'Linux'
41+
shell: bash
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y build-essential python3-setuptools python3-tk ${{ inputs.extra-apt }}
45+
46+
- name: SWIG Install (Linux)
47+
if: runner.os == 'Linux'
48+
uses: mmomtchev/setup-swig@v4
49+
with:
50+
version: v4.2.1
51+
52+
- name: SWIG Install (macOS)
53+
if: runner.os == 'macOS'
54+
shell: bash
55+
env:
56+
HOMEBREW_NO_AUTO_UPDATE: 1
57+
HOMEBREW_NO_INSTALL_UPGRADE: 1
58+
HOMEBREW_NO_ANALYTICS: 1
59+
run: brew install swig || true
60+
61+
- name: SWIG Install (Windows)
62+
if: runner.os == 'Windows'
63+
shell: pwsh
64+
run: |
65+
$swigDir = "C:\Program Files\SWIG"
66+
if (!(Test-Path $swigDir)) {New-Item -ItemType Directory -Path $swigDir | Out-Null}
67+
$swigZip = "$swigDir\swigwin-4.2.1.zip"
68+
$swigUrl = "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download"
69+
Start-Process -NoNewWindow -Wait -FilePath "curl.exe" -ArgumentList "-L -o `"$swigZip`" `"$swigUrl`""
70+
if (!(Test-Path $swigZip) -or ((Get-Item $swigZip).Length -lt 500KB)) { Write-Host "Download failed or file is corrupted." }
71+
Expand-Archive -Path $swigZip -DestinationPath $swigDir -Force
72+
73+
- name: "Add Basilisk and SWIG paths"
74+
if: runner.os == 'Windows'
75+
shell: pwsh
76+
run: |
77+
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
78+
$newPath = “C:\Program Files\SWIG\swigwin-4.2.1;$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk”
79+
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
80+
81+
- name: Update Python tooling to latest
82+
shell: bash
83+
run: pip install -U pip wheel setuptools
84+
85+
- name: Install requirements
86+
shell: bash
87+
run: |
88+
if [[ "${{ inputs.is-canary }}" == 'true' ]]; then
89+
pip install -r .github/workflows/requirements.txt -r .github/workflows/requirements_dev.txt
90+
else
91+
pip install -r requirements.txt -r requirements_dev.txt
92+
fi
93+
94+
- name: Install documentation requirements
95+
if: ${{ inputs.install-doc-reqs == 'true' }}
96+
shell: bash
97+
run: |
98+
if [[ "${{ inputs.is-canary }}" == 'true' ]]; then
99+
pip install -r .github/workflows/requirements_doc.txt
100+
else
101+
pip install -r requirements_doc.txt
102+
fi
103+
104+
- name: Cache Conan
105+
if: ${{ inputs.build-mode == 'conan' }}
106+
uses: actions/cache@v4
107+
with:
108+
path: ${{ env.HOME }}/.conan2
109+
key: >-
110+
conan-${{ runner.os }}-py${{ inputs.python-version }}-
111+
${{ hashFiles('conan.lock','conanfile.*','**/conanfile.*','CMakeLists.txt','**/*.cmake') }}
112+
restore-keys: |
113+
conan-${{ runner.os }}-py${{ inputs.python-version }}-
114+
115+
- name: Configure Conan profile
116+
if: ${{ inputs.build-mode == 'conan' }}
117+
shell: bash
118+
run: |
119+
python -m conans.conan profile detect --exist-ok
120+
prof_path="$(python -m conans.conan profile path default)"
121+
122+
grep -q '^\[conf\]' "$prof_path" || printf "\n[conf]\n" >> "$prof_path"
123+
grep -q '^tools.system.package_manager:mode=install$' "$prof_path" || \
124+
printf "tools.system.package_manager:mode=install\n" >> "$prof_path"
125+
grep -q '^tools.system.package_manager:sudo=True$' "$prof_path" || \
126+
printf "tools.system.package_manager:sudo=True\n" >> "$prof_path"
127+
128+
- name: Build Basilisk (Conanfile)
129+
if: ${{ inputs.build-mode == 'conan' }}
130+
shell: bash
131+
env:
132+
CONAN_NON_INTERACTIVE: "1"
133+
run: |
134+
python conanfile.py ${{ inputs.conan-args }}
135+
136+
- name: Build Basilisk (Pip)
137+
if: ${{ inputs.build-mode == 'pip' }}
138+
shell: bash
139+
run: |
140+
pip install . -v
141+
bskLargeData

.github/actions/docs/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: docs
2+
description: Build Sphinx docs
3+
4+
inputs:
5+
html-dir: { required: false, default: "docs/build/html" }
6+
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Install doc requirements
11+
shell: bash
12+
run: |
13+
brew install doxygen
14+
pip install -r requirements_doc.txt
15+
- name: Generate doc artifacts
16+
shell: bash
17+
env:
18+
MPLBACKEND: agg
19+
working-directory: src
20+
run: pytest -n auto -m "not ciSkip" -rs --dist=loadscope -v
21+
- name: Compile docs
22+
shell: bash
23+
run: |
24+
make -C docs html SPHINXOPTS="-W"
25+
echo "DOCS_HTML=${{ inputs.html-dir }}" >> "$GITHUB_ENV"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: pre-commit
2+
description: Run pre-commit on changed files with Python 3.11
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: actions/setup-python@v5
8+
with:
9+
python-version: 3.11
10+
11+
- id: file_changes
12+
uses: tj-actions/changed-files@v44
13+
- uses: pre-commit/action@v3.0.1
14+
with:
15+
extra_args: --files ${{ steps.file_changes.outputs.all_changed_files }}

0 commit comments

Comments
 (0)