Skip to content

Commit 3b8cf00

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 a0d583c commit 3b8cf00

10 files changed

Lines changed: 393 additions & 394 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"

.github/workflows/canary.yml

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "Canary Build"
22

33
on:
44
schedule:
5-
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight
5+
- cron: "0 0 * * 0" # Run weekly on Sunday at midnight
66
workflow_dispatch:
77
pull_request:
88
branches:
@@ -19,70 +19,47 @@ jobs:
1919
timeout-minutes: 75
2020
strategy:
2121
matrix:
22-
python-version: [ "3.13" ]
22+
python-version: ["3.13"]
2323
steps:
2424
- name: Checkout code
2525
uses: actions/checkout@v4
2626
- name: Set up Python ${{ matrix.python-version }}
2727
uses: actions/setup-python@v5
2828
with:
2929
python-version: ${{ matrix.python-version }}
30-
31-
- name: Install Homebrew
32-
run: |
33-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
34-
brew install swig doxygen
35-
36-
- name: "Create virtual Environment"
37-
run: python3 -m venv .venv
38-
- name: "Capture initial package versions"
30+
- name: Capture initial package versions
3931
run: |
40-
source .venv/bin/activate
4132
pip freeze > initial_versions.txt
4233
echo "Initial package versions:" >> $GITHUB_STEP_SUMMARY
4334
cat initial_versions.txt >> $GITHUB_STEP_SUMMARY
4435
echo "\n" >> $GITHUB_STEP_SUMMARY
45-
46-
- name: "Install canary requirements"
47-
run: |
48-
source .venv/bin/activate
49-
pip3 install -r .github/workflows/requirements.txt
50-
pip3 install -r .github/workflows/requirements_dev.txt
51-
pip3 install -r .github/workflows/requirements_doc.txt
52-
pip3 install pytest-error-for-skips
53-
54-
- name: "Capture final package versions"
36+
- name: Build Basilisk
37+
uses: ./.github/actions/build
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
build-mode: conan
41+
conan-args: --opNav True --allOptPkg --mujoco True --mujocoReplay True --recorderPropertyRollback True --pyPkgCanary True
42+
is-canary: true
43+
install-doc-reqs: true
44+
- name: Capture final package versions
5545
run: |
56-
source .venv/bin/activate
5746
pip freeze > final_versions.txt
5847
echo "Final package versions:" >> $GITHUB_STEP_SUMMARY
5948
cat final_versions.txt >> $GITHUB_STEP_SUMMARY
6049
echo "\n" >> $GITHUB_STEP_SUMMARY
6150
echo "Package version changes:" >> $GITHUB_STEP_SUMMARY
6251
diff -u initial_versions.txt final_versions.txt | grep -E '^[+-]' | grep -v '^+++' | grep -v '^---' >> $GITHUB_STEP_SUMMARY
63-
64-
- name: "Build basilisk with latest dependencies"
65-
run: source .venv/bin/activate && python3 conanfile.py --opNav True --allOptPkg --mujoco True --mujocoReplay True --pyPkgCanary True
66-
67-
- name: "Run Python Tests"
68-
run: |
69-
source .venv/bin/activate
70-
cd src
71-
pytest -n auto -m "not ciSkip" -rs --error-for-skips --dist=loadscope -v
52+
- name: Run Python Tests
53+
working-directory: src
54+
run: pytest -n auto -m "not ciSkip" -rs --error-for-skips --dist=loadscope -v
7255
if: ${{ always() }}
73-
- name: "Run C/C++ Tests"
56+
- name: Run C/C++ Tests
7457
working-directory: ./dist3
7558
run: ctest -C Release
7659
if: ${{ always() }}
77-
78-
- name: "Build Documentation"
79-
run: |
80-
source .venv/bin/activate
81-
cd docs
82-
make html SPHINXOPTS="-W"
83-
if: ${{ always() }}
84-
85-
- name: "Upload package version logs"
60+
- name: Build docs
61+
uses: ./.github/actions/docs
62+
- name: Upload package version logs
8663
if: always()
8764
uses: actions/upload-artifact@v4
8865
with:

.github/workflows/merge.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
- name: Build Basilisk
73+
uses: ./.github/actions/build
74+
with:
75+
python-version: 3.13
76+
build-mode: conan
77+
conan-args: --opNav True --allOptPkg --mujoco True --mujocoReplay True --recorderPropertyRollback True
78+
- name: Build docs
79+
uses: ./.github/actions/docs
80+
- name: Deploy
81+
if: ${{ success() }} # deploy only if prior steps ok
82+
uses: peaceiris/actions-gh-pages@v3
83+
with:
84+
github_token: ${{ secrets.GITHUB_TOKEN }}
85+
publish_dir: ./docs/build/html
86+
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}}

0 commit comments

Comments
 (0)