-
Notifications
You must be signed in to change notification settings - Fork 69
159 lines (131 loc) · 5.16 KB
/
integration.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Integration Tests
on:
# we use pull_request_target to run the CI also for forks
pull_request_target:
types: [labeled]
push:
branches: [main]
permissions:
id-token: write
contents: read
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:
# workflow that is invoked when for PRs with labels 'enable-functional-tests'
functional-tests-pr:
name: Functional Tests - PR / python ${{ matrix.python-version }}
if: contains(github.event.pull_request.labels.*.name, 'enable-functional-tests')
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ["3.10"] # Use single version to avoid resource conflicts in an AWS account
env:
TOXENV: "integration"
PYTEST_ADDOPTS: "-v --color=yes --csv integ_results.csv"
DBT_AWS_ACCOUNT: ${{ secrets.DBT_AWS_ACCOUNT }}
DBT_GLUE_ROLE_ARN: ${{ secrets.DBT_GLUE_ROLE_ARN }}
DBT_GLUE_REGION: ${{ secrets.DBT_GLUE_REGION }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
sudo apt-get update
sudo apt-get install libsasl2-dev
python -m pip install --user --upgrade pip
python -m pip --version
python -m pip install tox
tox --version
- name: Generate session name
id: session
run: |
repo="${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}"
echo "name=${repo}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "${GITHUB_OUTPUT}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: ${{ steps.session.outputs.name }}
role-to-assume: arn:aws:iam::${{ secrets.DBT_AWS_ACCOUNT }}:role/dbt-glue
aws-region: ${{ secrets.DBT_GLUE_REGION }}
mask-aws-account-id: true
- name: Run tox
run: |
export DBT_S3_LOCATION=${{ secrets.DBT_S3_LOCATION }}/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}/${{ matrix.python-version }}
tox
- name: Get current date
if: always()
id: date
run: echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
- uses: actions/upload-artifact@v3
if: always()
with:
name: unit_results_${{ matrix.python-version }}-${{ steps.date.outputs.date }}.csv
path: unit_results.csv
# workflow that is invoked when a push to main happens
functional-tests-main:
name: Functional Tests - main / python ${{ matrix.python-version }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ["3.10"] # Use single version to avoid resource conflicts in an AWS account
env:
TOXENV: "integration"
PYTEST_ADDOPTS: "-v --color=yes --csv integ_results.csv -s"
DBT_AWS_ACCOUNT: ${{ secrets.DBT_AWS_ACCOUNT }}
DBT_GLUE_ROLE_ARN: ${{ secrets.DBT_GLUE_ROLE_ARN }}
DBT_GLUE_REGION: ${{ secrets.DBT_GLUE_REGION }}
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 }}
- name: Install python dependencies
run: |
sudo apt-get update
sudo apt-get install libsasl2-dev
python -m pip install --user --upgrade pip
python -m pip --version
python -m pip install tox
tox --version
- name: Generate session name
id: session
run: |
repo="${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}"
echo "name=${repo}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "${GITHUB_OUTPUT}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: ${{ steps.session.outputs.name }}
role-to-assume: arn:aws:iam::${{ secrets.DBT_AWS_ACCOUNT }}:role/dbt-glue
aws-region: ${{ secrets.DBT_GLUE_REGION }}
mask-aws-account-id: true
- name: Run tox
run: |
export DBT_S3_LOCATION=${{ secrets.DBT_S3_LOCATION }}/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}/${{ matrix.python-version }}
tox
- name: Get current date
if: always()
id: date
run: echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
- uses: actions/upload-artifact@v3
if: always()
with:
name: unit_results_${{ matrix.python-version }}-${{ steps.date.outputs.date }}.csv
path: unit_results.csv