forked from data-prep-kit/data-prep-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (157 loc) · 8.05 KB
/
Copy pathtest-code-code_quality-kfp.yml
File metadata and controls
167 lines (157 loc) · 8.05 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#
# DO NOT EDIT THIS FILE: it is generated from test-transform.template, Edit there and run make to change these files
#
name: Test2 KFP - transforms/code/code_quality
on:
workflow_dispatch:
push:
branches:
- "dev"
- "releases/**"
tags:
- "*"
paths:
- ".make.*"
- "scripts/k8s-setup/requirements.env"
- "transforms/.make.workflows"
- "transforms/code/code_quality/**"
- "!kfp/**" # This is tested in separate workflow
- "!data-processing-lib/**" # This is tested in separate workflow
- "!**.md"
- "!**/doc/**"
- "!**/images/**"
- "!**.gitignore"
# This only works when using pull_request_target as it
# runs in the context of the target branch and not the new branch
pull_request_target:
branches:
- "dev"
- "releases/**"
paths:
- ".make.*"
- "scripts/k8s-setup/requirements.env"
- "transforms/.make.workflows"
- "transforms/code/code_quality/**"
- "!data-processing-lib/**" # This is tested in separate workflow
- "!kfp/**" # This is tested in separate workflow
- "!**.md"
- "!**/doc/**"
- "!**/images/**"
- "!**.gitignore"
# taken from https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Verify that only a trusted person, can run the workflow.
# reminder to PR reviewers: Pay attention on whether the code is exposing any secrets.
check_if_allowed:
# check if user allowed to run restricted workflows
runs-on: ubuntu-22.04
outputs:
restricted_access: ${{ steps.permission.outputs.restricted_access }}
steps:
- id: permission
run: |
echo "Check if ${{ github.triggering_actor }} is allowed to run priviledge workflows"
restricted_acccess=${{ github.event.pull_request.head.repo.fork }}
if [[ "${{ vars.PRIVILEGED_USERS }}" == *+${{ github.triggering_actor }}+* ]]; then
restricted_access=false
fi
if $restricted_access; then
echo "User ${{ github.triggering_actor }} is not in Authorized users list: ${{ vars.PRIVILEGED_USERS }} "
exit 1
fi
test-kfp-v1:
needs: [check_if_allowed]
runs-on: ubuntu-22.04
env:
HF_READ_ACCESS_TOKEN: ${{ secrets.HF_READ_ACCESS_TOKEN }}
steps:
- name: Expose secret to trusted users working in a fork
if: "!needs.check_if_allowed.outputs.restricted_access"
run: |
echo "Checking actor:${{ github.actor }} Trigger_actor:${{ github.triggering_actor }} user.login=${{ github.event.pull_request.user.login }}"
echo "Checking PR.head.sha:${{ github.event.pull_request.head.sha }} github.ref: ${{ github.ref }}"
- name: Checkout
uses: actions/checkout@v4
with:
# Requires careful code review prior to triggering workflow
ref: ${{ github.event.pull_request.head.sha }}
- name: Free up space in github runner
# Free space as indicated here : https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
run: |
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /usr/local/share/powershell /usr/share/swift /usr/lib/jvm /usr/local/.ghcup
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
df -h
- name: Import environment variables
run: |
cat scripts/k8s-setup/requirements.env >> $GITHUB_ENV
echo "K8S_SETUP_SCRIPTS=$PWD/scripts/k8s-setup" >> $GITHUB_ENV
echo "REPOROOT=$PWD" >> $GITHUB_ENV
echo "PATH=$PATH:/tmp" >> $GITHUB_ENV
- name: Test V1 KFP workflow for transforms/code/code_quality
timeout-minutes: 120
run: |
KFP_BLACK_LIST=$(./scripts/check-workflows.sh -show-kfp-black-list)
if [ -e "transforms/code/code_quality/Makefile" -a -e "transforms/code/code_quality/kfp_ray/Makefile" ]; then
transform=$(basename "transforms/code/code_quality")
if echo ${KFP_BLACK_LIST} | grep -qv ${transform}; then
$PWD/scripts/workflow_helper.sh install-tools
$PWD/scripts/workflow_helper.sh test-workflow transforms/code/code_quality
else
$PWD/scripts/workflow_helper.sh build-workflow transforms/code/code_quality
fi
else
echo "Skipping transforms/code/code_quality kfp test for lack of Makefile and/or kfp_ray/Makefile"
fi
test-kfp-v2:
needs: [check_if_allowed]
runs-on: ubuntu-22.04
env:
HF_READ_ACCESS_TOKEN: ${{ secrets.HF_READ_ACCESS_TOKEN }}
steps:
- name: Expose secret to trusted users working in a fork
if: "!needs.check_if_allowed.outputs.restricted_access"
run: |
echo "Checking actor:${{ github.actor }} Trigger_actor:${{ github.triggering_actor }} user.login=${{ github.event.pull_request.user.login }}"
echo "Checking PR.head.sha:${{ github.event.pull_request.head.sha }} github.ref: ${{ github.ref }}"
- name: Checkout
uses: actions/checkout@v4
with:
# Requires careful code review prior to triggering workflow
ref: ${{ github.event.pull_request.head.sha }}
- name: Free up space in github runner
# Free space as indicated here : https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
run: |
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /usr/local/share/powershell /usr/share/swift /usr/lib/jvm /usr/local/.ghcup
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
df -h
- name: Import environment variables
run: |
cat scripts/k8s-setup/requirements.env >> $GITHUB_ENV
echo "K8S_SETUP_SCRIPTS=$PWD/scripts/k8s-setup" >> $GITHUB_ENV
echo "REPOROOT=$PWD" >> $GITHUB_ENV
echo "PATH=$PATH:/tmp" >> $GITHUB_ENV
echo "KFPv2=1" >> $GITHUB_ENV
- name: Test V2 KFP workflow for transforms/code/code_quality
timeout-minutes: 120
run: |
KFP_BLACK_LIST=$(./scripts/check-workflows.sh -show-kfp-black-list)
if [ -e "transforms/code/code_quality/Makefile" -a -e "transforms/code/code_quality/kfp_ray/Makefile" ]; then
transform=$(basename "transforms/code/code_quality")
if echo ${KFP_BLACK_LIST} | grep -qv ${transform}; then
$PWD/scripts/workflow_helper.sh install-tools
$PWD/scripts/workflow_helper.sh test-workflow transforms/code/code_quality
else
$PWD/scripts/workflow_helper.sh build-workflow transforms/code/code_quality
fi
else
echo "Skipping transforms/code/code_quality kfp test for lack of Makefile and/or kfp_ray/Makefile"
fi