mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-04 12:36:23 +00:00
[issue-1976] - Ingestion SonarCloud (#2085)
* Update path * Prepare sonar properties * Prepare coverage recipes * Add coverage * Simplify pytest * Organise integration tests * Update path * Use setup instead of reqs * Update recipes * Fix PR event to target * Update event_name * Prepare sonar * Run tests & sonar * Use sonarcloud host * Fix compose * Use ingestion token
This commit is contained in:
parent
c8de136cca
commit
48ebcffbd0
4
.github/workflows/maven-build.yml
vendored
4
.github/workflows/maven-build.yml
vendored
@ -17,7 +17,7 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- "catalog-rest-service/**"
|
- "catalog-rest-service/**"
|
||||||
- "openmetadata-ui/**"
|
- "openmetadata-ui/**"
|
||||||
pull_request:
|
pull_request_target:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- "catalog-rest-service/**"
|
- "catalog-rest-service/**"
|
||||||
@ -52,7 +52,7 @@ jobs:
|
|||||||
- name: Build PR with Maven
|
- name: Build PR with Maven
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request_target' }}
|
||||||
run: |
|
run: |
|
||||||
git fetch --no-tags https://github.com/open-metadata/OpenMetadata.git +refs/heads/main:refs/remotes/origin/main
|
git fetch --no-tags https://github.com/open-metadata/OpenMetadata.git +refs/heads/main:refs/remotes/origin/main
|
||||||
mvn -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
|
mvn -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
|
||||||
|
|||||||
@ -16,12 +16,12 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- ingestion/**
|
- ingestion/**
|
||||||
pull_request:
|
pull_request_target:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- ingestion/**
|
- ingestion/**
|
||||||
jobs:
|
jobs:
|
||||||
run_integration_tests:
|
run_tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -30,22 +30,48 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
|
||||||
- name: Start Server and Ingest Sample Data
|
- name: Start Server and Ingest Sample Data
|
||||||
run: ./docker/run_local_docker.sh
|
run: ./docker/run_local_docker.sh
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
|
|
||||||
- name: Install Ubuntu dependencies
|
- name: Install Ubuntu dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y libsasl2-dev unixodbc-dev python3-venv
|
sudo apt-get install -y libsasl2-dev unixodbc-dev python3-venv
|
||||||
|
|
||||||
- name: Install open-metadata dependencies
|
- name: Install open-metadata dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
source env/bin/activate
|
source env/bin/activate
|
||||||
make install_test install_dev generate install
|
make install_test install_dev generate
|
||||||
- name: Run Python Integration Tests
|
|
||||||
|
- name: Run Python Tests & record coverage
|
||||||
run: |
|
run: |
|
||||||
source env/bin/activate
|
source env/bin/activate
|
||||||
make run_ometa_integration_tests
|
make coverage
|
||||||
|
|
||||||
|
- name: Run PR Sonar
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
if: ${{ github.event_name == 'pull_request_target' }}
|
||||||
|
run: |
|
||||||
|
git fetch --no-tags https://github.com/open-metadata/OpenMetadata.git +refs/heads/main:refs/remotes/origin/main
|
||||||
|
|
||||||
|
# Add PR analysis information
|
||||||
|
echo "\nsonar.pullrequest.key=${{ github.event.pull_request.number }}" >> ingestion/sonar-project.properties
|
||||||
|
echo "sonar.pullrequest.branch=${{ github.head_ref }}" >> ingestion/sonar-project.properties
|
||||||
|
echo "sonar.pullrequest.base=origin/main" >> ingestion/sonar-project.properties
|
||||||
|
echo "sonar.pullrequest.provider=github" >> ingestion/sonar-project.properties
|
||||||
|
|
||||||
|
make token=${{ secrets.INGESTION_SONAR_SECRET }} sonar_ingestion
|
||||||
|
|
||||||
|
- name: Run Sonar
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
run: make token=${{ secrets.INGESTION_SONAR_SECRET }} sonar_ingestion
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -84,4 +84,4 @@ ingestion/.python-version
|
|||||||
|
|
||||||
# MLFlow
|
# MLFlow
|
||||||
mlruns/
|
mlruns/
|
||||||
/ingestion/tests/integration/mlflow/tests/db/
|
/ingestion/tests/integration/source/mlflow/tests/db/
|
||||||
|
|||||||
25
Makefile
25
Makefile
@ -11,10 +11,10 @@ install:
|
|||||||
python3 -m pip install ingestion/
|
python3 -m pip install ingestion/
|
||||||
|
|
||||||
install_test:
|
install_test:
|
||||||
python3 -m pip install -r ingestion/requirements-test.txt
|
python3 -m pip install "ingestion[test]/"
|
||||||
|
|
||||||
install_dev:
|
install_dev:
|
||||||
python3 -m pip install -r ingestion/requirements-dev.txt
|
python3 -m pip install "ingestion[dev]/"
|
||||||
|
|
||||||
precommit_install:
|
precommit_install:
|
||||||
@echo "Installing pre-commit hooks"
|
@echo "Installing pre-commit hooks"
|
||||||
@ -39,8 +39,25 @@ generate:
|
|||||||
datamodel-codegen --input catalog-rest-service/src/main/resources/json --input-file-type jsonschema --output ingestion/src/metadata/generated
|
datamodel-codegen --input catalog-rest-service/src/main/resources/json --input-file-type jsonschema --output ingestion/src/metadata/generated
|
||||||
|
|
||||||
run_ometa_integration_tests:
|
run_ometa_integration_tests:
|
||||||
cd ingestion; \
|
coverage run -m pytest -c ingestion/setup.cfg --doctest-modules --junitxml=ingestion/junit/test-results-integration.xml --override-ini=testpaths="ingestion/tests/integration/ometa ingestion/tests/integration/stage"
|
||||||
pytest -c setup.cfg --override-ini=testpaths="tests/integration/ometa tests/unit/stage_test.py"
|
|
||||||
|
unit_ingestion:
|
||||||
|
coverage run -m pytest -c ingestion/setup.cfg -s --doctest-modules --junitxml=ingestion/junit/test-results-unit.xml --override-ini=testpaths="ingestion/tests/unit"
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
coverage erase
|
||||||
|
make unit_ingestion
|
||||||
|
make run_ometa_integration_tests
|
||||||
|
coverage xml -i -o ingestion/coverage.xml
|
||||||
|
|
||||||
|
sonar_ingestion:
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
-e SONAR_HOST_URL="https://sonarcloud.io" \
|
||||||
|
-e SONAR_LOGIN=$(token) \
|
||||||
|
-v ${PWD}:/usr/src \
|
||||||
|
sonarsource/sonar-scanner-cli \
|
||||||
|
-Dproject.settings=ingestion/sonar-project.properties
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
make install_dev generate
|
make install_dev generate
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
boto3==1.20.14
|
|
||||||
botocore==1.23.14
|
|
||||||
datamodel-code-generator==0.11.14
|
|
||||||
docker
|
|
||||||
google-cloud-storage==1.43.0
|
|
||||||
twine
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
black
|
|
||||||
isort
|
|
||||||
pre-commit
|
|
||||||
pylint
|
|
||||||
pytest
|
|
||||||
pytest-cov
|
|
||||||
faker
|
|
||||||
@ -33,7 +33,6 @@ indent=' '
|
|||||||
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = --cov src --cov-report term --cov-config setup.cfg --strict-markers
|
|
||||||
markers =
|
markers =
|
||||||
slow: marks tests as slow (deselect with '-m "not slow"')
|
slow: marks tests as slow (deselect with '-m "not slow"')
|
||||||
testpaths =
|
testpaths =
|
||||||
|
|||||||
@ -108,6 +108,24 @@ plugins: Dict[str, Set[str]] = {
|
|||||||
"okta": {"okta~=2.3.0"},
|
"okta": {"okta~=2.3.0"},
|
||||||
"mlflow": {"mlflow-skinny~=1.22.0"},
|
"mlflow": {"mlflow-skinny~=1.22.0"},
|
||||||
}
|
}
|
||||||
|
dev = {
|
||||||
|
"boto3==1.20.14",
|
||||||
|
"botocore==1.23.14",
|
||||||
|
"datamodel-code-generator==0.11.14",
|
||||||
|
"docker",
|
||||||
|
"google-cloud-storage==1.43.0",
|
||||||
|
"twine",
|
||||||
|
}
|
||||||
|
test = {
|
||||||
|
"black",
|
||||||
|
"isort",
|
||||||
|
"pre-commit",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"pytest-cov",
|
||||||
|
"faker",
|
||||||
|
"coverage",
|
||||||
|
}
|
||||||
|
|
||||||
build_options = {"includes": ["_cffi_backend"]}
|
build_options = {"includes": ["_cffi_backend"]}
|
||||||
setup(
|
setup(
|
||||||
@ -138,6 +156,8 @@ setup(
|
|||||||
install_requires=list(base_requirements),
|
install_requires=list(base_requirements),
|
||||||
extras_require={
|
extras_require={
|
||||||
"base": list(base_requirements),
|
"base": list(base_requirements),
|
||||||
|
"dev": list(dev),
|
||||||
|
"test": list(test),
|
||||||
**{plugin: list(dependencies) for (plugin, dependencies) in plugins.items()},
|
**{plugin: list(dependencies) for (plugin, dependencies) in plugins.items()},
|
||||||
"all": list(
|
"all": list(
|
||||||
base_requirements.union(
|
base_requirements.union(
|
||||||
|
|||||||
11
ingestion/sonar-project.properties
Normal file
11
ingestion/sonar-project.properties
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
sonar.projectKey=openmetadata-ingestion
|
||||||
|
sonar.projectName=openmetadata-ingestion
|
||||||
|
sonar.organization=open-metadata
|
||||||
|
sonar.language=py
|
||||||
|
|
||||||
|
sonar.sources=ingestion/src
|
||||||
|
sonar.tests=ingestion/tests
|
||||||
|
sonar.exclusions=ingestion/src/metadata_server/static/**,ingestion/src/metadata_server/templates/**
|
||||||
|
sonar.python.xunit.reportPath=ingestion/junit/test-results-*.xml
|
||||||
|
sonar.python.coverage.reportPaths=ingestion/coverage.xml
|
||||||
|
sonar.python.version=3.8,3.9
|
||||||
0
ingestion/tests/integration/source/__init__.py
Normal file
0
ingestion/tests/integration/source/__init__.py
Normal file
0
ingestion/tests/integration/source/glue/__init__.py
Normal file
0
ingestion/tests/integration/source/glue/__init__.py
Normal file
0
ingestion/tests/integration/source/hive/__init__.py
Normal file
0
ingestion/tests/integration/source/hive/__init__.py
Normal file
@ -19,7 +19,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- CLUSTER_NAME=test
|
- CLUSTER_NAME=test
|
||||||
env_file:
|
env_file:
|
||||||
- ./hadoop-hive.env
|
- hadoop-hive.env
|
||||||
ports:
|
ports:
|
||||||
- "50070:50070"
|
- "50070:50070"
|
||||||
datanode:
|
datanode:
|
||||||
@ -27,7 +27,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- datanode:/hadoop/dfs/data
|
- datanode:/hadoop/dfs/data
|
||||||
env_file:
|
env_file:
|
||||||
- ./hadoop-hive.env
|
- hadoop-hive.env
|
||||||
environment:
|
environment:
|
||||||
SERVICE_PRECONDITION: "namenode:50070"
|
SERVICE_PRECONDITION: "namenode:50070"
|
||||||
ports:
|
ports:
|
||||||
@ -35,7 +35,7 @@ services:
|
|||||||
hive-server:
|
hive-server:
|
||||||
image: bde2020/hive:2.3.2-postgresql-metastore
|
image: bde2020/hive:2.3.2-postgresql-metastore
|
||||||
env_file:
|
env_file:
|
||||||
- ./hadoop-hive.env
|
- hadoop-hive.env
|
||||||
command: "sh /setup/setup.sh"
|
command: "sh /setup/setup.sh"
|
||||||
volumes:
|
volumes:
|
||||||
- ./setup:/setup
|
- ./setup:/setup
|
||||||
@ -47,7 +47,7 @@ services:
|
|||||||
hive-metastore:
|
hive-metastore:
|
||||||
image: bde2020/hive:2.3.2-postgresql-metastore
|
image: bde2020/hive:2.3.2-postgresql-metastore
|
||||||
env_file:
|
env_file:
|
||||||
- ./hadoop-hive.env
|
- hadoop-hive.env
|
||||||
command: /opt/hive/bin/hive --service metastore
|
command: /opt/hive/bin/hive --service metastore
|
||||||
environment:
|
environment:
|
||||||
SERVICE_PRECONDITION: "namenode:50070 datanode:50075 hive-metastore-postgresql:5432"
|
SERVICE_PRECONDITION: "namenode:50070 datanode:50075 hive-metastore-postgresql:5432"
|
||||||
0
ingestion/tests/integration/source/ldap/__init__.py
Normal file
0
ingestion/tests/integration/source/ldap/__init__.py
Normal file
0
ingestion/tests/integration/stage/__init__.py
Normal file
0
ingestion/tests/integration/stage/__init__.py
Normal file
@ -8,7 +8,7 @@ config = """
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "sample-data",
|
"type": "sample-data",
|
||||||
"config": {
|
"config": {
|
||||||
"sample_data_folder": "examples/sample_data/"
|
"sample_data_folder": "ingestion/examples/sample_data"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stage": {
|
"stage": {
|
||||||
0
ingestion/tests/integration/workflow/__init__.py
Normal file
0
ingestion/tests/integration/workflow/__init__.py
Normal file
@ -24,7 +24,7 @@ class TestConfig(TestCase):
|
|||||||
Check config reading
|
Check config reading
|
||||||
"""
|
"""
|
||||||
|
|
||||||
basedir = os.path.join("resources", "config")
|
basedir = os.path.join(os.path.dirname(__file__), "resources", "config")
|
||||||
|
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user