From b81cfae3a5472103b5095ff1d6a37f5c085707e7 Mon Sep 17 00:00:00 2001 From: mferrera Date: Mon, 2 Oct 2023 08:34:06 +0200 Subject: [PATCH] CLN: Update ci workflows --- .flake8 | 2 +- .github/actions/build-xtgeo/action.yml | 23 ---------- .github/actions/setup_testdata/action.yml | 9 ++++ .github/actions/setup_xtgeo/action.yml | 21 ++++++++++ .github/actions/test_setup/action.yml | 17 -------- .github/workflows/build_docs.yml | 12 +++--- .github/workflows/linting.yml | 34 ++++++++++----- .github/workflows/test.yml | 51 +++++++++++++++++------ .gitignore | 1 + 9 files changed, 101 insertions(+), 69 deletions(-) delete mode 100644 .github/actions/build-xtgeo/action.yml create mode 100644 .github/actions/setup_testdata/action.yml create mode 100644 .github/actions/setup_xtgeo/action.yml delete mode 100644 .github/actions/test_setup/action.yml diff --git a/.flake8 b/.flake8 index 4c7aaf9cd..f44d282a4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -exclude = docs/conf.py, src/xtgeo/cxtgeo/*.py, .eggs, _skbuild, tests/**/snapshots max-line-length = 88 ignore = E402, W503, E203, C901 +exclude = docs/conf.py, src/xtgeo/cxtgeo/*.py, .eggs, tests/**/snapshots, _theversion.py diff --git a/.github/actions/build-xtgeo/action.yml b/.github/actions/build-xtgeo/action.yml deleted file mode 100644 index c49928c7c..000000000 --- a/.github/actions/build-xtgeo/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Build -description: builds xtgeo - -inputs: - python-version: - required: true - - -runs: - using: "composite" - steps: - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ inputs.python-version }} - - - name: Upgrade pip - run: python -m pip install pip -U - shell: bash - - - name: install xtgeo - run: pip install . - shell: bash diff --git a/.github/actions/setup_testdata/action.yml b/.github/actions/setup_testdata/action.yml new file mode 100644 index 000000000..557f9d54d --- /dev/null +++ b/.github/actions/setup_testdata/action.yml @@ -0,0 +1,9 @@ +name: Setup xtgeo testdata +description: Set up the xtgeo test environment + +runs: + using: "composite" + steps: + - name: Install test data + shell: bash + run: git clone --depth 1 https://github.com/equinor/xtgeo-testdata ../xtgeo-testdata diff --git a/.github/actions/setup_xtgeo/action.yml b/.github/actions/setup_xtgeo/action.yml new file mode 100644 index 000000000..22e67f670 --- /dev/null +++ b/.github/actions/setup_xtgeo/action.yml @@ -0,0 +1,21 @@ +name: Setup xtgeo +description: Set up the xtgeo test environment + +inputs: + python-version: + required: true + type: string + +runs: + using: "composite" + steps: + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: Build and install xtgeo + shell: bash + run: | + pip install -U pip + pip install ".[dev]" diff --git a/.github/actions/test_setup/action.yml b/.github/actions/test_setup/action.yml deleted file mode 100644 index 1b9d77389..000000000 --- a/.github/actions/test_setup/action.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: "Set up for tests" -description: "Set up the xtgeo test environment" - -inputs: - python-version: - required: true - -runs: - using: "composite" - steps: - - uses: "./.github/actions/build-xtgeo" - with: - python-version: ${{ inputs.python-version }} - - run: git clone --depth 1 https://github.com/equinor/xtgeo-testdata ../xtgeo-testdata - shell: bash - - run: pip install -r requirements/requirements_test.txt - shell: bash diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index a8e0c64aa..70acc71dd 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -10,12 +10,14 @@ jobs: build_docs: name: Build docs runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - uses: "./.github/actions/build-xtgeo" + - uses: actions/checkout@v4 with: - python-version: 3.9 - - name: Install doc requirements - run: pip install -r requirements/requirements_docs.txt + fetch-depth: 0 + + - name: Install xtgeo + run: pip install ".[docs]" + - name: Build docs run: sphinx-build -W docs tmp/docs diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 1bac276b1..1c5af2afc 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,4 +1,4 @@ -name: linting +name: Linting on: [push, pull_request] @@ -6,14 +6,26 @@ jobs: linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 with: - python-version: "3.10" - - name: Check black style and linting - run: | - pip install black - pip freeze - black --check *.py src tests --extend-exclude tests/**/snapshots --extend-exclude src/xtgeo/grid3d/grid_properties.py - pip install flake8 - flake8 src tests + fetch-depth: 0 + + - name: Setup xtgeo + uses: "./.github/actions/setup_xtgeo" + with: + python-version: 3.11 + + - name: List dependencies + run: pip freeze + + - name: Lint with isort + if: ${{ always() }} + run: isort --check-only src tests + + - name: Lint with black + if: ${{ always() }} + run: black src tests + + - name: Lint with flake8 + if: ${{ always() }} + run: flake8 src tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25a245ac4..e2cc57f7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,49 +23,76 @@ jobs: python-version: 3.11 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: "./.github/actions/test_setup" + + - name: Setup xtgeo + uses: "./.github/actions/setup_xtgeo" with: python-version: ${{ matrix.python-version }} - - name: Run test - run: python -m pytest --disable-warnings -x --hypothesis-profile ci-fast + + - name: Setup testdata + uses: "./.github/actions/setup_testdata" + + - name: Run fast tests + run: pytest --disable-warnings -x --hypothesis-profile ci-fast + hypothesis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: "./.github/actions/test_setup" + + - name: Setup xtgeo + uses: "./.github/actions/setup_xtgeo" with: python-version: 3.9 + + - name: Setup testdata + uses: "./.github/actions/setup_testdata" + - name: Run just hypothesis tests with more examples run: python -m pytest --disable-warnings -x -m hypothesis --hypothesis-profile ci --generate-plots + big: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: "./.github/actions/test_setup" + + - name: Setup xtgeo + uses: "./.github/actions/setup_xtgeo" with: python-version: 3.9 + + - name: Setup testdata + uses: "./.github/actions/setup_testdata" + - name: Run just tests marked big run: XTG_BIGTEST=1 python -m pytest --disable-warnings -x -m bigtest --hypothesis-profile ci --generate-plots + codecov: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: "./.github/actions/test_setup" + + - name: Setup xtgeo + uses: "./.github/actions/setup_xtgeo" with: python-version: 3.9 - - name: "Install codecov" - run: pip install pytest-cov + + - name: Setup testdata + uses: "./.github/actions/setup_testdata" + + - name: Generate coverage report run: pytest tests --doctest-modules --generate-plots --disable-warnings --cov=xtgeo --hypothesis-profile ci-fast --cov-report=xml:xtgeocoverage.xml; + - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 with: diff --git a/.gitignore b/.gitignore index 960674f96..8d75d7692 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,4 @@ pip-wheel-metadata/ .vscode/ .venv*/ .nfs* +tmp/