-
Notifications
You must be signed in to change notification settings - Fork 3
/
workflow-template-latest.yml
114 lines (93 loc) · 3.47 KB
/
workflow-template-latest.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
# Workflow template for testing plugins against PennyLane latest
name: {{ plugin }}-{% if latest %}latest{% else %}stable{% endif %}-latest
on:
push:
branches:
- master
pull_request:
schedule:
- cron: '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
{%- if token is defined %}
{{ token }}: {% raw %}${{ secrets.{% endraw %}{{ token }}{% raw %} }}{% endraw %}
{%- endif %}
{%- if additional_env_vars is defined %}
{{ additional_env_vars }}
{%- endif %}
jobs:
tests:
runs-on: {% if runs_on is defined %}{{ runs_on }}{% else %}ubuntu-latest{% endif %}
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.10"
{%- 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 %}
{%- if requirements_latest is defined %}
{%- for req in requirements_latest %}
pip install --upgrade {{ req }}
{%- endfor %}
{%- endif %}
pip install 'pytest<8.1.0'
pip install pytest-mock pytest-cov flaky pytest-benchmark
pip freeze
{%- if latest %}
- name: Install PennyLane and Plugin
run: |
{% raw -%}
pip install git+https://github.com/PennyLaneAI/pennylane.git \
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 git+https://github.com/PennyLaneAI/pennylane.git \
${{ env.PLUGIN_PACKAGE }} --upgrade
{%- endraw %}
- 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 "version=$PLUGIN_VERSION" >> $GITHUB_OUTPUT
{%- 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 -%}
- name: Run PennyLane device integration tests
run: |
{%- for test in device_tests %}
pl-device-test {{ test }}
{%- endfor %}
- name: Run plugin tests
run: |
python -m pytest plugin_repo/{{ tests_loc }} --tb=short {%- for kwarg in test_kwargs %} {{ kwarg }}{%- endfor %}{% if no_deprecation_error %}{% else %} \
-W "error::pennylane.PennyLaneDeprecationWarning"{% endif %}