MarsInterp testing #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)" |