-
Notifications
You must be signed in to change notification settings - Fork 56
156 lines (138 loc) · 4.96 KB
/
main.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
153
# 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: Build and run tests
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "master", "develop", "beta" ]
# Allow running manually from Actions tab
workflow_dispatch:
env:
SKIP_DEAP: 1
NOSE_VERBOSE: 2
NOSE_WITH_TIMER: 1
NOSE_WITH_ID: 1
NOSE_REDNOSE: 1
NOSE_WITH_COVERAGE: 1
NOSE_COVER_PACKAGE: "pygsti"
NOSE_PROCESSES: -1
NOSE_NOPATH: 1 # use installed package, not source tree under CWD
NOSE_PROCESS_TIMEOUT: 2400
NOSE_WHERE: "test/unit/"
jobs:
build: # Main build + unit test check
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up installation environment
run: |
./.github/ci-scripts/before_install.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install package
run: |
python -m pip install --upgrade pip
# see https://github.com/cvxgrp/cvxpy/issues/968 for numpy version
python -m pip install "numpy>=1.16.0"
# Cython must be pre-installed to build native extensions on pyGSTi install
python -m pip install cython
python -m pip install wheel flake8
python -m pip install .[testing]
python -m pip freeze
- name: Lint with flake8
run: |
# Critical errors, exit on failure
flake8 . --count --show-source --statistics --config=.flake8-critical
# Standard PEP8, allowed to fail since exit-zero treats all errors as warnings
flake8 . --exit-zero --statistics
- name: Run unit tests
run: |
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
echo "nosetests: $NOSETESTS"
nosetests $NOSETESTS
push: # Push to stable "beta" branch on successful build
runs-on: ubuntu-18.04
# Only run on "develop" branch if tests pass
needs: build
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Merge changes to beta branch
env:
TRIGGER_REF: refs/heads/develop
MERGE_BRANCH: beta
run: |
./.github/ci-scripts/merge.sh
- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with:
branch: 'refs/heads/beta'
github_token: ${{ secrets.PYGSTI_TOKEN }}
test_extras: # On stable branches, run extended tests
runs-on: ubuntu-18.04
strategy:
fail-fast: false # Finish all tests even if one fails
matrix:
python-version: [3.6, 3.7, 3.8]
nose-tests:
- "algorithms algorithmsb"
- "report reportb"
- "drivers objects tools iotest optimize construction extras"
# - "mpi" # Fails in GitHub Actions, passes locally but doesn't terminate threads properly
# Only run on "beta" or "master" branch if tests pass
needs: build
if: github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master'
env:
NOSE_NOPATH: "" # Needs to be off for MPI
NOSE_WHERE: 'test/test_packages'
steps:
- uses: actions/checkout@v2
- name: Set up installation environment
run: |
./.github/ci-scripts/before_install.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install package
run: |
python -m pip install --upgrade pip
# see https://github.com/cvxgrp/cvxpy/issues/968 for numpy version
python -m pip install "numpy>=1.16.0"
# Cython must be pre-installed to build native extensions on pyGSTi install
python -m pip install cython
python -m pip install wheel
# Installing with -e to keep installation local (for NOSE_NOPATH)
# but still compile Cython extensions
python -m pip install -e .[testing]
python -m pip freeze
- name: Run test_packages ${{ matrix.nose-tests }}
env:
NOSETESTS: ${{ matrix.nose-tests }}
run: |
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
echo "nosetests: $NOSETESTS"
nosetests $NOSETESTS