Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): changes to decrease build time, cancel runs in case of multiple commits #5187

Merged
merged 19 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
release:
types: [published, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/check-datahub-jars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
release:
types: [published, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

check_jars:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker-unified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
release:
types: [published, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means cancelling only those in progress for the same PR right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same branch


env:
DATAHUB_GMS_IMAGE: 'linkedin/datahub-gms'
DATAHUB_FRONTEND_IMAGE: 'linkedin/datahub-frontend-react'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
# release:
# types: [published, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
gh-pages:
runs-on: ubuntu-latest
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/metadata-ingestion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ on:
release:
types: [published, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

metadata-ingestion-general:
runs-on: ubuntu-latest
env:
SPARK_VERSION: 3.0.3
DATAHUB_TELEMETRY_ENABLED: false
strategy:
matrix:
python-version: ["3.6", "3.9"]
Expand All @@ -29,30 +34,28 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: vemonet/setup-spark@v1 # spark is required for pyspark+pydeequ data lake profiling
with:
spark-version: '3.0.3'
hadoop-version: '3.2'
- name: Install dependencies
run: ./metadata-ingestion/scripts/install_deps.sh
- name: Run metadata-ingestion tests
run: ./gradlew :metadata-ingestion:build :metadata-ingestion:check
run: ./gradlew :metadata-ingestion:build :metadata-ingestion:testQuick :metadata-ingestion:check
- uses: actions/upload-artifact@v2
if: always()
with:
name: Test Results (metadata ingestion general)
name: Test Results (metadata ingestion ${{ matrix.python-version }} testQuick)
path: |
**/build/reports/tests/test/**
**/build/test-results/test/**
**/junit.*.xml

metadata-ingestion-by-version:
metadata-ingestion:
runs-on: ubuntu-latest
env:
SPARK_VERSION: 3.0.3
DATAHUB_TELEMETRY_ENABLED: false
strategy:
matrix:
python-version: ["3.6", "3.9"]
command: ["installAirflow1", "testIntegration", "testSlowIntegration"]
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand All @@ -64,11 +67,9 @@ jobs:
spark-version: '3.0.3'
hadoop-version: '3.2'
- name: Install dependencies
run: ./metadata-ingestion/scripts/install_deps.sh && python -m pip install --upgrade pip && pip install tox tox-gh-actions
- name: Codegen
run: ./gradlew :metadata-ingestion:codegen
- name: Run tox tests
run: cd metadata-ingestion && tox
run: ./metadata-ingestion/scripts/install_deps.sh
- name: Run metadata-ingestion tests
run: ./gradlew :metadata-ingestion:build :metadata-ingestion:${{ matrix.command }} -x:metadata-ingestion:testQuick -x:metadata-ingestion:check
- uses: actions/upload-artifact@v2
if: always()
with:
Expand Down
25 changes: 19 additions & 6 deletions metadata-ingestion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ task testQuick(type: Exec, dependsOn: installDev) {
inputs.files(project.fileTree(dir: "tests/"))
outputs.dir("${venv_name}")
commandLine 'bash', '-x', '-c',
"source ${venv_name}/bin/activate && pytest -m 'not integration and not slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.quick.xml"
"source ${venv_name}/bin/activate && pytest --durations=20 -m 'not slow_unit and not integration and not slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.quick.xml"
}

task installDevTest(type: Exec, dependsOn: [installDev]) {
task installDevTest(type: Exec, dependsOn: [install]) {
inputs.file file('setup.py')
outputs.dir("${venv_name}")
outputs.file("${venv_name}/.build_install_dev_test_sentinel")
Expand All @@ -109,14 +109,27 @@ task testSingle(dependsOn: [installDevTest]) {
}
}

task testFull(type: Exec, dependsOn: [testQuick, installDevTest]) {
task installAirflow1(type: Exec, dependsOn: [install]) {
inputs.file file('setup.py')
outputs.dir("${venv_name}")
outputs.file("${venv_name}/.build_install_airflow_sentinel")
commandLine 'bash', '-x', '-c',
"${venv_name}/bin/pip install -e .[dev-airflow1] -c tests/airflow1-constraints.txt && touch ${venv_name}/.build_install_airflow_sentinel"
}

task testIntegration(type: Exec, dependsOn: [installDevTest]) {
commandLine 'bash', '-x', '-c',
"source ${venv_name}/bin/activate && pytest --durations=50 -m 'not slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.integration.xml"
}

task testFull(type: Exec, dependsOn: [installDevTest]) {
commandLine 'bash', '-x', '-c',
"source ${venv_name}/bin/activate && pytest -m 'not slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.full.xml"
"source ${venv_name}/bin/activate && pytest --durations=50 -vv --continue-on-collection-errors --junit-xml=junit.full.xml"
}

task testSlowIntegration(type: Exec, dependsOn: [testQuick, installDevTest]) {
task testSlowIntegration(type: Exec, dependsOn: [installDevTest]) {
commandLine 'bash', '-x', '-c',
"source ${venv_name}/bin/activate && pytest -m 'slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.full.xml"
"source ${venv_name}/bin/activate && pytest --durations=20 -m 'slow_integration' -vv --continue-on-collection-errors --junit-xml=junit.slow.integration.xml"
}

task docGen(type: Exec, dependsOn: [codegen, installDevTest]) {
Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ disallow_untyped_defs = yes
asyncio_mode = auto
addopts = --cov=src --cov-report term-missing --cov-config setup.cfg --strict-markers
markers =
slow_unit: marks tests to only run slow unit tests (deselect with '-m not slow_unit')
integration: marks tests to only run in integration (deselect with '-m "not integration"')
slow_integration: marks tests that are too slow to even run in integration (deselect with '-m "not slow_integration"')
slow_hana: marks tests that are too slow to even run in integration (deselect with '-m "not slow_hana"')
testpaths =
tests/unit
tests/integration
Expand Down
1 change: 0 additions & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ def get_long_description():
"pytest-asyncio>=0.16.0",
"pytest-cov>=2.8.1",
"pytest-docker>=0.10.3,<0.12",
"tox",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove tox?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also interested to know!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried parallelising via tox but there was some problem during builds. the build wheel being generated by the 3 test suites was stepping on each other's toes and causing at least one of them to fail. Also, thought it might be better to do it via github actions so we can easily parallelise and isolate. Now if that SAP HANA test flakes we can simply re-run that (that and nifi one under slow integration) one instead of all integration tests.

"deepdiff",
"requests-mock",
"freezegun",
Expand Down
9 changes: 9 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/graph/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import os
from json.decoder import JSONDecodeError
from typing import Any, Dict, List, Optional, Type

Expand All @@ -24,6 +25,11 @@
logger = logging.getLogger(__name__)


telemetry_enabled = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this guy in here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in case we had file sink this was causing telemetry client id to fetched. In case telemetry is disabled it should not be doing that.

For unit tests this was doing 3 retries and failing. Adding this and passing the environment variable reduced time for unit tests by 30-60 secs.

os.environ.get("DATAHUB_TELEMETRY_ENABLED", "true").lower() == "true"
)


class DatahubClientConfig(ConfigModel):
"""Configuration class for holding connectivity to datahub gms"""

Expand Down Expand Up @@ -51,6 +57,9 @@ def __init__(self, config: DatahubClientConfig) -> None:
ca_certificate_path=self.config.ca_certificate_path,
)
self.test_connection()
if not telemetry_enabled:
self.server_id = "missing"
return
try:
client_id: Optional[TelemetryClientIdClass] = self.get_aspect_v2(
"urn:li:telemetry:clientId", TelemetryClientIdClass, "telemetryClientId"
Expand Down
2 changes: 2 additions & 0 deletions metadata-ingestion/tests/integration/s3/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def s3_populate(pytestconfig, s3_resource, s3_client, bucket_name):
source_files = os.listdir(SOURCE_FILES_PATH)


@pytest.mark.slow_unit
@pytest.mark.parametrize("source_file", source_files)
def test_data_lake_s3_ingest(
pytestconfig, s3_populate, source_file, tmp_path, mock_time
Expand Down Expand Up @@ -101,6 +102,7 @@ def test_data_lake_s3_ingest(
)


@pytest.mark.slow_unit
@pytest.mark.parametrize("source_file", source_files)
def test_data_lake_local_ingest(pytestconfig, source_file, tmp_path, mock_time):
test_resources_dir = pytestconfig.rootpath / "tests/integration/s3/"
Expand Down
2 changes: 2 additions & 0 deletions metadata-ingestion/tests/integration/tableau/test_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pathlib
from unittest import mock

import pytest
from freezegun import freeze_time

from datahub.ingestion.run.pipeline import Pipeline
Expand Down Expand Up @@ -40,6 +41,7 @@ def side_effect_query_metadata(query):


@freeze_time(FROZEN_TIME)
@pytest.mark.slow_unit
def test_tableau_ingest(pytestconfig, tmp_path):

global test_resources_dir
Expand Down
45 changes: 0 additions & 45 deletions metadata-ingestion/tox.ini

This file was deleted.