Skip to content

Commit 267aeec

Browse files
committed
add muse2 main branch install to ci
organise CI flow to be easier to follow
1 parent 790a01a commit 267aeec

5 files changed

Lines changed: 195 additions & 111 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Setup MUSE2 from main
2+
description: Build and configure MUSE2_PATH from the MUSE2 main branch via cargo install
3+
inputs:
4+
muse2_exe:
5+
description: MUSE2 executable name for the current OS
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Install Rust toolchain
11+
uses: actions-rust-lang/setup-rust-toolchain@v1
12+
13+
- name: Build and install MUSE2 from main (cargo)
14+
shell: bash
15+
run: |
16+
cargo install \
17+
--git https://github.com/EnergySystemsModellingLab/MUSE2 \
18+
--rev main \
19+
--root "$GITHUB_WORKSPACE/muse2_cargo_root"
20+
21+
- name: Set MUSE2_PATH (Linux / macOS)
22+
if: runner.os == 'Linux' || runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
echo "MUSE2_PATH=${{ github.workspace }}/muse2_cargo_root/bin/${{ inputs.muse2_exe }}" >> "$GITHUB_ENV"
26+
27+
- name: Set MUSE2_PATH (Windows)
28+
if: runner.os == 'Windows'
29+
shell: pwsh
30+
run: |
31+
$exePath = "${{ github.workspace }}\muse2_cargo_root\bin\${{ inputs.muse2_exe }}"
32+
echo "MUSE2_PATH=$exePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Setup MUSE2 from latest release
2+
description: Download latest MUSE2 release asset for current OS and configure MUSE2_PATH
3+
inputs:
4+
github_token:
5+
description: GitHub token for API access
6+
required: true
7+
muse2_exe:
8+
description: MUSE2 executable name for the current OS
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Get latest MUSE2 release tag
14+
id: muse2_release
15+
shell: bash
16+
run: |
17+
TAG=$(curl -sSf \
18+
-H "Accept: application/vnd.github+json" \
19+
-H "Authorization: Bearer ${{ inputs.github_token }}" \
20+
https://api.github.com/repos/EnergySystemsModellingLab/MUSE2/releases/latest \
21+
| jq -r '.tag_name')
22+
23+
if [[ -z "$TAG" || "$TAG" == "null" ]]; then
24+
echo "::error::Failed to retrieve latest MUSE2 release tag."
25+
exit 1
26+
fi
27+
28+
echo "Resolved latest MUSE2 release: $TAG"
29+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
30+
31+
- name: Download MUSE2 release asset
32+
shell: bash
33+
run: |
34+
curl -sSfL \
35+
"https://github.com/EnergySystemsModellingLab/MUSE2/releases/download/${{ steps.muse2_release.outputs.tag }}/${{ runner.os == 'Windows' && 'muse2_windows.zip' || runner.os == 'macOS' && 'muse2_macos_arm.tar.gz' || 'muse2_linux.tar.gz' }}" \
36+
--output "muse2_asset_download"
37+
38+
- name: Extract and set MUSE2_PATH (Linux / macOS)
39+
if: runner.os == 'Linux' || runner.os == 'macOS'
40+
shell: bash
41+
run: |
42+
mkdir -p muse2_bin
43+
tar -xf muse2_asset_download -C muse2_bin
44+
chmod +x "muse2_bin/${{ inputs.muse2_exe }}"
45+
echo "MUSE2_PATH=${{ github.workspace }}/muse2_bin/${{ inputs.muse2_exe }}" >> "$GITHUB_ENV"
46+
47+
- name: Extract and set MUSE2_PATH (Windows)
48+
if: runner.os == 'Windows'
49+
shell: pwsh
50+
run: |
51+
New-Item -ItemType Directory -Force -Path muse2_bin | Out-Null
52+
Rename-Item -Path "muse2_asset_download" -NewName "muse2_asset_download.zip"
53+
Expand-Archive -Path "muse2_asset_download.zip" -DestinationPath muse2_bin -Force
54+
$exePath = "${{ github.workspace }}\muse2_bin\${{ inputs.muse2_exe }}"
55+
echo "MUSE2_PATH=$exePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Verify MUSE2 installation
2+
description: Validate that MUSE2_PATH points to an executable file for the current OS
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Verify MUSE2_PATH (Linux / macOS)
7+
if: runner.os == 'Linux' || runner.os == 'macOS'
8+
shell: bash
9+
run: |
10+
if [[ ! -f "$MUSE2_PATH" ]]; then
11+
echo "::error::MUSE2 executable not found at: $MUSE2_PATH"
12+
exit 1
13+
fi
14+
echo "MUSE2_PATH is set to: $MUSE2_PATH"
15+
16+
- name: Verify MUSE2_PATH (Windows)
17+
if: runner.os == 'Windows'
18+
shell: pwsh
19+
run: |
20+
if (-not (Test-Path -Path $env:MUSE2_PATH -PathType Leaf)) {
21+
Write-Error "MUSE2 executable not found at: $env:MUSE2_PATH"
22+
exit 1
23+
}
24+
Write-Host "MUSE2_PATH is set to: $env:MUSE2_PATH"

.github/workflows/ci.yml

Lines changed: 13 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -7,114 +7,16 @@ on:
77
workflow_call:
88

99
jobs:
10-
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
include:
16-
- os: ubuntu-latest
17-
python-version: '3.14'
18-
muse2_asset: muse2_linux.tar.gz
19-
muse2_exe: muse2
20-
- os: windows-latest
21-
python-version: '3.14'
22-
muse2_asset: muse2_windows.zip
23-
muse2_exe: muse2.exe
24-
- os: macos-latest
25-
python-version: '3.14'
26-
muse2_asset: muse2_macos_arm.tar.gz
27-
muse2_exe: muse2
28-
29-
steps:
30-
- uses: actions/checkout@v6
31-
32-
- uses: astral-sh/setup-uv@v7
33-
with:
34-
enable-cache: true
35-
prune-cache: false
36-
activate-environment: true
37-
python-version: ${{ matrix.python-version }}
38-
39-
- name: Install dependencies
40-
run: uv sync
41-
42-
# Query the GitHub API for the latest MUSE2 release tag (e.g. "v2.0.0").
43-
# The tag is written to GITHUB_OUTPUT so subsequent steps can reference it.
44-
- name: Get latest MUSE2 release tag
45-
id: muse2_release
46-
shell: bash
47-
run: |
48-
TAG=$(curl -sSf \
49-
-H "Accept: application/vnd.github+json" \
50-
-H "Authorization: Bearer ${{ github.token }}" \
51-
https://api.github.com/repos/EnergySystemsModellingLab/MUSE2/releases/latest \
52-
| jq -r '.tag_name')
53-
54-
if [[ -z "$TAG" || "$TAG" == "null" ]]; then
55-
echo "::error::Failed to retrieve latest MUSE2 release tag."
56-
exit 1
57-
fi
58-
59-
echo "Resolved latest MUSE2 release: $TAG"
60-
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
61-
62-
# Download the platform-appropriate MUSE2 release asset.
63-
# 'shell: bash' is used on all platforms
64-
- name: Download MUSE2 release asset
65-
shell: bash
66-
run: |
67-
curl -sSfL \
68-
"https://github.com/EnergySystemsModellingLab/MUSE2/releases/download/${{ steps.muse2_release.outputs.tag }}/${{ matrix.muse2_asset }}" \
69-
--output "muse2_asset_download"
70-
71-
- name: Extract MUSE2 and set environment variable (Linux / macOS)
72-
if: runner.os == 'Linux' || runner.os == 'macOS'
73-
shell: bash
74-
run: |
75-
mkdir -p muse2_bin
76-
tar -xf muse2_asset_download -C muse2_bin
77-
chmod +x "muse2_bin/${{ matrix.muse2_exe }}"
78-
echo "MUSE2_PATH=${{ github.workspace }}/muse2_bin/${{ matrix.muse2_exe }}" >> "$GITHUB_ENV"
79-
80-
- name: Extract MUSE2 and set environment variable (Windows)
81-
if: runner.os == 'Windows'
82-
shell: pwsh
83-
run: |
84-
New-Item -ItemType Directory -Force -Path muse2_bin | Out-Null
85-
Rename-Item -Path "muse2_asset_download" -NewName "muse2_asset_download.zip"
86-
Expand-Archive -Path "muse2_asset_download.zip" -DestinationPath muse2_bin -Force
87-
$exePath = "${{ github.workspace }}\muse2_bin\${{ matrix.muse2_exe }}"
88-
echo "MUSE2_PATH=$exePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
89-
90-
# Confirm the muse2 executable is present and the environment variable is set correctly.
91-
- name: Verify MUSE2 installation (Linux / macOS)
92-
if: runner.os == 'Linux' || runner.os == 'macOS'
93-
shell: bash
94-
run: |
95-
if [[ ! -f "$MUSE2_PATH" ]]; then
96-
echo "::error::MUSE2 executable not found at: $MUSE2_PATH"
97-
exit 1
98-
fi
99-
echo "MUSE2_PATH is set to: $MUSE2_PATH"
100-
101-
- name: Verify MUSE2 installation (Windows)
102-
if: runner.os == 'Windows'
103-
shell: pwsh
104-
run: |
105-
if (-not (Test-Path -Path $env:MUSE2_PATH -PathType Leaf)) {
106-
Write-Error "MUSE2 executable not found at: $env:MUSE2_PATH"
107-
exit 1
108-
}
109-
Write-Host "MUSE2_PATH is set to: $env:MUSE2_PATH"
110-
111-
- name: Run tests
112-
run: pytest
113-
114-
- name: Upload coverage to Codecov
115-
if: runner.os == 'Linux'
116-
uses: codecov/codecov-action@v5
117-
with:
118-
token: ${{ secrets.CODECOV_TOKEN }}
119-
files: ./coverage.xml
120-
fail_ci_if_error: true
10+
test_release:
11+
name: Test against latest MUSE2 release
12+
uses: ./.github/workflows/test-with-muse2.yml
13+
with:
14+
muse2_source: release
15+
secrets: inherit
16+
17+
test_main:
18+
name: Test against MUSE2 main
19+
uses: ./.github/workflows/test-with-muse2.yml
20+
with:
21+
muse2_source: main
22+
secrets: inherit
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Test with MUSE2 source
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
muse2_source:
7+
description: Which MUSE2 source to test against (release or main)
8+
required: true
9+
type: string
10+
secrets:
11+
CODECOV_TOKEN:
12+
required: false
13+
14+
jobs:
15+
test:
16+
name: Test against MUSE2 (${{ inputs.muse2_source }}) on ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: ubuntu-latest
23+
python-version: '3.14'
24+
muse2_exe: muse2
25+
- os: windows-latest
26+
python-version: '3.14'
27+
muse2_exe: muse2.exe
28+
- os: macos-latest
29+
python-version: '3.14'
30+
muse2_exe: muse2
31+
32+
steps:
33+
- uses: actions/checkout@v6
34+
35+
- uses: astral-sh/setup-uv@v7
36+
with:
37+
enable-cache: true
38+
prune-cache: false
39+
activate-environment: true
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install dependencies
43+
run: uv sync
44+
45+
- name: Setup MUSE2 from main
46+
if: inputs.muse2_source == 'main'
47+
uses: ./.github/actions/setup-muse2-main
48+
with:
49+
muse2_exe: ${{ matrix.muse2_exe }}
50+
51+
- name: Setup MUSE2 from latest release
52+
if: inputs.muse2_source == 'release'
53+
uses: ./.github/actions/setup-muse2-release
54+
with:
55+
github_token: ${{ github.token }}
56+
muse2_exe: ${{ matrix.muse2_exe }}
57+
58+
- name: Verify MUSE2 installation
59+
uses: ./.github/actions/verify-muse2
60+
61+
- name: Run tests
62+
run: pytest
63+
64+
- name: Upload coverage to Codecov
65+
# Latest linux release only - they should all be the same
66+
if: runner.os == 'Linux' && inputs.muse2_source == 'release'
67+
uses: codecov/codecov-action@v5
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: ./coverage.xml
71+
fail_ci_if_error: true

0 commit comments

Comments
 (0)