-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (187 loc) · 7.13 KB
/
arm64.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
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
name: arm64 R builds
on:
workflow_dispatch:
inputs:
platforms:
description: |
Comma-separated list of platforms. Specify "all" to use all platforms (the default).
required: false
default: 'all'
type: string
r_versions:
description: |
Comma-separated list of R versions. Specify "last-N" to use the
last N minor R versions, or "all" to use all minor R versions since R 3.1.
Defaults to "last-5".
required: false
default: 'next,devel'
type: string
schedule:
- cron: '55 2 * * *'
permissions:
contents: read
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
platforms: ${{ steps.setup-matrix.outputs.platforms }}
r_versions: ${{ steps.setup-matrix.outputs.r_versions }}
arm64: ${{ steps.setup-matrix.outputs.arm64 }}
steps:
- uses: actions/checkout@v4
- name: Set up matrix of platforms and R versions
id: setup-matrix
run: |
platforms=$(python test/get_platforms.py ${{ github.event.inputs.platforms }})
echo "platforms=$platforms" >> $GITHUB_OUTPUT
r_versions=$(python test/get_r_versions.py ${{ github.event.inputs.r_versions || 'next,devel' }})
echo "r_versions=$r_versions" >> $GITHUB_OUTPUT
arm64=$(python test/get_arm64.py ${{ github.event.inputs.platforms || 'all' }} ${{ github.event.inputs.r_versions || 'next,devel' }})
echo "arm64=$arm64" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
docker-images:
needs: setup-matrix
if: ${{ needs.setup-matrix.outputs.platforms != '' && needs.setup-matrix.outputs.platforms != '[]' }}
strategy:
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
runs-on: ubuntu-latest
name: Docker image (${{ matrix.platform }})
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
platforms: linux/arm64
# Enable Docker layer caching without having to push to a registry.
# https://docs.docker.com/build/ci/github-actions/examples/#local-cache
# This may eventually be migrated to the GitHub Actions cache backend,
# which is still considered experimental.
# https://github.com/moby/buildkit#github-actions-cache-experimental
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ matrix.platform }}-arm64-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-arm64-buildx-
# Use docker buildx instead of docker-compose here because cache exporting
# does not seem to work as of docker-compose v2.6.0 and buildx v0.8.2, even
# though it works with buildx individually.
- name: Build image
run: |
docker buildx build -t r-builds:${{ matrix.platform }} \
--platform linux/arm64 \
--file builder/Dockerfile.${{ matrix.platform }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new,mode=max" \
builder
# Temporary workaround for unbounded GHA cache growth with the local cache mode.
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build:
needs: [setup-matrix, docker-images]
if: ${{ needs.setup-matrix.outputs.platforms != '' && needs.setup-matrix.outputs.r_versions != '' }}
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
r_version: ${{ fromJson(needs.setup-matrix.outputs.r_versions) }}
runs-on: ubuntu-latest
name: ${{ matrix.platform }} (R ${{ matrix.r_version }})
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
platforms: linux/arm64
- name: Restore cached Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ matrix.platform }}-arm64-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-arm64-buildx-
- name: Load cached Docker image
run: |
docker buildx build -t r-builds:${{ matrix.platform }} \
--platform linux/arm64 \
--file builder/Dockerfile.${{ matrix.platform }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--load \
builder
- name: Build R
run: |
cd builder && docker compose up ${{ matrix.platform }}
env:
R_VERSION: ${{ matrix.r_version }}
DOCKER_DEFAULT_PLATFORM: linux/arm64
- name: Copy and rename package
run: |
pkg=$(find builder/integration -name "*.deb" -or -name "*.rpm")
pkg2=$(echo $pkg | sed "s|/[rR]-|/r-rstudio-${{ matrix.platform }}-|")
pkg2=$(basename "$pkg2")
cp "$pkg" "$pkg2"
ls -l .
- name: Release
uses: softprops/action-gh-release@v2
with:
repository: r-hub/R
token: ${{ secrets.DEPLOY_TOKEN }}
files: |
*-rstudio-*.deb
*-rstudio-*.rpm
name: "R ${{ matrix.r_version }}"
tag_name: v${{ matrix.r_version }}
arm64:
needs: setup-matrix
if: ${{ always() && needs.setup-matrix.outputs.arm64 != '[]' }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup-matrix.outputs.arm64) }}
runs-on: [self-hosted, linux, ARM64]
name: Native (${{ matrix.config.platform }} ${{ matrix.config.rversion }})
container:
image: "ubuntu:22.04"
volumes:
- ${{ github.workspace }}:/${{ github.workspace }}
steps:
- uses: actions/checkout@v4
- name: Install Docker
run: |
apt-get update && apt-get install -y docker.io docker-compose-v2
- name: Build R
run: |
cd ${{ github.workspace }}
cd builder &&
mkdir -p integration &&
docker compose build ${{ matrix.config.platform }}
docker compose up ${{ matrix.config.platform }}
env:
R_VERSION: ${{ matrix.config.rversion }}
- name: Copy and rename package
run: |
pkg=$(find builder/integration -name "*.deb" -or -name "*.rpm")
pkg2=$(echo $pkg | sed "s|/[rR]-|/r-rstudio-${{ matrix.config.platform }}-|")
pkg2=$(basename "$pkg2")
cp "$pkg" "$pkg2"
ls -l .
- name: Release
uses: softprops/action-gh-release@v2
with:
repository: r-hub/R
token: ${{ secrets.DEPLOY_TOKEN }}
files: |
*-rstudio-*.deb
*-rstudio-*.rpm
name: "R ${{ matrix.config.rversion }}"
tag_name: v${{ matrix.config.rversion }}