-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (107 loc) · 4.22 KB
/
ci.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
# This workflow will do a clean install of Node dependencies and execute all
# Bazel tests. This implicitly builds all required targets. Any target that is
# not tested but should verify its build should use a build test.
# https://github.com/bazelbuild/bazel-skylib/blob/master/rules/build_test.bzl
name: CI
on:
push:
branches:
# Run CI for direct pushes to `main`. I probably shouldn't do that in
# general, but for a core team of 1, PRs are a waste of effort.
- main
# Run CI for the `ci` branch. This branch isn't special in any way, it
# just does not enforce linear history, so edits to the CI workflow can be
# tested there where commits can still be amended before they are
# immutably pushed to main.
- ci
pull_request:
branches: [ main ]
jobs:
test:
# Includes `bazelisk`.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#:~:text=Bazel%204.2.1-,Bazelisk,-1.10.1
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Cache Bazel
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Get pnpm store directory
id: pnpm-cache-dir
run: |
echo "PNPM_STORE_PATH=$(bazel run @pnpm --config ci -- store path --silent)" >> "${GITHUB_OUTPUT}"
- name: Cache pnpm
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install
run: bazel run @pnpm --config ci -- install --dir $PWD --frozen-lockfile
# Build and test the entire repository.
- name: Test
run: |
# Run `bazel test //...` over all workspaces in the repository.
find . -name WORKSPACE.bazel -printf "%h\n" |
sort |
xargs -I {} bash -c "(cd {} && bazel test //... --config ci)"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: bazel.profile.gz
path: bazel.profile.gz
docs-deploy:
# Includes `bazelisk`.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#:~:text=Bazel%204.2.1-,Bazelisk,-1.10.1
runs-on: ubuntu-20.04
# Only deploy after a successful test run.
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Cache Bazel
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Get pnpm store directory
id: pnpm-cache-dir
run: |
echo "PNPM_STORE_PATH=$(bazel run @pnpm --config ci -- store path --silent)" >> "${GITHUB_OUTPUT}"
- name: Cache pnpm
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install
run: bazel run @pnpm --config ci -- install --dir $PWD --frozen-lockfile
- name: Deploy to preview
# Only publish non-`main` branch for preview.
if: ${{ github.ref_name != 'main' }}
run: |
bazel run //docs:deploy --config ci -- \
--alias ${{ github.ref_name }} \
-m "Automated preview deployment from GitHub actions."
env:
NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PAT }}
- name: Deploy to Prod
# Only publish the `main` branch to prod.
if: ${{ github.ref_name == 'main' }}
run: |
bazel run //docs:deploy --config ci -- \
--prod \
-m "Automated prod deployment from GitHub actions."
env:
NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PAT }}