some Upgrade #78
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# **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: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: | | |
3.8 | |
3.9 | |
3.10 | |
3.11 | |
- name: install dependencies | |
run: | | |
pip install tox | |
- name: Build Docker image | |
run: docker build -t dbt-iris:$GITHUB_SHA . | |
- name: Run Container | |
run: | | |
docker run --rm -d -p 1972:1972 dbt-iris:$GITHUB_SHA \ | |
-a 'iris session iris -U %SYS "##class(Security.Users).UnExpireUserPasswords(\"*\")"' | |
- name: Run Tests | |
run: | | |
tox -e py38-iris,py39-iris,py310-iris,py311-iris | |
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 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- 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 |