diff --git a/.github/workflows/esgf_qa_check.yml b/.github/workflows/esgf_qa_check.yml new file mode 100644 index 0000000..cf96aff --- /dev/null +++ b/.github/workflows/esgf_qa_check.yml @@ -0,0 +1,98 @@ +name: esgf_qa_check +on: + push: + branches: + - main + pull_request: + branches: + +# cancel running jobs if theres a newer push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + esgf-qa-validation: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + fail-fast: false + defaults: + run: + shell: bash -l {0} + steps: + - name: Checkout Files + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: fremorizer + environment-file: environment.yaml + auto-activate-base: false + miniforge-version: latest + + - name: Configure Conda + run: | + echo "removing main and r channels from defaults" + conda config --remove channels defaults || true + conda config --remove channels main || true + conda config --remove channels r || true + + echo "setting strict channel priority" + conda config --set channel_priority strict + + echo "printing conda config just in case" + conda config --show + + - name: Install fremorizer + run: | + pip install . + + - name: Run pytest to generate test outputs + run: | + pytest fremorizer/tests/ -v --tb=short + + - name: Run ESGF-QA on test outputs + run: | + # Find the test output directory + TEST_OUTPUT_DIR="fremorizer/tests/test_files/outdir" + + # Create directory for QA results + QA_RESULTS_DIR="esgf_qa_results" + mkdir -p ${QA_RESULTS_DIR} + + # Check if test outputs exist + if [ -d "${TEST_OUTPUT_DIR}" ] && [ -n "$(find ${TEST_OUTPUT_DIR} -name '*.nc' -print -quit)" ]; then + echo "Running ESGF-QA on test outputs in ${TEST_OUTPUT_DIR}" + + # Run ESGF-QA with CF compliance checks + esgqa -t cf:latest -o ${QA_RESULTS_DIR} -i "fremorizer-test-outputs" ${TEST_OUTPUT_DIR} || true + + echo "ESGF-QA check completed" + echo "Results stored in ${QA_RESULTS_DIR}" + + # Display summary of results + if [ -f "${QA_RESULTS_DIR}/qa_result_"*.cluster.json ]; then + echo "QA results summary:" + ls -lh ${QA_RESULTS_DIR}/qa_result_*.cluster.json + fi + else + echo "No test output files found in ${TEST_OUTPUT_DIR}" + echo "Skipping ESGF-QA validation" + fi + + - name: Upload ESGF-QA results + if: always() + uses: actions/upload-artifact@v4 + with: + name: esgf-qa-results-py${{ matrix.python-version }} + path: esgf_qa_results/ + retention-days: 30 + if-no-files-found: warn diff --git a/.gitignore b/.gitignore index df2b827..ddb453d 100644 --- a/.gitignore +++ b/.gitignore @@ -156,6 +156,7 @@ cython_debug/ tmp/ # QA results +esgf_qa_results/ wcrp_compliance_reports/ # autogen'd by doc build diff --git a/README.md b/README.md index f6467de..9ad5406 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![pylint](https://img.shields.io/badge/pylint-%E2%89%A59.6-brightgreen)](https://github.com/NOAA-GFDL/epmt/actions/workflows/build_and_test_epmt.yml) [![codecov](https://codecov.io/gh/ilaflott/fremorizer/branch/main/graph/badge.svg)](https://codecov.io/gh/ilaflott/fremorizer) +[![esgf_qa_check](https://github.com/ilaflott/fremorizer/actions/workflows/esgf_qa_check.yml/badge.svg?branch=main)](https://github.com/ilaflott/fremorizer/actions/workflows/esgf_qa_check.yml) Simply put, `fremorizer` CMORizes FRE output with `CMOR`. @@ -174,6 +175,24 @@ pylint --rcfile pylintrc fremorizer/ ## Quality Assurance +The repository includes automated quality assurance (QA) checks to validate that CMORized outputs meet CMIP6 standards: + +### ESGF-QA Validation + +The `esgf_qa_check` workflow runs [ESGF-QA](https://github.com/ESGF/esgf-qa) on test outputs to verify CF compliance and CMIP6 metadata standards. This separate pipeline: + +- Runs automatically on pushes and pull requests +- Executes unit tests to generate CMORized output files +- Validates outputs using ESGF-QA with CF compliance checks +- Uploads QA results as workflow artifacts (retained for 30 days) + +To view QA results from a workflow run: +1. Navigate to the Actions tab in GitHub +2. Select the `esgf_qa_check` workflow run +3. Download the `esgf-qa-results` artifact +4. View results using the ESGF-QA viewer or web interface + +## Relationship to fre-cli ### WCRP Compliance Checking [![wcrp_compliance_check](https://github.com/ilaflott/fremorizer/actions/workflows/wcrp_compliance_check.yml/badge.svg?branch=main)](https://github.com/ilaflott/fremorizer/actions/workflows/wcrp_compliance_check.yml) diff --git a/environment.yaml b/environment.yaml index 4d13fba..d1106fe 100644 --- a/environment.yaml +++ b/environment.yaml @@ -12,3 +12,6 @@ dependencies: - conda-forge::pytest - conda-forge::pytest-cov - conda-forge::pylint + - pip + - pip: + - esgf-qa diff --git a/pyproject.toml b/pyproject.toml index be3cac8..c6bb1b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,7 @@ test = [ ] qa = [ + "esgf-qa", "cc-plugin-wcrp", ]