-
Notifications
You must be signed in to change notification settings - Fork 58
133 lines (126 loc) · 4.53 KB
/
test_integration.yaml
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
name: Integration testing
on:
pull_request:
branches:
- "*"
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- main
repository_dispatch:
types: [ok-to-test-command]
schedule:
- cron: "0 8 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
define-matrix:
uses: ./.github/workflows/matrix.yaml
# Branch-based pull request
integration-trusted:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
python -m hatch env create integration
- name: Run integration tests
env:
TERM: unknown
SNOWFLAKE_CONNECTIONS_INTEGRATION_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
run: python -m hatch run integration:test
# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
permissions:
pull-requests: write
checks: write
if: |
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
contains(
github.event.client_payload.pull_request.head.sha,
github.event.client_payload.slash_command.args.named.sha
)
steps:
- name: Test
run: |
echo ${{ github.event_name }}
echo ${{ github.event.client_payload.slash_command.args.named.sha }}
echo ${{ github.event.client_payload.pull_request.head.sha }}
# - uses: actions/checkout@v4
# with:
# persist-credentials: false
# ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip hatch
# python -m hatch env create integration
# - name: Run integration tests
# env:
# TERM: unknown
# SNOWFLAKE_CONNECTIONS_INTEGRATION_USER: ${{ secrets.SNOWFLAKE_USER }}
# SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
# SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
# run: python -m hatch run integration:test
# # Update check run called "integration-fork"
# - uses: actions/github-script@v7
# id: update-check-run
# if: ${{ always() }}
# env:
# number: ${{ github.event.client_payload.pull_request.number }}
# job: ${{ github.job }}
# # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
# conclusion: ${{ job.status }}
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const { data: pull } = await github.rest.pulls.get({
# ...context.repo,
# pull_number: process.env.number
# });
# const ref = pull.head.sha;
#
# const { data: checks } = await github.rest.checks.listForRef({
# ...context.repo,
# ref
# });
#
# const check = checks.check_runs.filter(c => c.name === process.env.job);
#
# const { data: result } = await github.rest.checks.update({
# ...context.repo,
# check_run_id: check[0].id,
# status: 'completed',
# conclusion: process.env.conclusion
# });
#
# return result;