Skip to content

Commit cc8c323

Browse files
Refactor GitHub workflows and use composite actions
- Created .github/actions which contains a reusable build action for bsk and the docs - Updated pull-request-closed.yml to merge.yml and simplified logic to reflect this is a workflow only intended to run on merges - Simplified pull-request.yml by using the reusable actions - Simplified version bump checking - Gated docs build/deploy behind successful macOS builds
1 parent 28fc272 commit cc8c323

8 files changed

Lines changed: 328 additions & 349 deletions

File tree

.github/actions/build/action.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
required: true
8+
description: "Python version"
9+
swig-version:
10+
required: false
11+
default: 4.2.1
12+
conan-args:
13+
required: false
14+
default: ""
15+
build-mode:
16+
required: false
17+
default: conan
18+
extra-apt:
19+
required: false
20+
default: ""
21+
runs:
22+
using: "composite"
23+
steps:
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ inputs.python-version }}
27+
cache: "pip"
28+
29+
- name: Install Linux System Deps.
30+
if: runner.os == 'Linux'
31+
shell: bash
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y build-essential python3-setuptools python3-tk ${EXTRA_APT}
35+
env:
36+
EXTRA_APT: ${{ inputs.extra-apt }}
37+
38+
- name: SWIG Install (Linux)
39+
if: runner.os == 'Linux'
40+
uses: mmomtchev/setup-swig@v4
41+
with:
42+
version: v${{ inputs.swig-version }}
43+
44+
- name: SWIG Install (macOS)
45+
if: runner.os == 'macOS'
46+
shell: bash
47+
env:
48+
HOMEBREW_NO_AUTO_UPDATE: 1
49+
HOMEBREW_NO_INSTALL_UPGRADE: 1
50+
HOMEBREW_NO_ANALYTICS: 1
51+
run: brew install swig || true
52+
53+
- name: SWIG Install (Windows)
54+
if: runner.os == 'Windows'
55+
shell: pwsh
56+
run: |
57+
choco install swig --version=${{ inputs.swig-version }} -y --no-progress --force
58+
swig -version
59+
60+
- name: Update Python tooling to latest
61+
shell: bash
62+
run: python -m pip install -U pip wheel setuptools
63+
64+
- name: Cache Conan (Linux/macOS)
65+
if: ${{ inputs.build-mode == 'conan' }}
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.conan2
70+
key: conan-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('conanfile.*', '**/conanfile.*') }}
71+
restore-keys: |
72+
conan-${{ runner.os }}-${{ inputs.python-version }}-
73+
74+
- name: Cache Conan (Windows)
75+
if: runner.os == 'Windows' && ${{ inputs.build-mode == 'conan' }}
76+
uses: actions/cache@v4
77+
with:
78+
path: ${{ env.USERPROFILE }}\.conan2
79+
key: conan-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('conan.lock','conanfile.*','**/conanfile.*') }}
80+
restore-keys: |
81+
conan-${{ runner.os }}-${{ inputs.python-version }}-
82+
83+
- name: Configure Conan profile
84+
if: ${{ inputs.build-mode == 'conan' }}
85+
shell: bash
86+
run: |
87+
python -m conans.conan profile detect --exist-ok
88+
prof_path="$(python -m conans.conan profile path default)"
89+
90+
grep -q '^\[conf\]' "$prof_path" || printf "\n[conf]\n" >> "$prof_path"
91+
grep -q '^tools.system.package_manager:mode=install$' "$prof_path" || \
92+
printf "tools.system.package_manager:mode=install\n" >> "$prof_path"
93+
grep -q '^tools.system.package_manager:sudo=True$' "$prof_path" || \
94+
printf "tools.system.package_manager:sudo=True\n" >> "$prof_path"
95+
96+
- name: Install dev requirements
97+
shell: bash
98+
run: |
99+
python -m pip install -r requirements_dev.txt
100+
101+
- name: Build Basilisk (Conanfile)
102+
if: ${{ inputs.build-mode == 'conan' }}
103+
shell: bash
104+
run: |
105+
python conanfile.py ${{ inputs.conan-args }}
106+
107+
- name: Build Basilisk (Pip)
108+
if: ${{ inputs.build-mode == 'pip' }}
109+
shell: bash
110+
run: |
111+
pip install . -v
112+
bskLargeData

.github/actions/docs/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 Doxygen
11+
if: ${{ runner.os == 'macOS' }}
12+
shell: bash
13+
env:
14+
HOMEBREW_NO_AUTO_UPDATE: 1
15+
HOMEBREW_NO_INSTALL_UPGRADE: 1
16+
HOMEBREW_NO_ANALYTICS: 1
17+
run: |
18+
brew install doxygen || true
19+
- name: Compile docs
20+
shell: bash
21+
run: |
22+
make -C docs html SPHINXOPTS="-W"
23+
echo "DOCS_HTML=${{ inputs.html-dir }}" >> "$GITHUB_ENV"

.github/workflows/merge.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Merge to develop
2+
3+
on:
4+
push:
5+
branches: [ develop ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
actions: read
11+
12+
concurrency:
13+
group: merge-develop
14+
cancel-in-progress: false
15+
16+
jobs:
17+
bump_version:
18+
name: Bump version (skip if already bumped)
19+
runs-on: ubuntu-latest
20+
if: ${{ github.actor != 'AVSlabBot' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: develop
25+
fetch-depth: 0
26+
token: ${{ secrets.BOT_ACCESS_TOKEN }}
27+
28+
- name: Bump version
29+
run: ./.github/workflows/version-bumper.sh ./docs/source/bskVersion.txt
30+
31+
- name: Commit and push
32+
run: |
33+
git config user.name "AVSlabBot"
34+
git config user.email "cuavslab@gmail.com"
35+
git commit -a -m "[AUTO] Bump version number" || echo "No changes"
36+
git push || true
37+
38+
build-ubuntu-latest-wheels:
39+
name: Build ubuntu-latest wheels
40+
needs: bump_version
41+
# Allow for manual runs to generate new wheels
42+
if: ${{ always() }}
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
python-version: ["3.9", "3.10", "3.11"]
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- uses: ./.github/actions/build
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
build-mode: pip
55+
extra-apt: "cmake"
56+
57+
- name: Build wheel
58+
run: |
59+
python -m pip wheel . -v --wheel-dir /tmp/wheelhouse
60+
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
name: basilisk-wheels_ubuntu-22.04_python${{ matrix['python-version'] }}
64+
path: /tmp/wheelhouse/**/*asilisk*.whl
65+
66+
build_documentation:
67+
name: macOS Docs Deployment
68+
needs: bump_version
69+
runs-on: macos-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- id: build
74+
uses: ./.github/actions/build
75+
with:
76+
python-version: "3.13"
77+
build-mode: conan
78+
conan-args: "--opNav True --allOptPkg --mujoco True --mujocoReplay True"
79+
80+
- name: Build docs
81+
if: ${{ steps.build.outcome == 'success' }}
82+
uses: ./.github/actions/docs
83+
84+
- name: Deploy
85+
if: ${{ success() }} # deploy only if prior steps ok
86+
uses: peaceiris/actions-gh-pages@v3
87+
with:
88+
github_token: ${{ secrets.GITHUB_TOKEN }}
89+
publish_dir: ./docs/build/html
90+
force_orphan: true

.github/workflows/pre-commit.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Pre-commit"
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: 3.11
15+
- id: file_changes
16+
uses: tj-actions/changed-files@v44
17+
- uses: pre-commit/action@v3.0.1
18+
with:
19+
extra_args: --files ${{ steps.file_changes.outputs.all_changed_files}}

.github/workflows/pull-request-closed.yml

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)