-
-
Notifications
You must be signed in to change notification settings - Fork 43
152 lines (135 loc) · 4.86 KB
/
python-package.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
tags:
- v*
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.12"]
include:
- os: ubuntu-latest
pippath: ~/.cache/pip
- os: macos-latest
pippath: ~/Library/Caches/pip
- os: windows-latest
pippath: ~\AppData\Local\pip\Cache
# include:
# - os: macos-latest
# python-version: "3.10"
steps:
- uses: actions/checkout@v4
# - name: Get MacTeX Version
# if: ${{ startsWith(matrix.os, 'macos') }}
# run: echo "TEX_VER=$(brew info mactex | grep -E -o '\d+\.\d+')" >> $GITHUB_ENV
# - name: MacTeX Cache
# if: ${{ startsWith(matrix.os, 'macos') }}
# uses: actions/[email protected]
# env:
# cache-name: cache-brew
# with:
# # A list of files, directories, and wildcard patterns to cache and restore
# path: |
# ~/Library/Caches/Homebrew
# ~/Library/Caches/Homebrew/Casks
# # An explicit key for restoring and saving the cache
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.TEX_VER }}
# # # An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.
# # restore-keys: # optional
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
with:
path: ${{ matrix.pippath }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Set up Homebrew
if: ${{ startsWith(matrix.os, 'macos') }}
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Setup TeX Live
uses: teatimeguest/setup-texlive-action@v3
with:
cache: true
packages: >-
scheme-basic
collection-xetex
collection-fontsrecommended
collection-mathscience
collection-pictures
collection-latexextra
repository: https://mirrors.tuna.tsinghua.edu.cn/tex-historic-archive/systems/texlive/2023/tlnet-final/
version: 2023
- name: windows denpendencies
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
choco install pandoc --version 3.1 --no-progress
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
- name: ubuntu dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install -y xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 curl
sudo apt-get install -y pandoc
- name: mac dependencies
if: ${{ startsWith(matrix.os, 'macos') }}
# fix pandoc version to 3.1.6 until https://github.com/jupyter/nbconvert/issues/2164 fixed
run: |
brew update
brew install pandoc
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install pytest pytest-asyncio matplotlib selenium jupyter pandoc playwright
pip install . --upgrade
- name: mac nbconvert patch fix # this is a tmp fix, related to https://github.com/jupyter/nbconvert/issues/1773
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
mkdir -p ~/Library/Jupyter
ln -s /opt/homebrew/share/jupyter/nbconvert ~/Library/Jupyter
- name: Test with pytest
env:
DEBUG: "1"
run: |
# sed 's/:/\n/g' <<< "$PATH" # show path
pytest
# upload tmp.zip if fails
- name: upload failed notebook.tex
if: failure()
uses: actions/upload-artifact@v3
with:
path: notebook.tex
- name: Upload pdf
uses: actions/upload-artifact@v3
with:
name: test_output
path: tests/test_output
publish:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: build
run: |
pip install -U pip wheel build setuptools
python3 -m build --wheel
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}