File: r_nightly.yml

package info (click to toggle)
apache-arrow 23.0.1-4
  • links: PTS
  • area: main
  • in suites:
  • size: 76,368 kB
  • sloc: cpp: 654,608; python: 70,522; ruby: 45,964; ansic: 18,742; sh: 7,367; makefile: 633; javascript: 125; xml: 41
file content (216 lines) | stat: -rw-r--r-- 7,594 bytes parent folder | download | duplicates (6)
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
215
216
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

name: Upload R Nightly builds
# This workflow downloads the (nightly) binaries created in crossbow and uploads them
# to nightlies.apache.org. Due to authorization requirements, this upload can't be done
# from the crossbow repository.

on:
  workflow_dispatch:
    inputs:
      prefix:
        description: Job prefix to use.
        required: false
        default: ''
      keep:
        description: Number of versions to keep.
        required: false
        default: 14

  schedule:
    #Crossbow packaging runs at 0 8 * * *
    - cron: '0 14 * * *'

permissions:
  contents: read

jobs:
  upload:
    if: github.repository == 'apache/arrow'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Arrow
        uses: actions/checkout@v6
        with:
          fetch-depth: 1
          path: arrow
          repository: apache/arrow
          ref: main
          submodules: recursive
      - name: Checkout Crossbow
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          path: crossbow
          repository: ursacomputing/crossbow
          ref: main
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: 3.12
      - name: Install Archery
        shell: bash
        run: pip install -e arrow/dev/archery[all]
      - run: mkdir -p binaries
      - name: Download Artifacts
        env:
          PREFIX: ${{ github.event.inputs.prefix || ''}}
        run: |
          if [ -z $PREFIX ]; then
            PREFIX=nightly-packaging-$(date +%Y-%m-%d)-0
          fi
          echo $PREFIX

          archery crossbow download-artifacts -f r-binary-packages -t binaries $PREFIX

          if [ -n "$(ls -A binaries/*/*/)" ]; then
            echo "Found files!"
          else
            echo "No files found. Stopping upload."
            exit 1
          fi
      - name: Cache Repo
        uses: actions/cache@v5
        with:
          path: repo
          key: r-nightly-${{ github.run_id }}
          restore-keys: r-nightly-
      - name: Sync from Remote
        uses: ./arrow/.github/actions/sync-nightlies
        with:
          switches: -avzh --update --delete --progress
          local_path: repo
          remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/arrow/r
          remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
          remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
          remote_user: ${{ secrets.NIGHTLIES_RSYNC_USER }}
          remote_key: ${{ secrets.NIGHTLIES_RSYNC_KEY }}
          remote_host_key: ${{ secrets.NIGHTLIES_RSYNC_HOST_KEY }}
      - run: tree repo
      - uses: r-lib/actions/setup-r@v2
      - name: Build Repository
        shell: Rscript {0}
        run: |
          # folder that we sync to nightlies.apache.org
          repo_root <- "repo"
          # The binaries are in a nested dir
          # so we need to find the correct path.
          art_path <- list.files("binaries",
            recursive = TRUE,
            include.dirs = TRUE,
            pattern = "r-binary-packages$",
            full.names = TRUE
          )

          current_pkg_path <- list.files(art_path,
            full.names = TRUE,
            pattern = "r-pkg",
            recursive = TRUE
          )
          current_lib_path <- list.files(art_path,
            full.names = TRUE,
            pattern = "r-libarrow",
            recursive = TRUE
          )
          current_path <- c(current_pkg_path, current_lib_path)
          files <- c(
            sub("r-pkg", repo_root, current_pkg_path),
            sub("r-libarrow", paste0(repo_root, "__libarrow__r-libarrow"), current_lib_path)
          )

          # decode contrib.url from artifact name:
          # bin__windows__contrib__4.1 -> bin/windows/contrib/4.1
          new_paths <- gsub("__", "/", files)
          # strip superfluous nested dirs
          new_paths <- sub(art_path, ".", new_paths)
          dirs <- dirname(new_paths)
          sapply(dirs, dir.create, recursive = TRUE, showWarnings = FALSE)

          # overwrite allows us to "force push" a new version with the same name
          copy_result <- file.copy(current_path, new_paths, overwrite = TRUE)

          if (!all(copy_result)) {
            stop("There was an issue while copying the files!")
          }
      - name: Prune Repository
        shell: bash
        env:
          KEEP: ${{ github.event.inputs.keep || 14 }}
        run: |
          set -x

          prune() {
            # list files  | retain $KEEP newest files | delete everything else
            ls -t "$@" | tail -n +$((KEEP + 1)) | xargs --no-run-if-empty rm
          }

          # find leaf sub dirs and store in array
          mapfile -t repo_dirs < <(find repo -type d -links 2)

          # Old packages: repo/libarrow/bin/${TARGET}/arrow-${VERSION}.zip
          #
          # We want to retain $keep (14) versions of each pkg/lib so we call
          # prune on each leaf dir and not on repo/.
          for dir in "${repo_dirs[@]}"; do
            prune "$dir"/arrow* || :
          done

          # New packages: repo/libarrow/${TARGET}-arrow-${VERSION}.zip
          prune repo/libarrow/r-libarrow-darwin-arm64-* || :
          prune repo/libarrow/r-libarrow-darwin-x86_64-* || :
          prune repo/libarrow/r-libarrow-linux-x86_64-* || :
          prune repo/libarrow/r-libarrow-windows-x86_64-* || :
      - name: Update Repository Index
        shell: Rscript {0}
        run: |
          # folder that we sync to nightlies.apache.org
          repo_root <- "repo"
          tools::write_PACKAGES(file.path(repo_root, "src/contrib"),
            type = "source",
            verbose = TRUE,
            latestOnly = FALSE
          )

          repo_dirs <- list.dirs(repo_root)
          # find dirs with binary R packages: e.g. */contrib/4.1
          pkg_dirs <- grep(".+contrib\\/\\d.+", repo_dirs, value = TRUE)


          for (dir in pkg_dirs) {
            on_win <- grepl("windows", dir)
            tools::write_PACKAGES(dir,
              type = ifelse(on_win, "win.binary", "mac.binary"),
              verbose = TRUE,
              latestOnly = FALSE
            )
          }
      - name: Show repo contents
        run: tree repo
      - name: Sync to Remote
        uses: ./arrow/.github/actions/sync-nightlies
        with:
          upload: true
          switches: -avzh --update --delete --progress
          local_path: repo
          remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/arrow/r
          remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
          remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
          remote_user: ${{ secrets.NIGHTLIES_RSYNC_USER }}
          remote_key: ${{ secrets.NIGHTLIES_RSYNC_KEY }}
          remote_host_key: ${{ secrets.NIGHTLIES_RSYNC_HOST_KEY }}