-
Notifications
You must be signed in to change notification settings - Fork 50
106 lines (92 loc) · 3.23 KB
/
test_on_local_destinations_forks.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
name: test sources on postgres and duckdb on forks
on:
pull_request_target:
branches:
- master
- devel
types:
- opened
- synchronize
- labeled
workflow_dispatch:
env:
ALL_DESTINATIONS: '["postgres", "duckdb"]'
DLT_SECRETS_TOML: ${{ secrets.DLT_SECRETS_TOML }}
RUNTIME__LOG_LEVEL: ERROR
jobs:
authorize:
# run when label is assigned OR when we are not a fork
# see https://iterative.ai/blog/testing-external-contributions-using-github-actions-secrets for inspiration
if: ${{ github.event.label.name == 'ci from fork' || (github.event.pull_request.head.repo.full_name == github.repository && (github.event.action == 'opened' || github.event.action == 'synchronize'))}}
runs-on: ubuntu-latest
steps:
- run: true
get_changed_sources:
needs: authorize
uses: ./.github/workflows/get_changed_sources.yml
# run only on fork
# if: ${{ github.event.pull_request.head.repo.fork }}
run_loader:
name: FORKS - test on local postgres and duckdb
needs: get_changed_sources
if: needs.get_changed_sources.outputs.sources_list != ''
strategy:
max-parallel: 1
fail-fast: false
defaults:
run:
shell: bash
runs-on: "ubuntu-latest"
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_DB: dlt_data
POSTGRES_USER: loader
POSTGRES_PASSWORD: loader
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out
uses: actions/checkout@master
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: "3.9.x"
- name: Install Poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
# path: ${{ steps.pip-cache.outputs.dir }}
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-destinations-forks
- name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --all-extras
- name: create secrets.toml
run: pwd && echo "$DLT_SECRETS_TOML" > sources/.dlt/secrets.toml
- run: |
sources_list="${{ needs.get_changed_sources.outputs.sources_list }}"
test_paths=$(echo "$sources_list" | awk '{for(i=1;i<=NF;i++) printf "tests/%s ", $i}')
poetry run pytest $test_paths
name: Run tests on Linux/macOS
env:
DESTINATION__POSTGRES__CREDENTIALS: postgresql://loader:loader@localhost:5432/dlt_data