-
Notifications
You must be signed in to change notification settings - Fork 68
87 lines (76 loc) · 3.15 KB
/
test_dispatcher.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
name: Plugin 'Test' Command Dispatcher
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
paths:
- "_data/meltano/*/*/*.yml"
jobs:
get_changed_files:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Get changed files
id: changed_files
uses: tj-actions/[email protected]
with:
sha: ${{ github.event.pull_request.head.sha }}
json: "true"
- name: Filter changed files
id: filter_files
run: echo "filtered_files=$(echo ${{ steps.changed_files.outputs.all_changed_files }} | jq -c 'map(select(startswith("_data/meltano/") and endswith(".yml") and not endswith("airbyte.yml")))' | sed 's/"/\\"/g')" >> "$GITHUB_OUTPUT"
- id: set-matrix
run: echo "matrix={\"changed_file\":${{ steps.filter_files.outputs.filtered_files }}}" >> "$GITHUB_OUTPUT"
dispatch_tests:
runs-on: ubuntu-latest
needs:
- get_changed_files
strategy:
matrix: ${{ fromJson(needs.get_changed_files.outputs.matrix) }}
max-parallel: 4
fail-fast: false
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install yq
env:
VERSION: v4.28.2
BINARY: yq_linux_amd64
run: >
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |
tar xz && mv ${BINARY} yq && chmod u+x yq
- name: Get the name and pip url
run: |
name="$(basename "$(dirname "${{ matrix.changed_file }}")")"
pip_url="$(./yq '.pip_url // ""' "${{ matrix.changed_file }}")"
variant="$(./yq '.variant' "${{ matrix.changed_file }}")"
echo "name=${name}" >> $GITHUB_ENV
echo "pip_url=${pip_url}" >> $GITHUB_ENV
echo "prelude=Testing plugin \`${name}\` (\`${variant}\` variant):" >> $GITHUB_ENV
- name: Find the MeltyBot test-command comment if it exists
if: ${{ env.pip_url != '' }}
id: find_comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: ${{ env.prelude }}
- uses: octokit/[email protected]
if: ${{ env.pip_url != '' }}
with:
route: "POST /repos/${{ github.repository }}/actions/workflows/test-plugin-command.yml/dispatches"
ref: 'main'
inputs: "{\"repository\":\"${{ github.repository }}\",\"comment-id\":\"${{ steps.find_comment.outputs.comment-id }}\",\"issue-number\":\"${{ github.event.pull_request.number }}\",\"name\":\"${{ env.name }}\",\"pip-url\":\"${{ env.pip_url }}\",\"prepend-text\":\"${{ env.prelude }}\"}"
env:
GITHUB_TOKEN: ${{ secrets.MELTYBOT_GITHUB_AUTH_TOKEN }}