-
Notifications
You must be signed in to change notification settings - Fork 44
178 lines (165 loc) · 5.61 KB
/
pull-request-check.yml
File metadata and controls
178 lines (165 loc) · 5.61 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
178
#
# Copyright (c) 2021-2025 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
name: Pull Request Check
# Trigger the workflow on pull request
on: [pull_request]
jobs:
check-artifacts:
runs-on: ubuntu-22.04
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Install jq
uses: dcarbone/install-jq-action@v3
with:
version: 1.7
force: true
- name: Generate artifacts
run: ./build/artifacts/generate.sh
- name: Check if artifacts are up to date
run: |
if [[ $(git diff --name-only | wc -l) != 0 ]]; then
# Print difference
git --no-pager diff
echo "[ERROR] Artifacts is not up to date."
echo "[ERROR] Run './build/artifacts/generate.sh' and include file into the commit."
exit 1
fi
build:
name: build
strategy:
fail-fast: false
matrix:
dist: ['libc-ubi8', 'libc-ubi9', 'musl']
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: docker system prune -af
- name: Compile che-code
run: |
docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
-f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile \
-t linux-${{matrix.dist}}-${{env.arch}} .
- name: Display docker images
run: docker images
- name: Compress image to a file
run: docker save linux-${{matrix.dist}}-${{env.arch}} | gzip > linux-${{matrix.dist}}-${{env.arch}}.tgz
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: linux-${{matrix.dist}}-${{env.arch}}
path: linux-${{matrix.dist}}-${{env.arch}}.tgz
assemble:
name: assemble
needs: build
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: docker system prune -af
- name: Download editor artifacts
uses: actions/download-artifact@v4
with:
pattern: linux-*
merge-multiple: true
path: .
- name: List downloaded files
run: ls -lah
- name: Load docker images
run: |
docker load -i linux-libc-ubi8-${{env.arch}}.tgz
docker load -i linux-libc-ubi9-${{env.arch}}.tgz
docker load -i linux-musl-${{env.arch}}.tgz
- name: Display docker images
run: docker images
- name: Update assembly.Dockerfile
run: |
sed "s|FROM linux-libc-ubi8|FROM linux-libc-ubi8-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile"
sed "s|FROM linux-libc-ubi9|FROM linux-libc-ubi9-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile"
sed "s|FROM linux-musl|FROM linux-musl-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile"
- name: Assemble che-code
run: |
docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
-f build/dockerfiles/assembly.Dockerfile \
-t che-code-${{env.arch}} .
- name: Display docker images
run: docker images
- name: Compress image to a file
run: docker save che-code-${{env.arch}} | gzip > che-code-${{env.arch}}.tgz
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: che-code-${{env.arch}}
path: che-code-${{env.arch}}.tgz
- name: Store PR info
run: echo "${{ github.event.number }}" > PR_NUMBER
# Upload PR number artifact only once
- name: Upload PR Number artifact
uses: actions/upload-artifact@v4
if: ${{ env.arch == 'amd64' }}
with:
name: pull-request-number
path: PR_NUMBER
dev:
name: build-che-dev-image
runs-on: ubuntu-22.04
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Free up disk space
run: |
rm -rf /opt/hostedtoolcache
df -h
- name: Cleanup docker images
run: |
docker system prune -af
- name: Build Che-Code Docker image
run: |
docker buildx build \
--platform linux/amd64 \
--progress=plain \
-f build/dockerfiles/dev.Dockerfile \
-t che-dev .
- name: Display docker images
run: |
docker images
- name: Compress che-dev image to a file
run: |
docker save che-dev | gzip > che-dev.tgz
- name: Upload che-dev docker image artifact
uses: actions/upload-artifact@v4
with:
name: che-dev
path: che-dev.tgz