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/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..7661e8a3f 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,19 +1,25 @@ -name: linting +name: Linting on: [push, pull_request] jobs: linting: runs-on: ubuntu-latest + uses: ./.github/workflows/setup_tests.yml + with: + python-version: 3.11 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@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 + - 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/setup_tests.yml b/.github/workflows/setup_tests.yml new file mode 100644 index 000000000..9a93f594d --- /dev/null +++ b/.github/workflows/setup_tests.yml @@ -0,0 +1,29 @@ +name: Setup tests +description: Set up the xtgeo test environment + +on: + workflow_call: + inputs: + python-version: + required: true + type: string + +runs: + steps: + - name: Checkout commit + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: Install test data + run: git clone --depth 1 https://github.com/equinor/xtgeo-testdata ../xtgeo-testdata + + - name: Build and install xtgeo + run: | + pip install -U pip + pip install ".[dev]" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25a245ac4..f1539f9af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,50 +22,43 @@ jobs: - os: windows-latest python-version: 3.11 runs-on: ${{ matrix.os }} + uses: ./.github/workflows/setup_tests.yml + with: + python-version: ${{ matrix.python-version }} + steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: "./.github/actions/test_setup" - with: - python-version: ${{ matrix.python-version }} - - name: Run test - run: python -m pytest --disable-warnings -x --hypothesis-profile ci-fast + - name: Run fast tests + run: pytest --disable-warnings -x --hypothesis-profile ci-fast + hypothesis: runs-on: ubuntu-latest + uses: ./.github/workflows/setup_tests.yml + with: + python-version: 3.9 steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: "./.github/actions/test_setup" - with: - python-version: 3.9 + - 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 + uses: ./.github/workflows/setup_tests.yml + with: + python-version: 3.9 steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: "./.github/actions/test_setup" - with: - python-version: 3.9 - 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 + uses: ./.github/workflows/setup_tests.yml + with: + python-version: 3.9 steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: "./.github/actions/test_setup" - with: - python-version: 3.9 - - name: "Install codecov" - run: pip install pytest-cov + - 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/