-
Notifications
You must be signed in to change notification settings - Fork 25
110 lines (101 loc) · 4.08 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# 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
# This permissions will propagate to the workflows called by this workflow.
permissions:
# To allow the build workflow to push to the origin, when actions/checkout is used.
contents: write
# To allow the docs workflow to submit a comment using thollander/actions-comment-pull-request
pull-requests: write
# Project file changes:
# - Always validate it
# - Website only metadata -> Skip test/build
# - Deployment metadata (examples_config.deployments, commands) -> We should redeploy, but skip test/build/doc
# - Docs is special, it's just to pull the `evaluated` branch, and this is only useful to get the built notebooks
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 }}
changedprojectsfile: ${{ steps.set-list.outputs.changedprojectsfile }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 100
# - uses: hmarr/debug-action@v2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- 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 --exclude-website-metadata --exclude-deployments-metadata | 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
# There's logic to skip testing/building when only some metadata in the
# project file changes. In these cases, we still want to validate the project file.
- name: validate project files
run: |
CHANGESPROJECTSFILE=$(doit util_list_changed_dirs_with_main --only-project-file | tail -n -1)
CHANGEDPROJECTSFILE=$(echo $CHANGESPROJECTSFILE | jq -c -r '.changed')
echo "Changed projects (project file only): $CHANGEDPROJECTSFILE"
if [ "$CHANGEDPROJECTSFILE" != "[]" ]; then
items=$(echo $CHANGEDPROJECTSFILE | jq -c -r '.[]')
for item in ${items[@]}; do
doit validate_project_file:$item
done
fi
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