-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (63 loc) · 2.72 KB
/
pre-merge-checks.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
name: Run pre-merge checks
on:
push:
branches:
- "main"
pull_request:
branches:
- "**"
jobs:
run-tests:
name: Run pre-merge checks
runs-on: ubuntu-20.04
env:
GOOGLE_APPLICATION_CREDENTIALS: service_account_credentials.json
steps:
- name: Checkout reboot-dev/pyprotoc-plugin
uses: actions/checkout@v2
with:
# We don't need special credentials since this is a public repo
# that only depends on other public repos.
submodules: recursive
- name: Install Python 3.10 and set it as the default
# To set Python 3.10 as the default we use `update-alternatives`:
# https://linux.die.net/man/8/update-alternatives
# We must set `python3` in addition to `python` because Bazel knows and cares
# about whether it's using python2 or python3, and will enforce its desire by
# explicitly running the `python2` or `python3` command.
run: |
sudo apt-get update \
&& DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
curl gpg gpg-agent software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa \
&& sudo apt-get update \
&& DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
python3.10 \
python3.10-dev \
python3.10-venv
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
python --version
python3 --version
- name: Set up read+write remote cache credentials (when on main)
# With the exception of GITHUB_TOKEN, secrets are not passed to the runner
# when a workflow is triggered from a forked repository. We can therefore
# only safely assume `GCP_REMOTE_CACHE_CREDENTIALS` to exist once the PR
# has been merged to `main`.
if: github.ref == 'refs/heads/main'
uses: jsdaniell/[email protected]
with:
name: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
json: ${{ secrets.GCP_REMOTE_CACHE_CREDENTIALS }}
- name: Set up read+write remote cache (when on main)
# Ditto to the reasoning of the step above, we will only use the cache in
# read-write mode if we're on `main`.
if: github.ref == 'refs/heads/main'
run: |
echo "BAZEL_REMOTE_CACHE=--remote_upload_local_results=true \
--google_credentials=${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" \
>> $GITHUB_ENV
- name: Run tests
run: |
bazel test //... \
${{ env.BAZEL_REMOTE_CACHE }}