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

ci: use nondocker to run pytest and jest #413

Merged
merged 11 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
72 changes: 46 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,60 @@ on:
branches:
- master
pull_request:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
nodetests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set PY
run: |
echo 'PY<<EOF' >> $GITHUB_ENV
echo "$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.0.1
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
token: ${{ secrets.GITHUB_TOKEN }}
tests:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile --prefer-offline
# if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: ./querybook/scripts/run_test --node
pythontests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install libs
run: >
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -y --allow-downgrades --allow-remove-essential --allow-change-held-packages
libsasl2-dev
libsasl2-modules
build-essential
python-dev
libssl-dev
libldap2-dev
- uses: actions/setup-python@v2
with:
fetch-depth: 1
- name: Run docker test
run: make test
python-version: 3.7.9
- uses: actions/cache@v2
id: pip-cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/base.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
# if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements/base.txt
- run: PYTHONPATH=querybook/server ./querybook/scripts/run_test --python
31 changes: 30 additions & 1 deletion querybook/scripts/run_test
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

usage() {
echo "Runs querybook tests"
echo ''
echo 'If not specified, then both python and node tests'
echo 'will be executed.'
echo ''
echo 'Flags:'
echo ' --python only run python tests'
echo ' --node only run node js tests'
echo
echo 'Usage:'
echo ' $0 [--python]'
exit 1
}

run_python_unit_test() {
echo 'Start running python unit tests >>>>>>>>>>>>>>>>>>>>>>>>>>>>'
py.test querybook/tests || exit 1
Expand Down Expand Up @@ -29,14 +44,28 @@ run_eslint_validation() {
npm run lint
}

tests=(
PYTHON_TESTS=(
"run_python_unit_test"
)

NODE_TESTS=(
"run_ts_validation"
"run_js_unit_test"
"run_eslint_validation"
"run_webpack_test"
)

tests=("${PYTHON_TESTS[@]}" "${NODE_TESTS[@]}")
while [[ "$#" -gt 0 ]]; do
case $1 in
--python) tests=("${PYTHON_TESTS[@]}");;
--node) tests=("${NODE_TESTS[@]}");;
--help) usage;;
*) echo "Unknown parameter passed: $1"; usage;;
esac;
shift;
done

children_pids=()

clen=`expr "${#tests[@]}" - 1`
Expand Down