forked from DataDog/integrations-core
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 1.94 KB
/
compute-matrix.yml
File metadata and controls
67 lines (56 loc) · 1.94 KB
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
name: Compute matrix
on:
workflow_call:
inputs:
repo:
required: true
type: string
outputs:
matrix:
value: ${{ jobs.compute.outputs.data }}
defaults:
run:
shell: bash
env:
PYTHON_VERSION: "3.13"
MATRIX_SCRIPT: "ddev/src/ddev/utils/scripts/ci_matrix.py"
jobs:
compute:
name: Compute matrix
runs-on: ubuntu-22.04
outputs:
data: "${{ steps.compute.outputs.data }}"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Fetch merge base
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |-
merge_base=$(gh api \
repos/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
--jq '.merge_base_commit.sha')
echo "MERGE_BASE=$merge_base" >> "$GITHUB_ENV"
git -c protocol.version=2 fetch --no-tags --no-recurse-submodules --filter=blob:none origin "$merge_base"
- name: Fetch computation script
if: inputs.repo != 'core'
run: |-
mkdir -p $(dirname ${{ env.MATRIX_SCRIPT }})
curl -sLo ${{ env.MATRIX_SCRIPT }} https://raw.githubusercontent.com/DataDog/integrations-core/master/${{ env.MATRIX_SCRIPT }}
- name: Compute
id: compute
run: |-
python ${{ env.MATRIX_SCRIPT }} -v --ref "$MERGE_BASE" --exact >> /tmp/matrix.json
echo "data=$(cat /tmp/matrix.json)" >> "$GITHUB_OUTPUT"
- name: Show matrix
run: |-
import json
from pathlib import Path
from pprint import pprint
pprint(json.loads(Path('/tmp/matrix.json').read_text(encoding='utf-8')))
shell: python