diff --git a/.ci/manifest.toml b/.ci/manifest.toml new file mode 100644 index 000000000..0d43b2a37 --- /dev/null +++ b/.ci/manifest.toml @@ -0,0 +1,74 @@ +# An island for now: eccodes, eckit, metkit, mir, odc, fdb, gribjump, cfgrib, and pdbufr come from PyPI. +[[deps]] +build-type-input = "python-build-type" +compiler-inputs = [] +package = "multiurl" +python-version-input = "python-version" +ref = "develop" +repo = "ecmwf/multiurl" + +[[deps]] +build-type-input = "python-build-type" +compiler-inputs = [] +package = "earthkit-utils" +python-version-input = "python-version" +ref = "develop" +repo = "ecmwf/earthkit-utils" + +[[deps]] +build-type-input = "python-build-type" +compiler-inputs = [] +package = "earthkit-geo" +python-version-input = "python-version" +ref = "develop" +repo = "ecmwf/earthkit-geo" + +[matrix.test] +triggers = ["upstream-change", "rebuild-request"] + +[matrix.test.defaults] +container = "eccr.ecmwf.int/public-ci-images/ubuntu24.04-base:latest" +extras = "all,test,ci" +job-script = "./.ci/test.sh.j2" +platform = "ubuntu-24.04" +python-build-type = "Release" +runs-on = "ubuntu-latest" + +[[matrix.test.include]] +python-version = "3.12" + +[[matrix.test.include]] +python-version = "3.13" + +[package] +allow-stale-deps = true +ci-pre-commit = false +compiler-inputs = [] +full-history = true +name = "earthkit-data" +repo = "ecmwf/earthkit-data" +visibility = "public" + +[[trigger-downstream]] +ref = "develop" +repo = "ecmwf/earthkit-transforms" + +[[trigger-downstream]] +ref = "main" +repo = "ecmwf/earthkit-workflows" + +[[trigger-downstream]] +ref = "develop" +repo = "ecmwf/earthkit-hydro" + +[[trigger-downstream]] +ref = "develop" +repo = "ecmwf/earthkit-meteo" + +[[trigger-downstream]] +ref = "develop" +repo = "ecmwf/earthkit-plots" + +[[trigger-downstream]] +ref = "develop" +repo = "ecmwf/earthkit" diff --git a/.ci/test.sh.j2 b/.ci/test.sh.j2 new file mode 100644 index 000000000..bfa00e125 --- /dev/null +++ b/.ci/test.sh.j2 @@ -0,0 +1,8 @@ +{% extends "ci-infrastructure/python-runner.sh.j2" %} +{% block test %} +cd "$CI_SOURCE_DIR" +python -m pytest -vv -m 'not notebook and not no_cache_init' -k 'not netcdf' --cov=. --cov-report=xml +python -m pytest -v -m 'notebook' +python -m pytest --forked -vv -m 'no_cache_init' -k 'not netcdf' +python -m coverage report +{% endblock %} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3d21c2de2..0b929ab4d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,6 +2,7 @@ # BEGIN org baseline: maintainers own .github/ and CODEOWNERS (ci-infrastructure scripts/apply-codeowners.sh) /.github/ @JamesVarndell @sandorkertesz +/.ci/ @JamesVarndell @sandorkertesz /CODEOWNERS @JamesVarndell @sandorkertesz /docs/CODEOWNERS @JamesVarndell @sandorkertesz # END org baseline diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a22b06e1a..78f12c317 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,36 +1,141 @@ -name: ci +# GENERATED FILE - DO NOT EDIT. +# Regenerate via the ci-infrastructure-generate CLI. +# Source of truth: each repo's .ci/manifest.toml. +name: CI + on: - # Trigger the workflow on push to master or develop, except tag creation push: - branches: - - "main" - - "develop" - tags-ignore: - - "**" - paths-ignore: - - "docs/**" - - "README.md" - # Trigger the workflow on pull request + branches: [develop, master, main] pull_request: - paths-ignore: - - "docs/**" - - "README.md" - # Trigger the workflow manually + types: [opened, reopened, synchronize] workflow_dispatch: + schedule: + - cron: "13 4 * * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +env: + ARTIFACT_POLL_INTERVAL: ${{ vars.ARTIFACT_POLL_INTERVAL || '60' }} + ARTIFACT_WAIT_TIMEOUT: ${{ vars.ARTIFACT_WAIT_TIMEOUT || '1800' }} + ARTIFACT_S3_ENDPOINT: ${{ secrets.ARTIFACT_S3_ENDPOINT }} + ARTIFACT_S3_BUCKET: ${{ secrets.ARTIFACT_S3_BUCKET }} + SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + jobs: - # Run CI including downstream packages on self-hosted runners - downstream-ci: - name: downstream-ci - uses: ecmwf/downstream-ci/.github/workflows/downstream-ci.yml@main - with: - earthkit-data: ecmwf/earthkit-data@${{ github.event.pull_request.head.sha || github.sha }} - codecov_upload: true - python_qa: false - secrets: inherit - # Build downstream packages on HPC - downstream-ci-hpc: - name: downstream-ci-hpc - uses: ecmwf/downstream-ci/.github/workflows/downstream-ci-hpc.yml@main - with: - earthkit-data: ecmwf/earthkit-data@${{ github.event.pull_request.head.sha || github.sha }} - secrets: inherit + ci-approval: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: ecmwf/ci-infrastructure/actions/require-ci-approval@main + + resolve: + needs: ci-approval + runs-on: ubuntu-latest + outputs: + matrices: ${{ steps.r.outputs.json }} + dispatch-plans: ${{ steps.r.outputs.dispatch-plans }} + steps: + - id: mint + uses: ecmwf/ci-infrastructure/actions/mint-token@main + with: + client-id: ${{ vars.CI_READER_APP_CLIENT_ID }} + private-key: ${{ secrets.CI_READER_APP_PRIVATE_KEY }} + repositories: earthkit-data,earthkit-geo,earthkit-utils,multiurl + permissions: contents:read actions:read + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 + - id: r + uses: ecmwf/ci-infrastructure/actions/resolve-deps@main + with: + matrix: test + token: ${{ steps.mint.outputs.token }} + rebuild-missing: 'true' + - name: Wait for the deps of test + if: steps.r.outputs.dispatch-plans == '[]' + uses: ecmwf/ci-infrastructure/actions/wait-for-deps@main + with: + matrix: ${{ steps.r.outputs.json }} + kinds: test + token: ${{ steps.mint.outputs.token }} + name: resolve + wait-build + + rebuild-producers: + needs: [ci-approval, resolve] + runs-on: ubuntu-latest + steps: + - if: needs.resolve.outputs.dispatch-plans != '' && needs.resolve.outputs.dispatch-plans != '[]' + uses: ecmwf/ci-infrastructure/actions/dispatch-producers@main + with: + dispatch-plans: ${{ needs.resolve.outputs.dispatch-plans }} + repositories: earthkit-data,earthkit-geo,earthkit-utils,multiurl + client-id: ${{ vars.CI_DISPATCHER_APP_CLIENT_ID }} + app-private-key: ${{ secrets.CI_DISPATCHER_APP_PRIVATE_KEY }} + + test: + needs: [ci-approval, resolve, rebuild-producers] + name: test (${{ matrix._resolved['job-name'] }}) + runs-on: ${{ matrix['runs-on'] }} + container: + image: ${{ matrix.container || '' }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.resolve.outputs.matrices).test }} + steps: + - name: Announce image + uses: ecmwf/ci-infrastructure/actions/announce-image@main + - id: mint + uses: ecmwf/ci-infrastructure/actions/mint-token@main + with: + client-id: ${{ vars.CI_READER_APP_CLIENT_ID }} + private-key: ${{ secrets.CI_READER_APP_PRIVATE_KEY }} + repositories: earthkit-data,earthkit-geo,earthkit-utils,multiurl + permissions: contents:read actions:read + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 + - name: Fetch resolved deps + id: deps + uses: ecmwf/ci-infrastructure/actions/fetch-deps@main + with: + deps-json: ${{ toJSON(matrix._resolved.deps) }} + token: ${{ steps.mint.outputs.token }} + - name: Print dependency table + uses: ecmwf/ci-infrastructure/actions/print-dep-table@main + with: + resolved: ${{ toJSON(matrix._resolved) }} + - name: Build + id: build + uses: ecmwf/ci-infrastructure/actions/run-job-script@main + with: + job-script: ${{ matrix.job-script }} + matrix-leg: ${{ toJSON(matrix) }} + package: earthkit-data + cmake-prefix-path: ${{ steps.deps.outputs.cmake-prefix-path }} + - name: Publish + uses: ecmwf/ci-infrastructure/actions/publish-artifact@main + with: + install-path: ${{ steps.build.outputs.install-path }} + artifact-name: ${{ matrix._resolved['own-artifact-name'] }} + + ci-result: + name: collect results + if: always() + needs: [ci-approval, resolve, test] + runs-on: ubuntu-latest + permissions: + statuses: write + steps: + - uses: ecmwf/ci-infrastructure/actions/ci-result@main + with: + needs: ${{ toJSON(needs) }} diff --git a/.github/workflows/label-public-pr.yml b/.github/workflows/label-public-pr.yml deleted file mode 100644 index e9a26b0ec..000000000 --- a/.github/workflows/label-public-pr.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Manage labels of pull requests that originate from forks -name: label-public-pr -on: - pull_request_target: - types: [opened, synchronize] -jobs: - label: - uses: ecmwf/reusable-workflows/.github/workflows/label-pr.yml@v2 diff --git a/.github/workflows/old_CI.yml b/.github/workflows/old_CI.yml new file mode 100644 index 000000000..561108076 --- /dev/null +++ b/.github/workflows/old_CI.yml @@ -0,0 +1,36 @@ +name: old CI + +on: + # Trigger the workflow after the new CI succeeded on a push + workflow_run: + workflows: [CI] + types: [completed] + branches: + - "main" + - "develop" + + # Trigger the workflow manually + workflow_dispatch: + +jobs: + # Run CI including downstream packages on self-hosted runners + downstream-ci: + name: downstream-ci + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success') }} + uses: ecmwf/downstream-ci/.github/workflows/downstream-ci.yml@main + with: + ci_group: only-self + earthkit-data: ecmwf/earthkit-data@${{ github.event.workflow_run.head_sha || github.sha }} + codecov_upload: true + python_qa: false + secrets: inherit + + # Build downstream packages on HPC + downstream-ci-hpc: + name: downstream-ci-hpc + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success') }} + uses: ecmwf/downstream-ci/.github/workflows/downstream-ci-hpc.yml@main + with: + ci_group: only-self + earthkit-data: ecmwf/earthkit-data@${{ github.event.workflow_run.head_sha || github.sha }} + secrets: inherit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef9babeb8..e71554a38 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,8 @@ repos: hooks: - id: pretty-format-yaml args: [--autofix, --preserve-quotes] + # Written by the ci-infrastructure regenerator, which would undo the formatting. + exclude: ^\.github/workflows/(ci|ci-fork|cross-repo-trigger.*|trigger-downstream.*|pr-label-.*|pr-sync-branch|retry-nightly)\.yml$ - id: pretty-format-toml args: [--autofix] - repo: https://github.com/sphinx-contrib/sphinx-lint