-
Notifications
You must be signed in to change notification settings - Fork 3.3k
214 lines (193 loc) · 8.19 KB
/
Copy pathreusable-pack.yaml
File metadata and controls
214 lines (193 loc) · 8.19 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# %CopyrightBegin%
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright Ericsson AB 2024-2026. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# %CopyrightEnd%
name: Build Erlang/OTP (64-bit)
on:
workflow_call:
inputs:
base_branch:
required: true
type: string
full_build_and_check:
required: true
type: string
description: "'true' | 'false' as string"
bypass_erlang_repo:
required: true
type: boolean
description: "Bypasses checks of github.repository being 'erlang/otp'. Used for testing in forks"
outputs:
changes:
description: "changed apps"
value: ${{ jobs.pack.outputs.changes }}
build-c-code:
description: "'true' if C code must be rebuilt"
value: ${{ jobs.pack.outputs.build-c-code }}
# this echo below is due to a limitation where github erases the outsputs from other jobs.
base_branch:
value: ${{ inputs.base_branch }}
permissions:
contents: read
jobs:
pack:
name: Build Erlang/OTP (64-bit)
runs-on: ubuntu-latest
permissions:
contents: read # actions/checkout + actions/cache (read/write cache)
actions: write # actions/upload-artifact
if: github.repository == 'erlang/otp' || github.event_name != 'schedule' || inputs.bypass_erlang_repo
outputs:
changes: ${{ steps.changes.outputs.changes }}
build-c-code: ${{ steps.build-c-code.outputs.value }}
all: ${{ steps.apps.outputs.all }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/build-base-image
with:
BASE_BRANCH: ${{ inputs.base_branch }}
BUILD_IMAGE: false
- name: Get applications
id: apps
run: |
.github/scripts/path-filters.sh > .github/scripts/path-filters.yaml
.github/scripts/c-code-path-filters.sh > .github/scripts/c-code-path-filters.yaml
cat .github/scripts/path-filters.yaml
cat .github/scripts/c-code-path-filters.yaml
ALL_APPS=$(grep '^[a-z_]*:' .github/scripts/path-filters.yaml | sed 's/:.*$//')
ALL_APPS=$(jq -n --arg inarr "${ALL_APPS}" '$inarr | split("\n")' | tr '\n' ' ')
echo "all=${ALL_APPS}" >> $GITHUB_OUTPUT
- name: Check which applications have changed
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: app-changes
with:
filters: .github/scripts/path-filters.yaml
# 'changes' is an output parameter
- name: Override which applications have changed
id: changes
env:
ALL_APPS: ${{ steps.apps.outputs.all }}
CHANGED_APPS: ${{ steps.app-changes.outputs.changes }}
FULL_BUILD_AND_CHECK: ${{ inputs.full_build_and_check }}
run: |
if [ "${FULL_BUILD_AND_CHECK}" = "true" ]; then
echo "changes=${ALL_APPS}" >> "$GITHUB_OUTPUT"
else
echo "changes=${CHANGED_APPS}" >> "$GITHUB_OUTPUT"
fi
- name: Check if there are any C-code changes, if not then limit CI run
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: c-code-changes
with:
filters: .github/scripts/c-code-path-filters.yaml
# 'value' is an output parameter
- name: Set build-c-code output
id: build-c-code
env:
CHANGES: ${{ steps.c-code-changes.outputs.changes }}
BUILD_AND_CHECK: ${{ inputs.full_build_and_check }}
run: |
if [[ "${CHANGES}" != "[]" || "${BUILD_AND_CHECK}" == "true" ]]; then
echo "value=true" >> $GITHUB_OUTPUT
else
echo "value=false" >> $GITHUB_OUTPUT
fi
- name: Cache pre-built src
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: otp_src.tar.gz
key: prebuilt-src-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
prebuilt-src-${{ github.base_ref }}-${{ github.event.pull_request.base.sha }}
- name: Cache pre-built binaries
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: otp_cache.tar.gz
key: prebuilt-cache-64-bit-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
prebuilt-cache-64-bit-${{ github.base_ref }}-${{ github.event.pull_request.base.sha }}
- name: Create initial pre-release tar
run: .github/scripts/init-pre-release.sh otp_archive.tar.gz otp_src.tar.gz
- name: Upload source tar archive
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # ratchet:actions/upload-artifact@v6.0.0
with:
name: otp_git_archive
path: otp_archive.tar.gz
- name: Check how we can use the pre-built cache
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: cache
with:
filters: |
no-cache:
- '.github/**'
- deleted: '**/*.h'
deleted:
- deleted: '**'
bootstrap:
- 'bootstrap/**'
configure:
- '**.ac'
- '**.in'
list-files: shell
- name: Restore from cache
env:
NO_CACHE: ${{ fromJson(steps.cache.outputs.no-cache) || fromJson(inputs.full_build_and_check) || fromJson(steps.cache.outputs.deleted_count) > 20 }}
BOOTSTRAP: ${{ steps.cache.outputs.bootstrap }}
CONFIGURE: ${{ steps.cache.outputs.configure }}
EVENT: ${{ github.event_name }}
DELETED: ${{ fromJson(steps.cache.outputs.deleted_count) > 20 && '[]' || steps.cache.outputs.deleted_files }}
run: |
.github/scripts/restore-from-prebuilt.sh "`pwd`" \
"`pwd`/.github/otp.tar.gz" \
"`pwd`/otp_archive.tar.gz"
- name: Upload restored cache
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # ratchet:actions/upload-artifact@v6.0.0
if: runner.debug == 1
with:
name: restored-cache
path: .github/otp.tar.gz
- name: Build image
run: |
docker build --tag otp \
--build-arg MAKEFLAGS=-j$(($(nproc) + 2)) \
--file ".github/dockerfiles/Dockerfile.64-bit" \
.github/
- name: Build pre-built tar archives
run: |
docker run -v $PWD:/github --entrypoint "" otp \
scripts/build-otp-tar -o /github/otp_clean_src.tar.gz /github/otp_src.tar.gz -b /buildroot/otp/ /github/otp_archive.tar.gz
- name: Build cache
run: |
if [ -f otp_cache.tar.gz ]; then
gunzip otp_cache.tar.gz
else
docker run -v $PWD:/github --entrypoint "" otp \
bash -c 'cp ../otp_cache.tar /github/'
fi
docker run -v $PWD:/github --entrypoint "" otp \
bash -c 'set -x; C_APPS=$(ls -d ./lib/*/c_src); find Makefile ./make ./erts ./bin/`erts/autoconf/config.guess` ./lib/erl_interface ./lib/jinterface ${C_APPS} `echo "${C_APPS}" | sed -e 's:c_src$:priv:'` -type f -newer README.md \! -name "*.beam" \! -path "*/doc/*" \! -path "./erts/preloaded/*" | xargs tar --transform "s:^./:otp/:" -uvf /github/otp_cache.tar'
gzip otp_cache.tar
- name: Upload pre-built tar archives
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # ratchet:actions/upload-artifact@v6.0.0
with:
name: otp_prebuilt
path: |
otp_src.tar.gz
otp_cache.tar.gz