-
Notifications
You must be signed in to change notification settings - Fork 12
173 lines (143 loc) · 5.06 KB
/
push.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: build
on:
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
# Always run on push to main. The build cache can only be reused
# if it was saved by a run from the repository's default branch.
# The run result will be identical to that from the merge queue
# because the commit is identical, yet we need to perform it to
# seed the build cache.
branches:
- main
env:
HATCH_VERSION: 1.9.1
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: '3.10'
- name: Install hatch
run: pip install hatch==$HATCH_VERSION
- name: Setup Spark Remote
run: |
chmod +x $GITHUB_WORKSPACE/.github/scripts/setup_spark_remote.sh
$GITHUB_WORKSPACE/.github/scripts/setup_spark_remote.sh
- name: Run unit tests
run: hatch run test
- name: Publish test coverage
uses: codecov/codecov-action@v4
with:
codecov_yml_path: codecov.yml
token: ${{ secrets.CODECOV_TOKEN }}
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: 3.10.x
- name: Install hatch
run: pip install hatch==$HATCH_VERSION
- name: Reformat code
run: make fmt
- name: Fail on differences
run: |
# Exit with status code 1 if there are differences (i.e. unformatted files)
git diff --exit-code
no-lint-disabled:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify no lint disabled in the new code
run: |
NEW_CODE=$(git diff origin/main..$(git branch --show-current) | grep -e '^+')
CHEAT=$(echo "${NEW_CODE}" | grep '# pylint: disable' | grep -v "CHEAT" | wc -c)
if [ "${CHEAT}" -ne 0 ]; then
echo "Do not cheat the linter: ${CHEAT}"
exit 1
fi
test-core:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 11
cache: 'maven'
- name: Run Unit Tests with Maven
run: mvn --update-snapshots -B install scoverage:report -pl "!com.databricks.labs:remorph-coverage" --file pom.xml --fail-at-end
- name: Uplaod remorph-core jars as Artifacts
uses: actions/upload-artifact@v4
with:
name: remorph-core-jars
path: ~/.m2/repository/com/databricks/labs/remorph*
- name: Publish test coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
coverage-tests:
needs: test-core
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 11
cache: 'maven'
- name: Download remorph-core-jars
uses: actions/download-artifact@v4
with:
name: remorph-core-jars
path: ~/.m2/repository/com/databricks/labs/
- name: Run Coverage Tests with Maven
run: mvn --update-snapshots -B test -pl coverage --file pom.xml --fail-at-end
continue-on-error: true
- name: Run TSQL Coverage Tests with Maven
run: mvn --update-snapshots -B exec:java -pl coverage --file pom.xml --fail-at-end -DsourceDir=tests/resources/functional/tsql -DoutputPath=coverage-result.json -DsourceDialect=tsql
continue-on-error: true
- name: Run Snowflake Coverage Tests with Maven
run: mvn --update-snapshots -B exec:java -pl coverage --file pom.xml --fail-at-end -DsourceDir=tests/resources/functional/snowflake -DoutputPath=coverage-result.json -DsourceDialect=snowflake
continue-on-error: true
- name: Publish JUnit report
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
**/TEST-com.databricks.labs.remorph.coverage*.xml
comment_title: 'Coverage tests results'
check_name: 'Coverage Tests Results'
fail_on: 'nothing'
continue-on-error: true
- name: Upload coverage tests results as json as Artifacts
uses: actions/upload-artifact@v4
with:
name: remorph-coverage-results
path: coverage/target/coverage-result.json