forked from PennyLaneAI/plugin-test-matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow-template-stable.yml
103 lines (84 loc) · 3.09 KB
/
workflow-template-stable.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
# Workflow template for testing plugins against PennyLane stable
name: {{ plugin }}-{% if latest %}latest{% else %}stable{% endif %}-stable
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
env:
PLUGIN_REPO: {{ gh_user }}/{{ plugin_repo }}
PLUGIN_BRANCH: {% if branch %}{{ branch }}{% else %}master{% endif %}
PLUGIN_PACKAGE: {{ plugin_package }}
PENNYLANE_BRANCH: master
IBMQX_TOKEN: {% raw %}${{ secrets.IBMQX_TOKEN }}{% endraw %}
IONQ_API_KEY: {% raw %}${{ secrets.IONQ_API_KEY }}{% endraw %}
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: {% raw %}${{ github.token }}{% endraw %}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
{%- if additional_setup is defined %}
{{ additional_setup | indent(6, True) }}
{%- endif %}
- name: Install requirements
run: |
pip install --upgrade pip
{%- for req in requirements %}
pip install --upgrade {{ req }}
{%- endfor %}
pip install pytest pytest-mock pytest-cov flaky
pip freeze
{%- if latest %}
- name: Install PennyLane and Plugin
run: |
{% raw -%}
pip install pennylane git+https://github.com/${{ env.PLUGIN_REPO }}.git@${{ env.PLUGIN_BRANCH }}
{%- endraw %}
- uses: actions/checkout@v2
with:
repository: {% raw %}${{ env.PLUGIN_REPO }}{% endraw %}
path: plugin_repo
ref: {% raw %}${{ env.PLUGIN_BRANCH }}{% endraw %}
{% else %}
- name: Install PennyLane and Plugin
run: |
{% raw -%}
pip install pennylane ${{ env.PLUGIN_PACKAGE }} --upgrade
{%- endraw %}
pip freeze
- name: Get plugin version
id: plugin-version
run: |
{% raw -%}
PLUGIN_VERSION=$(python -c "import pkg_resources as pkg; print(pkg.get_distribution('${{ env.PLUGIN_PACKAGE }}').version)")
echo ::set-output name=version::$PLUGIN_VERSION
{%- endraw %}
- uses: actions/checkout@v2
with:
repository: {% raw %}${{ env.PLUGIN_REPO }}{% endraw %}
path: plugin_repo
ref: {% raw %}v${{ steps.plugin-version.outputs.version }}{% endraw %}
{% endif -%}
{% if device_tests -%}
- name: Run PennyLane device integration tests
run: |
if ! [ -x "$(command -v pl-device-test)" ]; then
echo 'Error: Version of PennyLane does not provide device integration tests.' >&2
else
{%- for test in device_tests %}
pl-device-test {{ test }}
{%- endfor %}
fi
{%- endif %}
- name: Run plugin tests
run: python -m pytest plugin_repo/{{ tests_loc }} --tb=short {%- for kwarg in test_kwargs %} {{ kwarg }} {%- endfor %}