-
Notifications
You must be signed in to change notification settings - Fork 354
135 lines (127 loc) · 4.42 KB
/
build.yml
File metadata and controls
135 lines (127 loc) · 4.42 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
name: build and test
on:
pull_request:
push:
release:
types:
- released
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
cmake:
strategy:
matrix:
runs-on:
- ubuntu-22.04
- ubuntu-latest
# `large` is x86-64 and `xlarge` is AArch64.
# https://docs.github.com/en/actions/reference/runners/larger-runners#available-macos-larger-runners-and-labels
- macos-14-large
- macos-14-xlarge
- macos-latest-large
# macos-latest-xlarge may timeout.
# https://github.com/google/s2geometry/issues/409
- macos-latest-xlarge
fail-fast: false
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set NUM_CORES
run: |
NUM_CORES=$(getconf _NPROCESSORS_ONLN)
echo "NUM_CORES=$NUM_CORES" >> $GITHUB_ENV
echo "Detected $NUM_CORES cores"
- name: Setup ccache
uses: hendrikmuhs/ccache-action@33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
with:
key: ${{ github.job }}-${{ matrix.runs-on }}
- run: mkdir build
- run: >
cmake
-DWITH_PYTHON=OFF
-DFETCH_ABSEIL=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
..
working-directory: build/
- run: cmake --build . --parallel ${{ env.NUM_CORES }}
working-directory: build/
- if: always()
run: ctest --parallel ${{ env.NUM_CORES }} --output-on-failure
working-directory: build/
bazel:
runs-on: ubuntu-latest
# We would like to test on the oldest and newest supported.
# https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md
# https://bazel.build/release#support-matrix
# It's not clear how to do that since bazelisk has some magic to pick a
# bazel version.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Bazel ${{ matrix.bazel }}
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # v0.19.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- name: Build and Test
run: |
bazel test \
--keep_going \
--test_verbose_timeout_warnings --test_output=errors \
//...
working-directory: src
python:
strategy:
matrix:
runs-on:
- ubuntu-latest
- macos-15-intel
- macos-latest
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-tags: true
persist-credentials: false
- uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
with:
package-dir: ./
output-dir: dist/
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: dist-${{ runner.os }}-${{ runner.arch }}
path: ./dist/
python-publish:
if: (github.event_name == 'release') && (github.event.action == 'released')
needs: [python]
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
# Requires environment protection rules in GitHub Settings:
# Settings > Environments > pypi > Add required reviewers
environment:
name: pypi
url: https://pypi.org/p/s2geometry
steps:
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: dist*
path: dist/
merge-multiple: true
- uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
with:
subject-path: "dist/*"
# To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0