-
Notifications
You must be signed in to change notification settings - Fork 2
194 lines (171 loc) · 6.05 KB
/
main.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# **what?**
# Runs code quality checks, unit tests, and verifies python build on
# all code commited to the repository. This workflow should not
# require any secrets since it runs for PRs from forked repos.
# By default, secrets are not passed to workflows running from
# a forked repo.
# **why?**
# Ensure code for dbt meets a certain quality standard.
# **when?**
# This will run for all PRs, when code is pushed to a release
# branch, and when manually triggered.
name: Tests and Code Checks
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- released
permissions: write-all
# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
code-quality:
name: code-quality
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
- name: Install python dependencies
run: |
pip install --user --upgrade pip
pip install pre-commit
pip install -r requirements-dev.txt
pip --version
pre-commit --version
mypy --version
dbt --version
- name: Run Tests
run: |
tox -e py38,py39,py310,py311
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
test-build:
strategy:
fail-fast: false
matrix:
image:
- intersystemsdc/iris-community:latest
- intersystemsdc/iris-community:preview
python:
- name: py38
version: 3.8
- name: py39
version: 3.9
- name: py310
version: 3.10
- name: py311
version: 3.11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
- name: install dependencies
run: |
pip install tox
- name: Build Docker image
run: docker build -t dbt-iris:$GITHUB_SHA .
- name: Run Tests
run: |
tox -e ${{ matrix.python.name }}-iris -- --container containers.intersystems.com/intersystems/iris-community:latest
build:
needs:
- code-quality
- test-build
name: build packages
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
persist-credentials: false
- run: git fetch --depth=1 origin '+refs/tags/*:refs/tags/*'
continue-on-error: true
- name: set version
id: set-version
run: |
VERSION=$(sed -n '0,/version = \(.*\)/s//\1/p' dbt/adapters/iris/__version__.py | tr -d '"' )
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=b$(($(git tag -l "v${VERSION}b*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d b -f2)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
sed -i "s/version = .*/version = \"${VERSION}\"/" dbt/adapters/iris/__version__.py
sed -i "s/package_version = .*/package_version = \"${VERSION}\"/" setup.py
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install python dependencies
run: |
pip install --user --upgrade pip
pip install --upgrade setuptools wheel twine check-wheel-contents tox
pip --version
- name: Build distributions
run: |
pip install -r requirements-iris.txt
./scripts/build-dist.sh
- name: Show distributions
run: ls -lh dist/
- name: Check distribution descriptions
run: |
twine check dist/*
- name: Check wheel contents
run: |
check-wheel-contents dist/*.whl --ignore W007,W008,W009
- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: dist
path: dist/dbt_iris-${{ steps.set-version.outputs.version }}-py3-none-any.whl
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v1
if: github.event_name != 'pull_request'
with:
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: dist/dbt_iris-${{ steps.set-version.outputs.version }}-py3-none-any.whl
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package
if: github.event_name != 'pull_request'
uses: pypa/gh-action-pypi-publish@release/v1.5
- uses: actions/checkout@v4
if: github.event_name == 'release'
with:
ref: main
- name: Bump version
if: github.event_name == 'release'
run: |
git config --global user.name 'ProjectBot'
git config --global user.email 'bot@users.noreply.github.com'
VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
sed -i "s/version = .*/version = \"${VERSION}\"/" dbt/adapters/iris/__version__.py
sed -i "s/package_version = .*/package_version = \"${VERSION}\"/" setup.py
git add dbt/adapters/iris/__version__.py
git add setup.py
git commit -m 'auto bump version with release'
git push