-
-
Notifications
You must be signed in to change notification settings - Fork 34
194 lines (180 loc) · 6.38 KB
/
buildandtest.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
name: 'Build & Test'
on:
push:
branches:
- main
- release/**
pull_request:
env:
CACHED_DEPENDENCY_PATHS: |
${{ github.workspace }}/node_modules
CACHED_BUILD_PATHS: |
${{ github.workspace }}/dist
BUILD_CACHE_KEY: ${{ github.sha }}
jobs:
job_install_deps:
name: Install Dependencies
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ hashFiles('yarn.lock') }}" >> "$GITHUB_OUTPUT"
- name: Check dependency cache
uses: actions/[email protected]
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install
outputs:
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
job_build:
name: Build
needs: job_install_deps
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Check dependency cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/[email protected]
id: cache_built_packages
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Build packages
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
# packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
# where the built packages are beside the point. In that case, you can change `BUILD_CACHE_KEY` (at the top of
# this file) to a constant and skip rebuilding all of the packages each time CI runs.
if: steps.cache_built_packages.outputs.cache-hit != 'true'
run: yarn build
# yarn.lock cannot be dirty when releasing a new version.
- name: Check if yarn.lock is dirty
if: steps.cache_built_packages.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Publish package locally
run: |
yarn global add yalc
yalc publish
- name: Upload yalc package
uses: actions/upload-artifact@v4
with:
name: yalc-package
if-no-files-found: error
path: ~/.yalc/packages/@sentry/capacitor/ # Path to yalc directory where the package is published
outputs:
# this needs to be passed on, because the `needs` context only looks at direct ancestors (so steps which depend on
# `job_build` can't see `job_install_deps` and what it returned)
dependency_cache_key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
job_sample_test:
name: Sample Build Test
needs: job_build
# macos required for the xcode build.
runs-on: macos-latest
strategy:
matrix:
include:
- bump: 'v3'
- bump: 'v4'
- bump: 'v5'
- bump: 'v6'
- bump: 'sample-vue'
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Check dependency cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Install yalc
run: yarn global add yalc
- name: Install Ionic
run: yarn global add @ionic/cli
- name: Download Sentry Capacitor package
uses: actions/download-artifact@v4
with:
name: yalc-package
path: ~/.yalc/packages/@sentry/capacitor/ # Ensure this path matches where yalc expects to find the package
- name: Publish test broken node.
working-directory: example/broken_node_module
run: |
yarn install
yarn build
yalc publish
- name: Build Sample ${{ matrix.bump }}
run: yarn run bump:${{ matrix.bump }}
job_unit_test:
name: Test
needs: job_build
continue-on-error: true
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Check dependency cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Run tests
run: yarn test
job_artifacts:
name: Upload Artifacts
needs: job_build
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Check dependency cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/[email protected]
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Pack
run: yarn pack
- name: Archive artifacts
uses: actions/[email protected]
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/sentry-capacitor-*