Repository navigation
77 lines (65 loc) · 2.2 KB
/
Copy pathcompute-matrix.yml
File metadata and controls
77 lines (65 loc) · 2.2 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
68
69
70
71
72
73
74
75
76
77
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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: Checkout computation script
if: inputs.repo != 'core'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: DataDog/integrations-core
ref: ${{ job.workflow_sha }}
fetch-depth: 1
sparse-checkout: ddev/src/ddev/utils/scripts
path: core-temp
- name: Install computation script
if: inputs.repo != 'core'
run: |-
mkdir -p "$(dirname "$MATRIX_SCRIPT")"
cp "core-temp/$MATRIX_SCRIPT" "$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