diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b49c89c52..b451e4f8d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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<> $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 diff --git a/querybook/scripts/run_test b/querybook/scripts/run_test index c475fc0d6..baefbdc46 100755 --- a/querybook/scripts/run_test +++ b/querybook/scripts/run_test @@ -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 @@ -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`