-
Notifications
You must be signed in to change notification settings - Fork 8
98 lines (89 loc) · 3.22 KB
/
marsinterp_test.yml
File metadata and controls
98 lines (89 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: MarsInterp Test Workflow
# Cancel any in-progress job or previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
# Trigger the workflow on push to devel branch
push:
branches: [ devel ]
paths:
- 'bin/MarsInterp.py'
- 'tests/test_marsinterp.py'
- '.github/workflows/marsinterp_test.yml'
- 'amescap/FV3_utils.py'
# Allow manual triggering of the workflow
workflow_dispatch:
# Trigger on pull requests that modify relevant files
pull_request:
branches: [ devel ]
paths:
- 'bin/MarsInterp.py'
- 'tests/test_marsinterp.py'
- '.github/workflows/marsinterp_test.yml'
- 'amescap/FV3_utils.py'
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
fail-fast: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Install dependencies
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install numpy netCDF4 xarray scipy matplotlib
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Install the package in editable mode
- name: Install package
run: pip install -e .
# Set HOME for Windows since it might be used by the script
- name: Set HOME environment variable for Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "HOME=$env:USERPROFILE" >> $env:GITHUB_ENV
# Set up AmesCAP configuration - handle platform differences
- name: Set up AmesCAP configuration
shell: bash
run: |
mkdir -p $HOME/.amescap
cp mars_templates/amescap_profile $HOME/.amescap_profile
# Create a patch for the test file to fix Windows path issues
- name: Create test_marsinterp.py path fix for Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$content = Get-Content tests/test_marsinterp.py -Raw
# Fix path handling for Windows
$content = $content -replace "os\.path\.join\(self\.test_dir, file\)", "os.path.normpath(os.path.join(self.test_dir, file))"
Set-Content tests/test_marsinterp.py -Value $content
# Run all tests with increased timeout
- name: Run all tests
timeout-minutes: 25
run: |
cd tests
python -m unittest test_marsinterp
# Report file paths if things fail on Windows
- name: Debug Windows paths
if: runner.os == 'Windows' && failure()
shell: pwsh
run: |
Write-Host "Current directory: $(Get-Location)"
Write-Host "Test directory contents: $(Get-ChildItem -Path tests)"