File tree Expand file tree Collapse file tree 2 files changed +155
-0
lines changed Expand file tree Collapse file tree 2 files changed +155
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Python virtualenv
2
+ description : Set up a Python virtual environment with caching
3
+ inputs :
4
+ python-version :
5
+ description : The Python version to use
6
+ required : true
7
+ cache-prefix :
8
+ description : Update this to invalidate the cache
9
+ required : true
10
+ default : v0
11
+ torch-version :
12
+ description : The PyTorch version to install
13
+ required : false
14
+ default : ' ==2.2.1'
15
+ runs :
16
+ using : composite
17
+ steps :
18
+ - name : Setup Python
19
+ uses : actions/setup-python@v4
20
+ with :
21
+ python-version : ${{ inputs.python-version }}
22
+
23
+ - shell : bash
24
+ run : |
25
+ # Install prerequisites.
26
+ pip install --upgrade pip setuptools build wheel virtualenv
27
+
28
+ - shell : bash
29
+ run : |
30
+ # Get the exact Python version to use in the cache key.
31
+ echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV
32
+
33
+ - uses : actions/cache@v2
34
+ id : virtualenv-cache
35
+ with :
36
+ path : .venv
37
+ key : ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('*requirements.txt', '*pyproject.toml') }}
38
+
39
+ - if : steps.virtualenv-cache.outputs.cache-hit != 'true'
40
+ shell : bash
41
+ run : |
42
+ # Set up virtual environment without cache hit.
43
+ test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
44
+ . .venv/bin/activate
45
+ pip install 'torch${{ inputs.torch-version }}' --extra-index-url https://download.pytorch.org/whl/cpu
46
+ pip install -e .[all]
47
+
48
+ - if : steps.virtualenv-cache.outputs.cache-hit == 'true'
49
+ shell : bash
50
+ run : |
51
+ # Set up virtual environment from cache hit.
52
+ . .venv/bin/activate
53
+ pip install --no-deps -e .[all]
54
+
55
+ - shell : bash
56
+ run : |
57
+ # Show environment info.
58
+ . .venv/bin/activate
59
+ echo "✓ Installed $(python --version) virtual environment to $(which python)"
60
+ echo "========= Python packages ==========="
61
+ pip freeze
Original file line number Diff line number Diff line change
1
+ name : Main
2
+
3
+ concurrency :
4
+ group : ${{ github.workflow }}-${{ github.ref }}
5
+
6
+ on :
7
+ pull_request :
8
+ branches :
9
+ - main
10
+ push :
11
+ branches :
12
+ - main
13
+ tags :
14
+ - ' v*.*.*'
15
+
16
+ env :
17
+ # Change this to invalidate existing cache.
18
+ CACHE_PREFIX : v0
19
+ PYTHONPATH : ./src/
20
+
21
+ jobs :
22
+ checks :
23
+ name : ${{ matrix.task.name }} (py ${{ matrix.python }})
24
+ runs-on : [ubuntu-latest]
25
+ timeout-minutes : 10
26
+ strategy :
27
+ fail-fast : false
28
+ matrix :
29
+ python : ['3.8', '3.10']
30
+ task :
31
+ - name : Lint
32
+ run : |
33
+ make lint
34
+
35
+ include :
36
+ - python : ' 3.10'
37
+ task :
38
+ name : Test
39
+ run : pytest -v --color=yes --durations=5 src/test/
40
+
41
+ - python : ' 3.10'
42
+ task :
43
+ name : Type check
44
+ run : |
45
+ make type-check
46
+
47
+ - python : ' 3.10'
48
+ task :
49
+ name : Build
50
+ run : |
51
+ make build
52
+
53
+ - python : ' 3.10'
54
+ task :
55
+ name : Style
56
+ run : |
57
+ make style-check
58
+
59
+ steps :
60
+ - uses : actions/checkout@v3
61
+
62
+ - name : Setup Python environment
63
+ uses : ./.github/actions/setup-venv
64
+ with :
65
+ python-version : ${{ matrix.python }}
66
+ cache-prefix : ${{ env.CACHE_PREFIX }}
67
+
68
+ - name : Restore mypy cache
69
+ if : matrix.task.name == 'Type check'
70
+ uses : actions/cache@v3
71
+ with :
72
+ path : .mypy_cache
73
+ key : mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-${{ github.ref }}-${{ github.sha }}
74
+ restore-keys : |
75
+ mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-${{ github.ref }}
76
+ mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
77
+
78
+ - name : ${{ matrix.task.name }}
79
+ run : |
80
+ . .venv/bin/activate
81
+ ${{ matrix.task.run }}
82
+
83
+ - name : Upload package distribution files
84
+ if : matrix.task.name == 'Build'
85
+ uses : actions/upload-artifact@v3
86
+ with :
87
+ name : package
88
+ path : dist
89
+
90
+ - name : Clean up
91
+ if : always()
92
+ run : |
93
+ . .venv/bin/activate
94
+ pip uninstall -y ai2-olmo-core
You can’t perform that action at this time.
0 commit comments