Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github action for integration test #896

Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# **what?**
# Runs integration tests.

# **why?**
# Ensure code for dbt meets a certain quality standard.
JCZuurmond marked this conversation as resolved.
Show resolved Hide resolved

# **when?**
# This will run for all PRs, when code is pushed to a release
# branch, and when manually triggered.

name: Integration tests

on:
push:
branches:
- "main"
- "*.latest"
- "releases/*"
pull_request:
workflow_dispatch:

# explicitly turn off permissions for `GITHUB_TOKEN`
permissions: read-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:
tests:
name: test with python ${{ matrix.python-version }}

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"

env:
TOXENV: "unit"
PYTEST_ADDOPTS: "-v --color=yes --csv test_results.csv"

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: isbang/[email protected]
with:
compose-file: "./docker-compose.yml"

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox

- name: Run tox for Spark session
run: tox -e integration-spark-session

- name: Run tox for Spark thrift
run: tox -e integration-spark-thrift
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ARG OPENJDK_VERSION=8
FROM eclipse-temurin:${OPENJDK_VERSION}-jre

ARG BUILD_DATE
ARG SPARK_VERSION=3.3.2
ARG HADOOP_VERSION=3
ARG SPARK_VERSION=3.1.3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests do not work yet for a later version. We will solve that later. This is the same version as in the Dockerfile used in the circle ci

ARG HADOOP_VERSION=3.2

LABEL org.label-schema.name="Apache Spark ${SPARK_VERSION}" \
org.label-schema.build-date=$BUILD_DATE \
Expand All @@ -14,7 +14,7 @@ ENV PATH="/usr/spark/bin:/usr/spark/sbin:${PATH}"

RUN apt-get update && \
apt-get install -y wget netcat procps libpostgresql-jdbc-java && \
wget -q "http://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz" && \
wget -q "https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz" && \
tar xzf "spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz" && \
rm "spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz" && \
mv "spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}" /usr/spark && \
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,22 @@ deps =


[testenv:integration-spark-thrift]
description = run integration tests against a Spark thrift server
allowlist_externals =
/bin/bash
basepython = python3.8
commands = /bin/bash -c '{envpython} -m pytest -v --profile apache_spark {posargs} -n4 tests/functional/adapter/*'
passenv =
DBT_*
PYTEST_ADDOPTS
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/dev-requirements.txt
-e.
commands = /bin/bash -c '{envpython} -m pytest -v --profile apache_spark {posargs} -n4 tests/functional/adapter/*'

[testenv:integration-spark-session]
description = run integration tests against a Spark session
allowlist_externals =
/bin/bash
basepython = python3.10
commands = /bin/bash -c '{envpython} -m pytest -v --profile spark_session {posargs} -n4 tests/functional/adapter/*'
passenv =
DBT_*
PYTEST_*
Expand All @@ -81,3 +80,4 @@ deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/dev-requirements.txt
-e.[session]
commands = /bin/bash -c '{envpython} -m pytest -v --profile spark_session {posargs} -n4 tests/functional/adapter/*'
Loading