Skip to content

Commit

Permalink
Make conftest configurable with envs (#1787)
Browse files Browse the repository at this point in the history
Signed-off-by: Fotis Nikolaidis <[email protected]>
Co-authored-by: Fotis Nikolaidis <[email protected]>
  • Loading branch information
kartik4949 and fnikolai authored Feb 17, 2024
1 parent b2aaabb commit 33da0c7
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 271 deletions.
192 changes: 108 additions & 84 deletions .github/workflows/ci_code.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,139 @@
name: Code Testing

on: # rules for when this action will be triggered
on:
pull_request:
branches:
- main
paths: # Paths that may affect code quality
paths-ignore:
- 'docs/**'
- '**/*.md'
- '**/*.rst'
- '**/*.json'
- ".github/**"
workflow_dispatch: # allows triggering a GitHub action manually - see 'Actions' tab
- 'docs/**'
- 'examples/**'
- '*.md'
- '*.rst'
workflow_dispatch:


# When this workflow is queued, automatically cancel any previous running
# or pending jobs from the same branch
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
code-testing:
# ---------------------------------
# Unit Testing
# ---------------------------------
unit-testing:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ] # TODO: add "windows-latest", "macos-latest" when Docker removed
python-version: ["3.10", "3.11"] # Due to cache limitations, check only the earliest and the latest.

os: [ "ubuntu-latest" ]
python-version: ["3.10", "3.11"]
steps:
- name: Check out repository
uses: actions/checkout@v3

# Remind users to update changelog
- name: Check Changelog Action
uses: tarides/changelog-check-action@v2
with:
changelog: CHANGELOG.md

#---------------------------------------------------
# Configuring Python environments.
#
# We intentionally commented the `cache` field to remind us not to enable it.
# The reason is that most of the time is spent on package installation rather than package downloading.
# As a result, in the next step, we will cache the complete Python environment, including all pre-installed components.
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
#cache: 'pip' # Do not activate

- name: Cache Python ${{ matrix.python-version }}
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ matrix.os }}_python-${{ matrix.python-version }}_${{ hashFiles('pyproject.toml', '*/pyproject.toml')}}

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

- name: Validate Changelog Update
uses: tarides/changelog-check-action@v2
with:
changelog: CHANGELOG.md

#---------------------------------------------------
# Configuring Python environments.
#
# We cache both the pip packages and the installation dir.
# If the pyproject remains unchanged, we re-use the existing installation dir.
# If the pyproject has changed, we reinstall everything using the cached pip packages.
- name: Cache Pip Packages
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies

- name: Cache Python Installation
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }} # Cache the whole python installation dir.
key: ${{ matrix.os }}_python-${{ matrix.python-version }}_${{ hashFiles('pyproject.toml', '*/pyproject.toml') }}
#---------------------------------------------------

- name: Install Dependencies
run: python -m pip install .[dev]
- name: Install SuperDuperDB Project
run: |
# Install core and testsuite dependencies on the cached python environment.
python -m pip install .[testsuite]
- name: Install DevKit (docs, testing, etc)
run: |
make install-devkit
- name: Check core imports
run: |
# This job checks that no optional dependencies are imported in the core code.
python -m pip install impall==1.3.1
python -m impall --NO_CLEAR_SYS_MODULES -E 'test**:superduperdb/ext**'
- name: Lint and type-check
run: |
make lint-and-type-check
- name: Unit Testing
run: |
make unit-testing PYTEST_ARGUMENTS="--cov=superduperdb --cov-report=xml"
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
with:
env_vars: RUNNER_OS,PYTHON_VERSION
file: ./coverage.xml
fail_ci_if_error: false
name: codecov-umbrella

# ---------------------------------
# Integration Testing
# ---------------------------------
integration-testing:
needs: [ 'unit-testing' ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check core imports
#---------------------------------------------------
# Build Docker Image in Cached Environment
# - uses: docker/setup-buildx-action@v3
# - uses: docker/build-push-action@v5
# with:
# file: /home/runner/work/superduperdb/superduperdb/deploy/images/superduperdb/Dockerfile
# context: /home/runner/work/superduperdb/superduperdb
# load: true # Load output to Docker images
# tags: superduperdb/sandbox:latest
# cache-from: type=gha
# cache-to: type=gha,mode=max
# build-args: |
# "BUILD_ENV=sandbox"
# "SUPERDUPERDB_EXTRAS=dev"
# -------------------------------------------------

- name: Build Docker Image
run: |
# This job checks that no optional dependencies are imported in the core code.
python -m pip install impall==1.3.1
python -m impall --NO_CLEAR_SYS_MODULES -E 'test**:superduperdb/ext**'
make testenv_image
- name: Basic health check
- name: Start Testing Environment
run: |
black --version
ruff --version
mypy --version
# Update hostnames
echo 127.0.0.1 mongodb | sudo tee -a /etc/hosts
- name: Lint and type-check
run: |
make lint-and-type-check
# Run the integrated testing environment
make testenv_init
- name: Unit Testing
- name: Integration Testing
run: |
make unit-testing PYTEST_ARGUMENTS="--cov=superduperdb --cov-report=xml"
- name: Cleanup Docker
run: |
docker system prune -af
# Run the test-suite within the sandbox image from the test environment
docker exec testenv-sandbox-1 sh -c 'make install-devkit && make integration-testing'
- name: Integration Testing
if: ${{ startsWith(matrix.python-version, '3.11') }} # Dask requires local python and Dockerfile to be in sync
- name: Shutdown Testing Environment
run: |
# Update hostnames
echo 127.0.0.1 mongodb | sudo tee -a /etc/hosts
# Build sandbox image for testing.
make testenv_image
# Run the integrated testing environment
make testenv_init
# Run the test-suite
make integration-testing PYTEST_ARGUMENTS="--cov=superduperdb --cov-report=xml"
# Destroy the testing environment
make testenv_shutdown
# Remove the data directory
sudo rm -rf deploy/testenv/.test_data
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
with:
env_vars: RUNNER_OS,PYTHON_VERSION
file: ./coverage.xml
fail_ci_if_error: false
name: codecov-umbrella
6 changes: 4 additions & 2 deletions .github/workflows/ci_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths: # run this action only when the docs folder is changed
- 'docs/hr/content/**'
- 'docs/hr/blog/**'
- 'docs/hr/*.js'
workflow_dispatch: # allows triggering a GitHub action manually - see 'Actions' tab


Expand Down Expand Up @@ -42,8 +43,9 @@ jobs:
${{ env.pythonLocation }}
key: ubuntu-latest_python-3.11_${{ hashFiles('pyproject.toml', '*/pyproject.toml') }}

- name: Install dependencies
run: pip install .[docs]
- name: Install DevKit (docs, testing, etc)
run: |
make install-devkit
- name: Build docs
run: |
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker Cache
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Push Base Docker image
run: |
make build_superduperdb
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changes Since Last Release

#### Changed defaults / behaviours
-
- Run Tests from within the container

#### New Features & Functionality
- CI fails if CHANGELOG.md is not updated on PRs
Expand All @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

#### Changed defaults / behaviours

- Test suite takes config from external .env file.
- Support 3.10+ due to `dataclass` supported features
- Updated the table creation method in MetaDataStore to improve compatibility across various databases.
- Replaced JSON data with String format before storage in SQLAlchemy.
Expand Down
Loading

0 comments on commit 33da0c7

Please sign in to comment.