Skip to content

Commit 8496d19

Browse files
authored
style: add linting checks (#60)
* style: add linting checks added markdown, yaml, general file formatting checks to improve readability, version control handling, and consistency.
1 parent 3041df5 commit 8496d19

32 files changed

+206
-167
lines changed

.github/workflows/ci-cd.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
1+
---
12
name: CI-CD
23

3-
on: [push]
4+
on: [push] # yamllint disable-line rule:truthy
45

56
jobs:
67
build:
78
runs-on: ubuntu-latest
89
permissions:
910
contents: read
1011
steps:
11-
#----------------------------------------------
12+
# ----------------------------------------------
1213
# check-out repo and set-up python
13-
#----------------------------------------------
14+
# ----------------------------------------------
1415
- name: Check out repository
1516
uses: actions/checkout@v3
1617
- name: Set up python
1718
id: setup-python
1819
uses: actions/setup-python@v4
1920
with:
2021
python-version: '3.9'
21-
#----------------------------------------------
22+
# ----------------------------------------------
2223
# ----- install & configure poetry -----
23-
#----------------------------------------------
24+
# ----------------------------------------------
2425
- name: Install Poetry
2526
uses: snok/install-poetry@v1
2627
with:
2728
virtualenvs-create: true
2829
virtualenvs-in-project: true
2930
installer-parallel: true
3031

31-
#----------------------------------------------
32+
# ----------------------------------------------
3233
# install dependencies if cache does not exist
33-
#----------------------------------------------
34+
# ----------------------------------------------
3435
- name: Install dependencies
3536
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
3637
run: poetry install --no-interaction --no-root
37-
#----------------------------------------------
38+
# ----------------------------------------------
3839
# install your root project, if required
39-
#----------------------------------------------
40+
# ----------------------------------------------
4041
- name: Install project
4142
run: poetry install --no-interaction
4243
#----------------------------------------------
@@ -51,9 +52,9 @@ jobs:
5152
run: |
5253
poetry version 0.0.1.alpha${{ github.run_number}}
5354
poetry build
54-
#----------------------------------------------
55+
# ----------------------------------------------
5556
# upload dist
56-
#----------------------------------------------
57+
# ----------------------------------------------
5758
- name: Upload dist
5859
uses: actions/upload-artifact@v3
5960
with:

.markdownlint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
MD013:
3+
line_length: 120

.markdownlintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ignore Microsoft-generated files
2+
SECURITY.md
3+
SUPPORT.md

.pre-commit-config.yaml

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1+
---
12
repos:
2-
- repo: https://github.com/python-poetry/poetry
3+
- repo: https://github.com/python-poetry/poetry
34
rev: 1.6.1
45
hooks:
5-
- id: poetry-check
6+
- id: poetry-check
67
args: []
7-
- id: poetry-lock
8+
- id: poetry-lock
89
args: ["--no-update"]
9-
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.1.5
11-
hooks:
12-
- id: ruff
13-
args: [ --fix ]
14-
- id: ruff-format
15-
- repo: local
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.5.0
1612
hooks:
17-
- id: pytest
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace
15+
- id: mixed-line-ending
16+
args: [--fix=auto]
17+
- repo: https://github.com/adrienverge/yamllint
18+
rev: v1.33.0
19+
hooks:
20+
- id: yamllint
21+
args: [--strict]
22+
- repo: https://github.com/igorshubovych/markdownlint-cli
23+
rev: v0.38.0
24+
hooks:
25+
- id: markdownlint-fix
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: v0.1.5
28+
hooks:
29+
- id: ruff
30+
args: [--fix]
31+
- id: ruff-format
32+
- repo: local
33+
hooks:
34+
- id: pytest
1835
name: pytest
1936
entry: poetry run pytest .
2037
language: system
2138
types: [python]
2239
require_serial: true
2340
pass_filenames: false
24-

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"python.testing.cwd": "${workspaceFolder}",
1010
"python.testing.pytestEnabled": true,
1111
"python.testing.unittestEnabled": false,
12-
}
12+
}

.yamllint.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
rules:
3+
new-lines:
4+
type: platform

DEVELOPMENT.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ poetry run pre-commit run
2424

2525
### Run Linting
2626

27-
We use Ruff to lint our code as it provides similar rule sets to well-established linters into one (e.g., black, flake8, isort, and pydocstyle).
27+
We use Ruff to lint our code as it provides similar rule sets to well-established linters into one
28+
(e.g., black, flake8, isort, and pydocstyle).
2829

2930
To run linting, run the following command:
3031

README.md

+82-69
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,80 @@
11
# Data Factory - Testing Framework
22

3-
A test framework that allows you to write unit and functional tests for Data Factory pipelines against the git integrated json resource files.
3+
A test framework that allows you to write unit and functional tests for Data Factory
4+
pipelines against the git integrated json resource files.
45

56
Supporting currently:
7+
68
* [Fabric Data Factory](https://learn.microsoft.com/en-us/fabric/data-factory/)
79
* [Azure Data Factory v2](https://learn.microsoft.com/en-us/azure/data-factory/concepts-pipelines-activities?tabs=data-factory)
810

911
Planned:
10-
* [Azure Synapse Analytics](https://learn.microsoft.com/en-us/azure/data-factory/concepts-pipelines-activities?context=%2Fazure%2Fsynapse-analytics%2Fcontext%2Fcontext&tabs=data-factory/)
1112

13+
* [Azure Synapse Analytics](https://learn.microsoft.com/en-us/azure/data-factory/concepts-pipelines-activities?context=%2Fazure%2Fsynapse-analytics%2Fcontext%2Fcontext&tabs=data-factory/)
1214

1315
## Disclaimer
1416

15-
This unit test framework is not officially supported. It is currently in an experimental state and has not been tested with every single data factory resource. It should support all activities out-of-the-box but has not been thoroughly tested, please report any issues in the issues section and include an example of the pipeline that is not working as expected.
17+
This unit test framework is not officially supported.
18+
It is currently in an experimental state and has not been tested with every single data factory resource.
19+
It should support all activities out-of-the-box but has not been thoroughly tested,
20+
please report any issues in the issues section and include an example of the pipeline that is not working as expected.
1621

17-
If there's a lot of interest in this framework, then we will continue to improve it and move it to a production-ready state.
22+
If there's a lot of interest in this framework, then we will continue to improve it and move it to a production-ready state.
1823

1924
## Features
2025

2126
Goal: Validate that the evaluated pipeline configuration with its expressions is behaving as expected on runtime.
2227

2328
1. Evaluate expressions with their functions and arguments instantly by using the framework's internal expression parser.
24-
2. Test a pipeline or activity against any state to assert the expected outcome. A state can be configured with pipeline parameters, global parameters, variables and activity outputs.
29+
2. Test a pipeline or activity against any state to assert the expected outcome.
30+
A state can be configured with pipeline parameters, global parameters, variables and activity outputs.
2531
3. Simulate a pipeline run and evaluate the execution flow and outcome of each activity.
2632
4. Dynamically supports all activity types with all their attributes.
2733

28-
> Pipelines and activities are not executed on any Data Factory environment, but the evaluation of the pipeline configuration is validated locally. This is different from the "validation" functionality present in the UI, which only validates the syntax of the pipeline configuration.
29-
34+
> Pipelines and activities are not executed on any Data Factory environment,
35+
> but the evaluation of the pipeline configuration is validated locally.
36+
> This is different from the "validation" functionality present in the UI,
37+
> which only validates the syntax of the pipeline configuration.
3038
3139
## Why
3240

33-
Data Factory does not support unit testing out of the box. The only way to validate your changes is through manual testing or running e2e tests against a deployed data factory. These tests are great to have, but miss the following benefits that unit tests, like using this unit test framework, provide:
41+
Data Factory does not support unit testing out of the box.
42+
The only way to validate your changes is through manual testing or running e2e tests against a deployed data factory.
43+
These tests are great to have, but miss the following benefits that unit tests, like using this unit test framework, provide:
3444

35-
* Shift left with immediate feedback on changes - Evaluate any individual data factory resource (pipelines, activities, triggers, datasets, linked services etc..), including (complex) expressions
45+
* Shift left with immediate feedback on changes - Evaluate any individual data factory resource
46+
(pipelines, activities, triggers, datasets, linked services etc..), including (complex) expressions
3647
* Allows testing individual resources (e.g. activity) for many different input values to cover more scenarios.
37-
* Less issues in production - due to the fast nature of writing and running unit tests, you will write more tests in less time and therefore have a higher test coverage. This means more confidence in new changes, fewer risks in breaking existing features (regression tests), and thus far fewer issues in production.
48+
* Less issues in production - due to the fast nature of writing and running unit tests,
49+
you will write more tests in less time and therefore have a higher test coverage.
50+
This means more confidence in new changes, fewer risks in breaking existing features (regression tests),
51+
and thus far fewer issues in production.
3852

39-
> Even though Data Factory is UI-driven writing unit tests, and might not be in the nature of it. How can you be confident that your changes will work as expected, and that existing pipelines will not break, without writing unit tests?
53+
> Even though Data Factory is UI-driven writing unit tests, and might not be in the nature of it.
54+
> How can you be confident that your changes will work as expected,
55+
> and that existing pipelines will not break, without writing unit tests?
4056
4157
## Getting started
4258

4359
1. Set up an empty Python project with your favorite testing library
44-
45-
More information:
60+
61+
More information:
4662
[docs_Setup](/docs/environment_setup/unit_test_setup.md)
47-
63+
4864
2. Install the package using your preferred package manager:
49-
65+
5066
Pip: `pip install data-factory-testing-framework`
51-
67+
5268
3. Create a Folder in your project and copy the JSON Files with the pipeline definitions locally.
53-
54-
More information:
69+
70+
More information:
5571
[docs Json](/docs/environment_setup/json_pipeline_files.md)
56-
72+
5773
4. Start writing tests
5874

5975
## Features - Examples
6076

61-
The samples seen below are the _only_ code that you need to write! The framework will take care of the rest.
77+
The samples seen below are the _only_ code that you need to write! The framework will take care of the rest.
6278

6379
1. Evaluate activities (e.g. a WebActivity that calls Azure Batch API)
6480

@@ -86,53 +102,53 @@ The samples seen below are the _only_ code that you need to write! The framework
86102
assert "Job-123" == body["JobName"]
87103
assert "version1" == body["Version"]
88104
```
89-
90-
2. Evaluate Pipelines and test the flow of activities given a specific input
91-
92-
```python
93-
# Arrange
94-
pipeline: PipelineResource = test_framework.repository.get_pipeline_by_name("batch_job")
95-
96-
# Runs the pipeline with the provided parameters
97-
activities = test_framework.evaluate_pipeline(pipeline, [
98-
RunParameter(RunParameterType.Pipeline, "JobId", "123"),
99-
RunParameter(RunParameterType.Pipeline, "ContainerName", "test-container"),
100-
RunParameter(RunParameterType.Global, "BaseUrl", "https://example.com"),
101-
])
102-
103-
set_variable_activity: Activity = next(activities)
104-
assert set_variable_activity is not None
105-
assert "Set JobName" == set_variable_activity.name
106-
assert "JobName" == activity.type_properties["variableName"]
107-
assert "Job-123" == activity.type_properties["value"].value
108-
109-
get_version_activity = next(activities)
110-
assert get_version_activity is not None
111-
assert "Get version" == get_version_activity.name
112-
assert "https://example.com/version" == get_version_activity.type_properties["url"].value
113-
assert "GET" == get_version_activity.type_properties["method"]
114-
get_version_activity.set_result(DependencyCondition.Succeeded,{"Version": "version1"})
115-
116-
create_batch_activity = next(activities)
117-
assert create_batch_activity is not None
118-
assert "Trigger Azure Batch Job" == create_batch_activity.name
119-
assert "https://example.com/jobs" == create_batch_activity.type_properties["url"].value
120-
assert "POST" == create_batch_activity.type_properties["method"]
121-
body = create_batch_activity.type_properties["body"].get_json_value()
122-
assert "123" == body["JobId"]
123-
assert "Job-123" == body["JobName"]
124-
assert "version1" == body["Version"]
125-
126-
with pytest.raises(StopIteration):
127-
next(activities)
128-
```
129-
130-
> See the [Examples](/examples) folder for more samples
131105

106+
2. Evaluate Pipelines and test the flow of activities given a specific input
107+
108+
```python
109+
# Arrange
110+
pipeline: PipelineResource = test_framework.repository.get_pipeline_by_name("batch_job")
111+
112+
# Runs the pipeline with the provided parameters
113+
activities = test_framework.evaluate_pipeline(pipeline, [
114+
RunParameter(RunParameterType.Pipeline, "JobId", "123"),
115+
RunParameter(RunParameterType.Pipeline, "ContainerName", "test-container"),
116+
RunParameter(RunParameterType.Global, "BaseUrl", "https://example.com"),
117+
])
118+
119+
set_variable_activity: Activity = next(activities)
120+
assert set_variable_activity is not None
121+
assert "Set JobName" == set_variable_activity.name
122+
assert "JobName" == activity.type_properties["variableName"]
123+
assert "Job-123" == activity.type_properties["value"].value
124+
125+
get_version_activity = next(activities)
126+
assert get_version_activity is not None
127+
assert "Get version" == get_version_activity.name
128+
assert "https://example.com/version" == get_version_activity.type_properties["url"].value
129+
assert "GET" == get_version_activity.type_properties["method"]
130+
get_version_activity.set_result(DependencyCondition.Succeeded,{"Version": "version1"})
131+
132+
create_batch_activity = next(activities)
133+
assert create_batch_activity is not None
134+
assert "Trigger Azure Batch Job" == create_batch_activity.name
135+
assert "https://example.com/jobs" == create_batch_activity.type_properties["url"].value
136+
assert "POST" == create_batch_activity.type_properties["method"]
137+
body = create_batch_activity.type_properties["body"].get_json_value()
138+
assert "123" == body["JobId"]
139+
assert "Job-123" == body["JobName"]
140+
assert "version1" == body["Version"]
141+
142+
with pytest.raises(StopIteration):
143+
next(activities)
144+
```
145+
146+
> See the [Examples](/examples) folder for more samples
132147

133148
## Registering missing expression functions
134149

135-
As the framework is interpreting expressions containing functions, these functions are implemented in the framework, but there may be bugs in some of them. You can override their implementation through:
150+
As the framework is interpreting expressions containing functions, these functions are implemented in the framework,
151+
but there may be bugs in some of them. You can override their implementation through:
136152

137153
```python
138154
FunctionsRepository.register("concat", lambda arguments: "".join(arguments))
@@ -141,7 +157,8 @@ As the framework is interpreting expressions containing functions, these functio
141157

142158
## Tips
143159

144-
1. After parsing a data factory resource file, you can use the debugger to easily discover which classes are actually initialized so that you can cast them to the correct type.
160+
1. After parsing a data factory resource file, you can use the debugger to easily discover which classes are actually
161+
initialized so that you can cast them to the correct type.
145162

146163
## Recommended development workflow for Azure Data Factory v2
147164

@@ -160,7 +177,7 @@ As the framework is interpreting expressions containing functions, these functio
160177

161178
This project welcomes contributions and suggestions. Most contributions require you to agree to a
162179
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
163-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
180+
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
164181

165182
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
166183
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
@@ -177,7 +194,3 @@ trademarks or logos is subject to and must follow
177194
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
178195
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
179196
Any use of third-party trademarks or logos are subject to those third-party's policies.
180-
181-
182-
183-

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Instead, please report them to the Microsoft Security Response Center (MSRC) at
1414

1515
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
1616

17-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
17+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
1818

1919
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
2020

SUPPORT.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Support
22

3-
## How to file issues and get help
3+
## How to file issues and get help
44

5-
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
6-
issues before filing new issues to avoid duplicates. For new issues, file your bug or
5+
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
6+
issues before filing new issues to avoid duplicates. For new issues, file your bug or
77
feature request as a new Issue.
88

99
For help and questions about using this project, feel free ask your question via GitHub issues. In the future we will think about other channels.
1010

11-
## Microsoft Support Policy
11+
## Microsoft Support Policy
1212

1313
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.

0 commit comments

Comments
 (0)