File: macros.jinja

package info (click to toggle)
apache-arrow 23.0.1-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 76,220 kB
  • sloc: cpp: 654,608; python: 70,522; ruby: 45,964; ansic: 18,742; sh: 7,365; makefile: 669; javascript: 125; xml: 41
file content (300 lines) | stat: -rw-r--r-- 10,013 bytes parent folder | download | duplicates (3)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# 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.

{%- macro github_header() -%}
# NOTE: must set "Crossbow" as name to have the badge links working in the
# github comment reports!
name: Crossbow
on:
  push:
    branches:
      - "*-github-*"

env:
  ARCHERY_DEBUG: 1
{% endmacro %}

{%- macro github_checkout_arrow(fetch_depth=1, submodules="recursive", action_v="4") -%}
  - name: Checkout Arrow
    uses: actions/checkout@v{{ action_v }}
    with:
      fetch-depth: {{ fetch_depth }}
      path: arrow
      repository: {{ arrow.github_repo }}
      ref: {{ arrow.head }}
      submodules: {{ submodules }}
{% endmacro %}

{%- macro github_login_dockerhub() -%}
  - name: Login to Dockerhub
    uses: docker/login-action@v2
    with:
      username: {{ '${{ secrets.DOCKERHUB_USER }}' }}
      password: {{ '${{ secrets.DOCKERHUB_TOKEN }}' }}
{% endmacro %}

{%- macro github_login_ghcr() -%}
  - name: Login to GitHub Container Registry
    uses: docker/login-action@v2
    with:
      registry: ghcr.io
      username: {{ '${{ github.actor }}' }}
      password: {{ '${{ secrets.GITHUB_TOKEN }}' }}
{% endmacro %}

{%- macro github_install_archery() -%}
  - name: Set up Python
    uses: actions/setup-python@v4
    with:
      cache: 'pip'
      python-version: 3.12
  - name: Install Archery
    shell: bash
    run: pip install -e arrow/dev/archery[all]
{% endmacro %}

{%- macro github_free_space() -%}
  - name: Free up disk space
    if: runner.os == 'Linux' && runner.arch == 'X64'
    shell: bash
    run: |
      arrow/ci/scripts/util_free_space.sh
{% endmacro %}

{%- macro github_upload_releases(pattern) -%}
  - name: Set up Python
    uses: actions/setup-python@v4
    with:
      python-version: 3.12
  - name: Checkout Crossbow
    uses: actions/checkout@v4
    with:
      path: crossbow
      ref: {{ job.branch }}
  - name: Setup Crossbow
    shell: bash
    run: |
      python3 -m pip install -e arrow/dev/archery[crossbow]
      echo "$HOME/.local/bin" >> $GITHUB_PATH
  - name: Upload artifacts
    shell: bash
    run: |
      archery crossbow \
        --queue-path $(pwd)/crossbow \
        --queue-remote {{ queue_remote_url }} \
        upload-artifacts \
        --sha {{ task.branch }} \
        --tag {{ task.tag }} \
      {% if pattern is string %}
        "{{ pattern }}"
      {% elif pattern is iterable %}
        {% for p in pattern %}
        "{{ p }}" {{ "\\" if not loop.last else "" }}
        {% endfor %}
      {% endif %}
    env:
      CROSSBOW_GITHUB_TOKEN: {{ '${{ secrets.CROSSBOW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}' }}
  - name: Verify uploaded artifacts
    shell: bash
    run: |
      archery crossbow \
        --queue-path $(pwd)/crossbow \
        --queue-remote {{ queue_remote_url }} \
        status \
        --task-filter '{{ task.name }}' \
        --no-fetch \
        --validate \
        {{ job.branch }}
    env:
      CROSSBOW_GITHUB_TOKEN: {{ '${{ secrets.CROSSBOW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}' }}
{% endmacro %}

{%- macro github_upload_wheel_scientific_python(pattern) -%}
  {%- if arrow.is_default_branch() -%}
  - name: Upload wheel to Anaconda scientific-python
    shell: bash
    run: |
      # check if completion actually expands to wheel files
      # to prevent empty dirs from failing silently
      if ! compgen -G "{{ pattern }}" > /dev/null; then
          echo "No wheel files found!"
          exit 1
      fi
      python3 -m pip install git+https://github.com/Anaconda-Platform/anaconda-client.git@1.12.3
      anaconda -t ${CROSSBOW_SCIENTIFIC_PYTHON_UPLOAD_TOKEN} upload --force -u scientific-python-nightly-wheels --label main {{ pattern }}
    env:
      CROSSBOW_SCIENTIFIC_PYTHON_UPLOAD_TOKEN: {{ '${{ secrets.CROSSBOW_SCIENTIFIC_PYTHON_UPLOAD_TOKEN }}' }}
  {% endif %}
{% endmacro %}

{%- macro configure_homebrew_arrow(formula) -%}
  - name: Configure Homebrew formula for testing
    env:
      ARROW_FORMULA: ./arrow/dev/tasks/homebrew-formulae/{{ formula }}
    run: |
      brew update || echo "brew update did not finish successfully"
      brew --version
      brew unlink python@2 || true
      brew config
      brew doctor || true
      # The GHA runners install of python > 3.10 is incompatible with brew so we
      # have to force overwriting of the symlinks
      # see https://github.com/actions/runner-images/issues/6868
      brew install --overwrite python@3.12 python@3.11 python@3.10

      set -x
      ARROW_GLIB_FORMULA=$(echo ${ARROW_FORMULA} | sed -e 's/\.rb/-glib.rb/')
      echo "ARROW_GLIB_FORMULA=${ARROW_GLIB_FORMULA}" >> ${GITHUB_ENV}
      for formula in ${ARROW_FORMULA} ${ARROW_GLIB_FORMULA}; do
        if [ ! -f ${formula} ]; then
          continue
        fi
        # Pin the current commit in the formula to test so that
        # we're not always pulling from the tip of the default branch
        sed -i '' -E \
          -e 's@https://github.com/apache/arrow.git", branch: "main"$@{{ arrow.remote }}.git", revision: "{{ arrow.head }}"@' \
          ${formula}
        # Sometimes crossbow gives a remote URL with .git and sometimes not.
        # Make sure there's only one
        sed -i '' -E -e 's@.git.git@.git@' ${formula}
        cat ${formula}
        cp ${formula} $(brew --repository homebrew/core)/Formula/
      done
{% endmacro %}

{%- macro github_change_r_pkg_version(is_fork, version) -%}
  - name: Modify version
    shell: bash
    run: |
      cd arrow/r
      sed -i.bak -E -e \
        's/(^Version: )([0-9]+\.[0-9]+\.[0-9]+).*$/\1{{ version }}/' \
        DESCRIPTION
      head DESCRIPTION
      rm -f DESCRIPTION.bak
{% endmacro %}

{%- macro github_test_r_src_pkg() -%}
  source("https://raw.githubusercontent.com/apache/arrow/HEAD/ci/etc/rprofile")

  # always remove arrow (mainly for self-hosted runners)
  try(remove.packages("arrow"), silent = TRUE)

  install.packages(
    "arrow",
    repos = c(getOption("arrow.dev_repo"), getOption("repos")),
    verbose = TRUE,
    type = "source",
    INSTALL_opts = "--build"
  )

  library(arrow)
  read_parquet(system.file("v0.7.1.parquet", package = "arrow"))
  print(arrow_info())

  # Our Version should always be > CRAN so we would detect a CRAN version here.
  stopifnot(packageVersion("arrow") == {{ '"${{needs.source.outputs.pkg_version}}"' }})
{% endmacro %}

{%- macro github_setup_local_r_repo(get_nix, get_win, get_mac=False) -%}
# TODO: improve arg handling
  - name: Setup local repo
    shell: bash
    run: mkdir repo
  {% if get_win %}
  - name: Get windows binary
    uses: actions/download-artifact@v4
    with:
      name: r-libarrow-windows-x86_64
      path: repo/libarrow
  {% endif %}
  {% if get_nix %}
  - name: Get Linux binary
    uses: actions/download-artifact@v4
    with:
      name: r-libarrow-linux-x86_64
      path: repo/libarrow
  {% endif %}
  {% if get_mac %}
    {% for arch in ["x86_64", "arm64"] %}
  - name: Get macOS {{ arch }} binary
    uses: actions/download-artifact@v4
    with:
      name: r-libarrow-darwin-{{ arch }}
      path: repo/libarrow
    {% endfor %}
  {% endif %}
  - name: Get src pkg
    uses: actions/download-artifact@v4
    with:
      name: r-pkg__src__contrib
      path: repo/src/contrib
  - name: Update repo index
    shell: Rscript {0}
    run: |
      # getwd() is necessary as this macro is used within jobs using a docker container
      tools::write_PACKAGES(file.path(getwd(), "repo/src/contrib", fsep = "/"), type = "source", verbose = TRUE)
  - name: Show repo
    shell: bash
    # tree not available in git-bash on windows
    run: |
      ls -R repo
  - name: Add repos to .Rprofile
    shell: Rscript {0}
    run: |
      profile_path <- file.path(getwd(), ".Rprofile")
      repo <- paste0("file://", getwd(), "/repo")
      str <- paste0("options(arrow.repo = '", repo, "/libarrow/' )")
      print(str)
      write(str, file = profile_path, append = TRUE)
      str <- paste0("options(arrow.dev_repo = '", repo, "' )")
      print(str)
      write(str, file = profile_path, append = TRUE)
      # Set envvar for later steps by appending to $GITHUB_ENV
      write(paste0("R_PROFILE_USER=", profile_path), file = Sys.getenv("GITHUB_ENV"), append = TRUE)
{% endmacro %}

{# Detect if we are using a fork or the upstream repo #}
  {% set is_upstream_b = arrow.github_repo == 'apache/arrow' %}
  {# use filter to cast to string and convert to lowercase to match yaml boolean #}
  {% set is_fork = (not is_upstream_b)|lower %}

{% set r_release = {"ver": "4.2", "rt" : "42"} %}
{% set r_oldrel = {"ver": "4.1", "rt" : "40"} %}

{%- macro github_set_env(env) -%}
  {% if env is defined %}
    env:
    {% for key, value in env.items() %}
      {{ key }}: "{{ value }}"
    {% endfor %}
  {% endif %}
{%- endmacro -%}

{% macro github_set_sccache_envvars(sccache_key_prefix = "sccache") %}
  {% set sccache_vars =  {
            "AWS_ACCESS_KEY_ID": '${{ secrets.AWS_ACCESS_KEY_ID }}',
            "AWS_SECRET_ACCESS_KEY": '${{ secrets.AWS_SECRET_ACCESS_KEY }}',
            "SCCACHE_BUCKET": '${{ secrets.SCCACHE_BUCKET }}',
            "SCCACHE_REGION": '${{ secrets.SCCACHE_REGION }}',
            "SCCACHE_S3_KEY_PREFIX": sccache_key_prefix
          }
 %}
  {% for key, value in sccache_vars.items() %}
  {{ key }}: "{{ value }}"
  {% endfor %}
{% endmacro %}