/
action.yml
98 lines (96 loc) · 3.88 KB
/
action.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
name: "Setup Virtual Env"
description: Sets up virtualenv + React; compiles protobuf
inputs:
use_cached_venv:
description: "Use Cached Virtual Env"
default: "true"
# There is an altered copy of these steps inlined in the python_min_deps
# workflow. If you make changes to this action, apply them there too if appropriate.
runs:
using: composite
steps:
- name: Restore pre-commit cache
id: cache-pre-commit
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: v1-pre-commit-${{ env.pythonLocation }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Install pre-commit
run: |
pip install pre-commit
pre-commit install-hooks
shell: bash --login -eo pipefail {0}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
- name: Initialize React
run: |
# Create the cache directory if it does not exist.
mkdir -p $(yarn cache dir)
make react-init
shell: bash --login -eo pipefail {0}
- name: Install system dependencies
run: |
sudo apt update
# protobuf, dot, & graphviz dependencies
sudo apt install -y gnupg \
graphviz \
libgvc6 \
protobuf-compiler
shell: bash --login -eo pipefail {0}
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository. To work around this, we vendor in
# protoc 3.20.3.
# We can remove the vendored protoc binary and this run step once Github
# Actions moves to a newer version of Ubunutu.
- name: Add vendored `protoc` to $PATH
run: |
echo "./vendor/protoc-3.20.3-linux-x86_64/bin" >> $GITHUB_PATH
shell: bash --login -eo pipefail {0}
# Combine hashes of the Python interpreter, Pipfile, and today's
# date into a file whose hash will key the Python virtualenv.
#
# This means that our virtualenv cache will expire each day. We do
# this because we are not using a lockfile to pin dependencies -
# instead, each time Github Actions rebuilds the virtualenv, it uses the
# latest compatible version of each dependency (which mirrors what
# happens when a user installs Streamlit locally). So we expire our
# virtualenv cache daily to prevent it from getting far out of sync
# with what a fresh Streamlit installation would look like.
- if: inputs.use_cached_venv == 'true'
name: Create Python environment cache key
run: |
md5sum $(which python) > $GITHUB_WORKSPACE/python_cache_key.md5
md5sum lib/dev-requirements.txt >> $GITHUB_WORKSPACE/python_cache_key.md5
md5sum lib/test-requirements.txt >> $GITHUB_WORKSPACE/python_cache_key.md5
md5sum lib/setup.py >> $GITHUB_WORKSPACE/python_cache_key.md5
md5sum Makefile >> $GITHUB_WORKSPACE/python_cache_key.md5
date +%F >> $GITHUB_WORKSPACE/python_cache_key.md5
shell: bash --login -eo pipefail {0}
- if: inputs.use_cached_venv == 'true'
name: Restore virtualenv from cache
id: cache-virtualenv
uses: actions/cache@v3
with:
path: venv
key: v1-python-venv-${{ hashFiles('**/python_cache_key.md5') }}
- if: steps.cache-virtualenv.outputs.cache-hit != 'true'
name: Create Virtual Env
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install uv
make python-init
deactivate
shell: bash --login -eo pipefail {0}
- name: Activate virtualenv
run: echo 'source venv/bin/activate' >> $HOME/.bash_profile
shell: bash --login -eo pipefail {0}
- name: Generate Protobufs
run: make protobuf
shell: bash --login -eo pipefail {0}