Skip to content

Commit 0ca9b87

Browse files
committed
test ci
1 parent 3e9e4b1 commit 0ca9b87

1 file changed

Lines changed: 75 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Test and build
2-
32
on:
43
push:
54
branches: [main]
@@ -9,28 +8,94 @@ on:
98

109
jobs:
1110
test:
12-
runs-on: ${{matrix.os}}
11+
runs-on: ${{ matrix.os }}
1312
strategy:
1413
fail-fast: false
1514
matrix:
16-
os:
17-
- ubuntu-latest
18-
- windows-latest
19-
- macos-latest
20-
python-version: ['3.14']
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
2128

2229
steps:
23-
- uses: actions/checkout@v6
24-
- uses: astral-sh/setup-uv@v7
30+
- uses: actions/checkout@v4
31+
32+
- uses: astral-sh/setup-uv@v5
2533
with:
2634
enable-cache: true
2735
prune-cache: false
28-
activate-environment: true
2936
python-version: ${{ matrix.python-version }}
3037

3138
- name: Install dependencies
3239
run: uv sync
3340

41+
# Query the GitHub API for the latest MUSE2 release tag (e.g. "v2.0.0").
42+
# The tag is written to GITHUB_OUTPUT so subsequent steps can reference it.
43+
- name: Get latest MUSE2 release tag
44+
id: muse2_release
45+
shell: bash
46+
run: |
47+
TAG=$(curl -sSf \
48+
-H "Accept: application/vnd.github+json" \
49+
-H "X-GitHub-Api-Version: 2022-11-28" \
50+
https://api.github.com/repos/EnergySystemsModellingLab/MUSE2/releases/latest \
51+
| jq -r '.tag_name')
52+
53+
if [[ -z "$TAG" || "$TAG" == "null" ]]; then
54+
echo "::error::Failed to retrieve latest MUSE2 release tag."
55+
exit 1
56+
fi
57+
58+
echo "Resolved latest MUSE2 release: $TAG"
59+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
60+
61+
# Download the platform-appropriate MUSE2 release asset.
62+
# 'shell: bash' is used on all platforms
63+
- name: Download MUSE2 release asset
64+
shell: bash
65+
run: |
66+
curl -sSfL \
67+
"https://github.com/EnergySystemsModellingLab/MUSE2/releases/download/${{ steps.muse2_release.outputs.tag }}/${{ matrix.muse2_asset }}" \
68+
--output "muse2_asset_download"
69+
70+
- name: Extract MUSE2 and set environment variable (Linux / macOS)
71+
if: runner.os == 'Linux' || runner.os == 'macOS'
72+
shell: bash
73+
run: |
74+
mkdir -p muse2_bin
75+
tar -xf muse2_asset_download -C muse2_bin
76+
chmod +x "muse2_bin/${{ matrix.muse2_exe }}"
77+
echo "MUSE2_PATH=${{ github.workspace }}/muse2_bin/${{ matrix.muse2_exe }}" >> "$GITHUB_ENV"
78+
79+
- name: Extract MUSE2 and set environment variable (Windows)
80+
if: runner.os == 'Windows'
81+
shell: pwsh
82+
run: |
83+
New-Item -ItemType Directory -Force -Path muse2_bin | Out-Null
84+
Rename-Item -Path "muse2_asset_download" -NewName "muse2_asset_download.zip"
85+
Expand-Archive -Path "muse2_asset_download.zip" -DestinationPath muse2_bin -Force
86+
$exePath = "${{ github.workspace }}\muse2_bin\${{ matrix.muse2_exe }}"
87+
echo "MUSE2_PATH=$exePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
88+
89+
# Confirm the muse2 executable is present and the environment variable is set correctly.
90+
- name: Verify MUSE2 installation
91+
shell: bash
92+
run: |
93+
if [[ ! -f "$MUSE2_PATH" ]]; then
94+
echo "::error::MUSE2 executable not found at: $MUSE2_PATH"
95+
exit 1
96+
fi
97+
echo "MUSE2_PATH is set to: $MUSE2_PATH"
98+
3499
- name: Run mypy
35100
run: mypy .
36101

0 commit comments

Comments
 (0)