forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
81 lines (74 loc) · 3.18 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: "Runner CI Python Tests"
description: "Runner CI Python Tests"
inputs:
module-name:
required: true
module-folder:
required: true
outputs:
coverage-paths:
description: "Coverage Paths"
value: ${{ steps.build-coverage-reports.outputs.coverage-paths }}
flake8-logs:
description: "Flake8 Logs"
value: ${{ steps.build-linter-reports.outputs.flake8-logs }}
mypy-logs:
description: "MyPy Logs"
value: ${{ steps.build-linter-reports.outputs.mypy-logs }}
black-diff:
description: "Black Diff"
value: ${{ steps.build-linter-reports.outputs.black-diff }}
isort-diff:
description: "Isort Diff"
value: ${{ steps.build-linter-reports.outputs.isort-diff }}
runs:
using: "composite"
steps:
- name: Build Coverage Reports
id: build-coverage-reports
shell: bash
working-directory: ${{ inputs.module-folder }}
run: |
virtualenv .venv
source .venv/bin/activate
JSON_CONFIG='{"module": "${{ inputs.module-name }}", "folder": "${{ inputs.module-folder }}", "lang": "py"}'
pip install coverage[toml]~=6.2
mkdir -p .venv/source-acceptance-test
mkdir -p reports
SAT_DIR=$(git rev-parse --show-toplevel)/airbyte-integrations/bases/source-acceptance-test
PYPROJECT_CONFIG=$(git rev-parse --show-toplevel)/pyproject.toml
git ls-tree -r HEAD --name-only $SAT_DIR | while read src; do cp -f $src .venv/source-acceptance-test; done
pip install build
python -m build .venv/source-acceptance-test
pip install .venv/source-acceptance-test/dist/source_acceptance_test-*.whl
[ -f requirements.txt ] && pip install --quiet -r requirements.txt
pip install .[tests]
coverage run --rcfile=${PYPROJECT_CONFIG} -m pytest ./unit_tests || true
coverage xml --rcfile=${PYPROJECT_CONFIG} -o reports/coverage.xml || true
rm -rf .venv
echo "::set-output name=coverage-paths::reports/coverage.xml"
- name: Build Linter Reports
id: build-linter-reports
shell: bash
working-directory: ${{ inputs.module-folder }}
run: |
JSON_CONFIG='{"module": "${{ inputs.module-name }}", "folder": "${{ inputs.module-folder }}", "lang": "py"}'
REPORT_FOLDER=reports
PYPROJECT_CONFIG=$(git rev-parse --show-toplevel)/pyproject.toml
# run mypy
pip install lxml~=4.7 mypy~=0.910 .
mypy . --config-file=${PYPROJECT_CONFIG} | tee reports/mypy.log || true
# run black
pip install black~=21.12b0
XDG_CACHE_HOME=/dev/null black --config ${PYPROJECT_CONFIG} --diff . | tee reports/black.diff
# run isort
pip install isort~=5.10.1
cp ${PYPROJECT_CONFIG} ./pyproject.toml
isort --diff . | tee reports/isort.diff
# run flake8
pip install mccabe~=0.6.1 pyproject-flake8~=0.0.1a2
pflake8 --exit-zero . | grep ^. | tee reports/flake.txt
echo "::set-output name=mypy-logs::reports/mypy.log"
echo "::set-output name=black-diff::reports/black.diff"
echo "::set-output name=isort-diff::reports/isort.diff"
echo "::set-output name=flake8-logs::reports/flake.txt"