-
Notifications
You must be signed in to change notification settings - Fork 36
169 lines (143 loc) · 5.65 KB
/
release.yaml
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
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
tags:
- "**" # Push events to every tag including hierarchical tags like v1.0/beta
pull_request:
branches:
- main
paths:
- .github/workflows/release.yaml
workflow_dispatch:
name: Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RPOLARS_FULL_FEATURES: "true"
RPOLARS_CARGO_CLEAN_DEPS: "true"
RPOLARS_PROFILE: release-optimized
jobs:
build:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - ${{ matrix.config.target }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release', rtools-version: ""}
- {os: ubuntu-latest, r: 'release'}
- {os: macos-latest, r: 'release', target: 'x86_64-apple-darwin'}
- {os: macos-latest, r: 'release', target: 'aarch64-apple-darwin'}
- {os: ubuntu-latest, r: 'release', target: 'x86_64-unknown-linux-gnu'}
- {os: ubuntu-latest, r: 'release', target: 'aarch64-unknown-linux-gnu'}
env:
RUNNER_TARGET: "${{ matrix.config.target }}"
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
with:
rust-nightly: true
target: ${{ matrix.config.target }}
- name: Set for arm64 Linux
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >>"$GITHUB_ENV"
- name: Set build command
if: matrix.config.target != ''
run: echo "RPOLARS_BUILD_COMMAND_BASE=cargo build --target=${{ env.RUNNER_TARGET }}" >>"$GITHUB_ENV"
- name: Fix path for Windows caching
if: runner.os == 'Windows'
shell: bash
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
rtools-version: ${{ matrix.config.rtools-version }}
Ncpus: 2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: dev
pak-version: devel
env:
CI: false
- name: find polars rust source/cache, used by Makevars in check step
id: get_the_rust_sauce
shell: bash
run: |
echo "RPOLARS_RUST_SOURCE=${PWD}/src/rust" >> $GITHUB_ENV
- name: make binary R package + test on host arch
if: matrix.config.target == ''
run: |
devtools::install(quick = TRUE)
devtools::test(stop_on_failure = TRUE)
fn = devtools::build(binary = TRUE, args = c('--preclean'))
if (R.version$os != "mingw32") {
newfn = paste0(substr(fn,1,regexpr("_",fn)),"_",R.version$platform,".",tools::file_ext(fn))
file.rename(fn,newfn)
} else {
file.rename(fn,"../polars.zip") #R expects specific windows binary filename
}
shell: Rscript {0}
- name: cross compile rust object files for another target arch
if: matrix.config.target != ''
run: |
pushd src
make -f Makevars "./rust/target/${{ env.RPOLARS_PROFILE }}/libr_polars.a"
popd
mv "./src/rust/target/${{ env.RUNNER_TARGET }}/${{ env.RPOLARS_PROFILE }}/libr_polars.a" ./inst/
ls -l
ls -l ./inst/
shell: bash
- name: make source R package with pre-cross-compiled rust binaries for another target arch
if: matrix.config.target != ''
run: |
runner_target = Sys.getenv("RUNNER_TARGET")
fn = devtools::build(vignettes = FALSE)
newfn = paste0(substr(fn,1,regexpr("_",fn)),"cross_",runner_target,".tar.gz")
file.rename(fn, newfn)
writeLines(basename(newfn),"polars_source_package_name.txt") #save for unit testing
list.files()
shell: Rscript {0}
- name: prep upload
run: |
mv ../polars* ./
- name: Upload produced R packages
uses: actions/upload-artifact@v3
with:
path: |
polars_*
polars.zip
- name: Upload produced R packages (source or binary) to release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request'
with:
files: |
polars_*
polars.zip
- name: unittest cross compilation, when host == target == 'x86_64-apple-darwin'
if: matrix.config.target == 'x86_64-apple-darwin' || matrix.config.target == 'x86_64-unknown-linux-gnu'
run: |
list.files()
polars_source_package_name = readLines("polars_source_package_name.txt")
install.packages(polars_source_package_name, repos = NULL, source = TRUE)
attach(getNamespace("polars")) # testthat assumes private namespace is in scope
testthat::test_dir("tests/testthat/")
shell: Rscript {0}
- name: print files
run: print(list.files("..",recursive = TRUE,full.names=TRUE))
shell: Rscript {0}
- name: print wd
run: print(getwd())
shell: Rscript {0}