1- # This is a basic workflow to help you get started with Actions
1+ name : linux
22
3- name : subsurface CI
4-
5- # Controls when the action will run.
3+ # Controls when the action will run.
64on :
75 # Triggers the workflow on push or pull request events but only for the master branch
86 push :
97 branches : [ main, mig_dev, main_candidate, t21-main ]
108 pull_request :
119 branches : [ main, t21-main ]
10+ release :
11+ types :
12+ - published
1213
1314 # Allows you to run this workflow manually from the Actions tab
1415 workflow_dispatch :
1516
1617# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1718jobs :
18- # This workflow contains a single job called "build"
1919 pytest :
20- runs-on : ubuntu-latest
21- env :
22- DISPLAY : ' :99.0'
23- PYVISTA_OFF_SCREEN : ' True'
24- ALLOW_PLOTTING : true
25- SHELLOPTS : ' errexit:pipefail'
26- # The type of runner that the job will run on
2720
28- steps :
29- - name : Set up Python
30- uses : actions/setup-python@v2
31- with :
32- python-version : ' 3.8'
33-
34- - uses : actions/checkout@v2
35- - name : Setup Headless Display
36- run : |
37- sudo apt-get install libgl1-mesa-glx
38- sudo apt-get install -y xvfb
39- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
40- sleep 3
41-
42- - name : Install dependencies
43- run : |
44- python -m pip install --upgrade pip
45- pip install -r requirements.txt
46- pip install -r optional_requirements.txt
47-
48- - name : Test with pytest
49- run : |
50- pip install pytest
51- pip install pytest-cov
52- pytest
53- docs :
54- runs-on : ubuntu-latest
21+ name : ${{ matrix.case.os }} py${{ matrix.case.python-version }} ${{ matrix.case.name }}
22+ runs-on : ${{ matrix.case.os }}-latest
23+
24+ strategy :
25+ fail-fast : false
26+ matrix :
27+ os : [ubuntu, ] # macos, windows] # Only Linux currently.
28+ case :
29+ - python-version : 3.8
30+ name : basic
31+ os : ubuntu
32+ # - python-version: 3.9
33+ # name: basic
34+ # os: ubuntu
35+
5536 env :
5637 DISPLAY : ' :99.0'
5738 PYVISTA_OFF_SCREEN : ' True'
5839 ALLOW_PLOTTING : true
5940 SHELLOPTS : ' errexit:pipefail'
41+ OS : ${{ matrix.case.os }}
42+ PYTHON : ${{ matrix.case.python-version }}
6043
6144 steps :
45+
46+ # Cancel any previous run of the test job; [pin v0.8.0 (2021-02-13)]
47+ - name : Cancel Previous Runs
48+ uses : styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d
49+ with :
50+ access_token : ${{ github.token }}
51+
52+ - name : Set up Python
53+ uses : actions/setup-python@v2
54+ with :
55+ python-version : ${{ matrix.case.python-version }}
56+
6257 - uses : actions/checkout@v2
6358 - name : Setup Headless Display
6459 run : |
@@ -67,24 +62,85 @@ jobs:
6762 Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
6863 sleep 3
6964
70- - name : Set up Python
65+ - name : Install dependencies
66+ run : |
67+ python -m pip install --upgrade pip
68+ pip install -r requirements_dev.txt
69+
70+ - name : Test with pytest
71+ run : pytest --cov=subsurface
72+
73+ # # # # DEPLOY # # #
74+ deploy :
75+ needs : pytest
76+ name : Deploy to PyPI
77+ runs-on : ubuntu-latest
78+ # Only from the origin repository, not forks; only main and tags.
79+ if : github.repository_owner == 'softwareunderground' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
80+
81+ steps :
82+ # Checks-out your repository under $GITHUB_WORKSPACE
83+ - name : Checkout
84+ uses : actions/checkout@v2
85+ with :
86+ # Need to fetch more than the last commit so that setuptools_scm can
87+ # create the correct version string. If the number of commits since
88+ # the last release is greater than this, the version will still be
89+ # wrong. Increase if necessary.
90+ fetch-depth : 100
91+ # The GitHub token is preserved by default but this job doesn't need
92+ # to be able to push to GitHub.
93+ persist-credentials : false
94+
95+ # Need the tags so that setuptools_scm can form a valid version number
96+ - name : Fetch git tags
97+ run : git fetch origin 'refs/tags/*:refs/tags/*'
98+
99+ - name : Setup Python
71100 uses : actions/setup-python@v2
72101 with :
73- python-version : ' 3.8'
102+ python-version : " 3.8"
103+
74104 - name : Install dependencies
75105 run : |
76106 python -m pip install --upgrade pip
107+ pip install wheel setuptools_scm
77108 pip install -r requirements.txt
78- pip install -r optional_requirements.txt
79- pip install -r dev_requirements.txt
80- pip install -e .
81- - name : Generate Sphinx Docs
82- working-directory : docs/
83- run : make html
84- - name : Publish generated content to GitHub Pages
85- uses :
tsunematsu21/[email protected] 109+
110+ - name : Build source and wheel distributions
111+ if : github.ref == 'refs/heads/main'
112+ run : |
113+ # Change setuptools-scm local_scheme to "no-local-version" so the
114+ # local part of the version isn't included, making the version string
115+ # compatible with Test PyPI.
116+ sed --in-place "s/'root'/'local_scheme':'no-local-version','root'/g" setup.py
117+
118+ - name : Build source and wheel distributions
119+ run : |
120+ # Build source and wheel packages
121+ python setup.py sdist
122+ python setup.py bdist_wheel
123+ echo ""
124+ echo "Generated files:"
125+ ls -lh dist/
126+
127+ - name : Publish to Test PyPI
128+ if : success()
129+ # Hash corresponds to v1.4.1
130+ uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806
86131 with :
87- dir : docs/build/html
88- branch : gh-pages
89- token : ${{ secrets.ACCESS_TOKEN }}
132+ user : __token__
133+ password : ${{ secrets.TEST_PYPI_PASSWORD }}
134+ repository_url : https://test.pypi.org/legacy/
135+ # Allow existing releases on test PyPI without errors.
136+ # NOT TO BE USED in PyPI!
137+ skip_existing : true
90138
139+ - name : Publish to PyPI
140+ # Only for releases
141+ if : success() && github.event_name == 'release'
142+ # Hash corresponds to v1.4.1
143+ uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806
144+ with :
145+ user : __token__
146+ password : ${{ secrets.PYPI_PASSWORD }}
0 commit comments