Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b17091f
Add comprehensive tests for ACCESS-MOPPeR functionality
rbeucher Aug 4, 2025
4738317
Add comprehensive test suite and restructure tests for ACCESS-MOPPeR
rbeucher Aug 4, 2025
1350050
Add unit tests for ACCESS_ESM_CMORiser driver class
rbeucher Aug 4, 2025
d8890df
Add unit tests for various components and ensure proper test marking
rbeucher Aug 4, 2025
a88a341
Enhance ACCESS_ESM_CMORiser initialization with additional parameters…
rbeucher Aug 4, 2025
be73258
Refactor TaskTracker to use 'experiment_id' instead of 'experiment' a…
rbeucher Aug 4, 2025
8113434
Update pytest.ini to ignore additional warnings for ndarray size chan…
rbeucher Aug 4, 2025
fcb545d
Add pytest-subtests to test dependencies and refactor integration tes…
rbeucher Aug 4, 2025
24376e6
Enhance CI workflows by adding a full test suite with manual triggers…
rbeucher Aug 4, 2025
b43032c
Enhance conda deployment workflow with matrix support and add PyPI av…
rbeucher Aug 4, 2025
979e3e3
Add jinja2 to project dependencies in pyproject.toml
rbeucher Aug 4, 2025
17f0dae
Enhance security by validating input paths before subprocess calls in…
rbeucher Aug 4, 2025
0a2908c
Enhance subprocess call safety by validating file paths in end-to-end…
rbeucher Aug 4, 2025
de6fa42
Enhance security by adding nosec comments for subprocess calls in bat…
rbeucher Aug 4, 2025
2a60f15
Enhance security by adding path validation and using secure temporary…
rbeucher Aug 4, 2025
6d86630
Update action versions in full-tests.yml for improved stability and p…
rbeucher Aug 4, 2025
7bfe122
Enhance security by adding validation for allowed characters in table…
rbeucher Aug 4, 2025
deb98a8
Enhance security by escaping paths in subprocess calls across multipl…
rbeucher Aug 4, 2025
ebcb994
Enhance security by adding validation for dashboard and script paths;…
rbeucher Aug 4, 2025
29cb6e8
Enhance error handling in tests by asserting TypeError for missing ex…
rbeucher Aug 4, 2025
4b441ea
Enhance security in submit_job by using explicit command construction…
rbeucher Aug 4, 2025
3deccda
Enhance security in wait_for_jobs by using explicit command construct…
rbeucher Aug 4, 2025
5546906
Enhance security in subprocess calls by using explicit command constr…
rbeucher Aug 4, 2025
e7a1b09
Refactor subprocess argument construction in start_dashboard and test…
rbeucher Aug 4, 2025
a4a1820
Add Codacy configuration for Bandit to enable security checks and ign…
rbeucher Aug 4, 2025
56b3c17
Add duplicate entry for B602 in Codacy configuration to ensure subpro…
rbeucher Aug 4, 2025
a992411
Test
rbeucher Aug 4, 2025
f3f30d9
Refactor subprocess call in test_full_cmorisation to enhance security…
rbeucher Aug 4, 2025
fe5b4e2
Refactor code structure for improved readability and maintainability
rbeucher Aug 4, 2025
e87187c
Refactor subprocess call in test_full_cmorisation to enhance security…
rbeucher Aug 4, 2025
237d83f
Add duplicate entry for B601 in Codacy configuration to enforce subpr…
rbeucher Aug 4, 2025
48a3cdc
Refactor test_batch_cmoriser.py to improve security comments and clar…
rbeucher Aug 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
engines:
bandit:
enabled: true
exclude_paths:
- tests/*
config:
ignore:
- B601 # generic subprocess use warning
- B602 # subprocess call with non-literal argument
- B603 # subprocess_without_shell_equals_true or similar
31 changes: 30 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,48 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1

conda:
name: build and deploy to conda
name: build and deploy to conda (${{ matrix.os }})
needs: pypi
if: always() && needs.pypi.result == 'success'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: [3.11]

steps:
- name: Debug matrix info
run: |
echo "Running on: ${{ matrix.os }}"
echo "Python version: ${{ matrix.python-version }}"
echo "Runner OS: ${{ runner.os }}"

- name: Checkout source
uses: actions/checkout@v4

- name: Wait for PyPI propagation
run: |
echo "Waiting for PyPI package to be available..."
PACKAGE_NAME="access-mopper"
VERSION=$(python -c "import versioneer; print(versioneer.get_version())")
echo "Looking for package: ${PACKAGE_NAME}==${VERSION}"

# Wait up to 10 minutes for the package to be available
for i in {1..60}; do
echo "Attempt $i/60: Checking PyPI availability..."
if pip index versions ${PACKAGE_NAME} 2>/dev/null | grep -q "${VERSION}"; then
echo "✅ Package ${PACKAGE_NAME}==${VERSION} is available on PyPI!"
break
fi
if [ $i -eq 60 ]; then
echo "❌ Package not found on PyPI after 10 minutes"
exit 1
fi
echo "Package not yet available, waiting 10 seconds..."
sleep 10
done

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ on:
push:
branches-ignore: [main]
workflow_dispatch:
inputs:
test_suite:
description: 'Which test suite to run'
required: true
default: 'unit'
type: choice
options:
- unit
- integration
- all

jobs:
pre-commit:
Expand Down Expand Up @@ -44,7 +54,20 @@ jobs:
- name: List installed packages
run: pixi list -e test

- name: Run tests
- name: Run smoke and unit tests (automatic)
if: github.event_name != 'workflow_dispatch'
run: pixi run -e test pytest tests/test_smoke.py tests/unit --cov=access_mopper --cov-report=xml

- name: Run unit tests only (manual)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_suite == 'unit'
run: pixi run -e test pytest tests/test_smoke.py tests/unit --cov=access_mopper --cov-report=xml

- name: Run integration tests only (manual)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_suite == 'integration'
run: pixi run -e test pytest tests/integration --cov=access_mopper --cov-report=xml

- name: Run all tests (manual)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_suite == 'all'
run: pixi run -e test pytest tests --cov=access_mopper --cov-report=xml

- name: Upload code coverage
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/full-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Full Test Suite

on:
workflow_dispatch:
inputs:
test_type:
description: 'Type of test to run'
required: true
default: 'integration'
type: choice
options:
- integration
- e2e
- performance
- all

jobs:
comprehensive-test:
name: Comprehensive Tests
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup pixi
uses: prefix-dev/setup-pixi@8ca4608ef7f4daeb54f5205b20d0b7cb42f11143 # v0.8.14
with:
pixi-version: v0.39.5

- name: Create default config file
run: |
mkdir -p ~/.mopper
cat <<EOF > ~/.mopper/user.yml
creator_name: "CI Bot"
organisation: "ACCESS-NRI"
creator_email: "ci@example.com"
creator_url: "https://example.com"
EOF

- name: List installed packages
run: pixi list -e test

- name: Run integration tests
if: github.event.inputs.test_type == 'integration' || github.event.inputs.test_type == 'all'
run: pixi run -e test pytest tests/integration -v --tb=short

- name: Run end-to-end tests
if: github.event.inputs.test_type == 'e2e' || github.event.inputs.test_type == 'all'
run: pixi run -e test pytest tests/e2e -v --tb=short

- name: Run performance tests
if: github.event.inputs.test_type == 'performance' || github.event.inputs.test_type == 'all'
run: pixi run -e test pytest tests/performance -v --tb=short

- name: Generate coverage report (if running all tests)
if: github.event.inputs.test_type == 'all'
run: pixi run -e test pytest tests --cov=access_mopper --cov-report=xml --cov-report=html

- name: Upload coverage artifacts
if: github.event.inputs.test_type == 'all'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-report
path: htmlcov/
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ repos:
- id: debug-statements # Detects print() and pdb in code

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0 # Check the latest version
rev: v0.8.4 # Use a specific version
hooks:
- id: ruff # Linting
exclude: "^(src/access_mopper/cmor_tables|src/access_mopper/_version.py|src/access_mopper/calc_ocean.py|src/access_mopper/calc_seaice.py)$" # Exclude files or directories
- id: ruff-format # Auto-formatting
exclude: "^(src/access_mopper/cmor_tables|src/access_mopper/_version.py)$"
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: "_version.py"
- id: ruff-format
exclude: "_version.py"
25 changes: 13 additions & 12 deletions notebooks/Getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@
"source": [
"import dask.distributed as dask\n",
"\n",
"client = dask.Client(threads_per_worker = 1)\n",
"client = dask.Client(threads_per_worker=1)\n",
"client"
]
},
Expand All @@ -790,6 +790,7 @@
"source": [
"# Here we use netcdf file from a raw ACCESS-ESM run.\n",
"import glob\n",
"\n",
"files = glob.glob(\"../../Test_data/esm1-6/atmosphere/aiihca.pa-0961*_mon.nc\")"
]
},
Expand All @@ -815,15 +816,15 @@
"outputs": [],
"source": [
"parent_experiment_config = {\n",
" \"parent_experiment_id\": \"piControl\",\n",
" \"parent_activity_id\": \"CMIP\",\n",
" \"parent_source_id\": \"ACCESS-ESM1-5\",\n",
" \"parent_variant_label\": \"r1i1p1f1\",\n",
" \"parent_time_units\": \"days since 0001-01-01 00:00:00\",\n",
" \"parent_mip_era\": \"CMIP6\",\n",
" \"branch_time_in_child\": 0.0,\n",
" \"branch_time_in_parent\": 54786.0,\n",
" \"branch_method\": \"standard\"\n",
" \"parent_experiment_id\": \"piControl\",\n",
" \"parent_activity_id\": \"CMIP\",\n",
" \"parent_source_id\": \"ACCESS-ESM1-5\",\n",
" \"parent_variant_label\": \"r1i1p1f1\",\n",
" \"parent_time_units\": \"days since 0001-01-01 00:00:00\",\n",
" \"parent_mip_era\": \"CMIP6\",\n",
" \"branch_time_in_child\": 0.0,\n",
" \"branch_time_in_parent\": 54786.0,\n",
" \"branch_method\": \"standard\",\n",
"}"
]
},
Expand Down Expand Up @@ -860,8 +861,8 @@
" variant_label=\"r1i1p1f1\",\n",
" grid_label=\"gn\",\n",
" activity_id=\"CMIP\",\n",
" parent_info=parent_experiment_config # <-- This is optional, can be skipped if not needed\n",
" )"
" parent_info=parent_experiment_config, # <-- This is optional, can be skipped if not needed\n",
")"
]
},
{
Expand Down
Loading