forked from data-prep-kit/data-prep-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (166 loc) · 8.08 KB
/
Copy pathtest-code-code_quality.yml
File metadata and controls
177 lines (166 loc) · 8.08 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
168
169
170
171
172
173
174
175
176
177
#
# DO NOT EDIT THIS FILE: it is generated from test-transform.template, Edit there and run make to change these files
#
name: Test2 - transforms/code/code_quality
on:
workflow_dispatch:
push:
branches:
- "dev"
- "releases/**"
tags:
- "*"
paths:
- ".make.*"
- "transforms/.make.transforms"
- "transforms/code/code_quality/**"
- "data-processing-lib/**"
- "!transforms/code/code_quality/**/kfp_ray/**" # This is/will be tested in separate workflow
- "!data-processing-lib/**/test/**"
- "!data-processing-lib/**/test-data/**"
- "!**.md"
- "!**/doc/**"
- "!**/images/**"
- "!**.gitignore"
pull_request_target:
branches:
- "dev"
- "releases/**"
paths:
- ".make.*"
- "transforms/.make.transforms"
- "transforms/code/code_quality/**"
- "data-processing-lib/**"
- "!transforms/code/code_quality/**/kfp_ray/**" # This is/will be tested in separate workflow
- "!data-processing-lib/**/test/**"
- "!data-processing-lib/**/test-data/**"
- "!**.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:
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
check_if_push_image:
# check whether the Docker images should be pushed to the remote repository
# The images are pushed if it is a merge to dev branch or a new tag is created.
# The latter being part of the release process.
# The images tag is derived from the value of the DOCKER_IMAGE_VERSION variable set in the .make.versions file.
runs-on: ubuntu-22.04
outputs:
publish_images: ${{ steps.version.outputs.publish_images }}
steps:
- id: version
run: |
publish_images='false'
if [[ ${GITHUB_REF} == refs/heads/dev && ${GITHUB_EVENT_NAME} != 'pull_request' && ${GITHUB_REPOSITORY} == IBM/data-prep-kit ]] ;
then
publish_images='true'
fi
if [[ ${GITHUB_REF} == refs/tags/* && ${GITHUB_REPOSITORY} == IBM/data-prep-kit ]] ;
then
publish_images='true'
fi
echo "publish_images=$publish_images" >> "$GITHUB_OUTPUT"
test-src:
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/local/.ghcup
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
df -h
- name: Test transform source in transforms/code/code_quality
run: |
if [ -e "transforms/code/code_quality/Makefile" ]; then
make -C transforms/code/code_quality DOCKER=docker test-src
else
echo "transforms/code/code_quality/Makefile not found - source testing disabled for this transform."
fi
test-image:
needs: [check_if_push_image, check_if_allowed]
runs-on: ubuntu-22.04
timeout-minutes: 120
env:
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
DOCKER_REGISTRY_KEY: ${{ secrets.DOCKER_REGISTRY_KEY }}
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 /opt/ghc
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: Test transform image in transforms/code/code_quality
run: |
if [ -e "transforms/code/code_quality/Makefile" ]; then
if [ -d "transforms/code/code_quality/spark" ]; then
make -C data-processing-lib/spark DOCKER=docker image
fi
make -C transforms/code/code_quality DOCKER=docker test-image
else
echo "transforms/code/code_quality/Makefile not found - testing disabled for this transform."
fi
- name: Print space
# Free space as indicated here : https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
run: |
df -h
docker images
- name: Publish images
if: needs.check_if_push_image.outputs.publish_images == 'true'
run: |
if [ -e "transforms/code/code_quality/Makefile" ]; then
make -C transforms/code/code_quality publish
else
echo "transforms/code/code_quality/Makefile not found - publishing disabled for this transform."
fi