-
Notifications
You must be signed in to change notification settings - Fork 24
91 lines (83 loc) · 2.8 KB
/
pr_flow.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
# Called when someone is committing in a PR.
# This runs:
# - setup: to find out which projects changed compared to main
# - test: test the changed projects in a matrix
# - build: build the changed projects in a matrix, this creates a branch to save the evaluated projects
# - docs: build the dev docs, collecting the evaluated projects from `evaluated` and the new branch
name: test+build+doc
on:
pull_request:
branches:
- "main"
# Cancel previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
setup:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 10
outputs:
changedprojects: ${{ steps.set-list.outputs.changedprojects }}
removedprojects: ${{ steps.set-list.outputs.removedprojects }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- uses: hmarr/debug-action@v2
- run: |
git branch
echo "DEBUG"
git checkout -b foo
git checkout ${GITHUB_REF}
git log
- run: exit 1
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: install deps
# Minimal required deps to run the following script
run: pip install doit pyyaml
- name: infer project list
id: set-list
run: |
CHANGES=$(doit util_list_changed_dirs_with_main | tail -n -1)
CHANGEDPROJECTS=$(echo $CHANGES | jq -c -r '.changed')
REMOVEDPROJECTS=$(echo $CHANGES | jq -c -r '.removed')
echo "Changed projects: $CHANGEDPROJECTS"
echo "Removed projects: $REMOVEDPROJECTS"
if [ "$CHANGEDPROJECTS" != "[]" -a "$REMOVEDPROJECTS" != "[]" ]; then
echo "No support for removing and updating projects together"
echo "Open a PR that just remove project"
exit 1
fi
echo "CHANGEDPROJECTS=$CHANGEDPROJECTS" >> $GITHUB_OUTPUT
echo "REMOVEDPROJECTS=$REMOVEDPROJECTS" >> $GITHUB_OUTPUT
test:
needs: setup
uses: ./.github/workflows/test.yml
with:
projects: ${{ needs.setup.outputs.changedprojects }}
type: workflow_call
secrets: inherit
build:
needs: [setup, test]
uses: ./.github/workflows/build.yml
with:
projects: ${{ needs.setup.outputs.changedprojects }}
type: workflow_call
branch: ${{ github.event.pull_request.head.ref }}
docs:
needs: [setup, build]
if: needs.build.result == 'success' || needs.build.result == 'skipped'
uses: ./.github/workflows/docs.yml
with:
target: dev
branch: ${{ github.event.pull_request.head.ref }}
changedprojects: ${{ needs.setup.outputs.changedprojects }}
removedprojects: ${{ needs.setup.outputs.removedprojects }}
type: workflow_call
secrets: inherit