-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (124 loc) · 4.34 KB
/
ci.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
name: PyRS CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- next
tags:
- v*
schedule: # daily cron job at UTC+6 == EST+1 on default branch
- cron: '0 6 * * *'
env:
TRIGGER_URL: "https://code.ornl.gov/api/v4/projects/6012/trigger/pipeline"
jobs:
ci:
runs-on: ubuntu-latest
timeout-minutes: 600
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Apt install deps
run: |
sudo apt update
sudo apt-get install xvfb freeglut3-dev libglu1-mesa
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
- name: Setup libmamba solver
run: |
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
conda install boa -c conda-forge
- name: Install requirements
run: |
# --quiet should turn off progress bars to make logs more readable
conda env create --file environment.yml --quiet
- name: Lint
run: |
conda activate PyRS
flake8 . --count
- name: mypy
run: |
conda activate PyRS
mypy pyrs scripts tests
- name: Mantid pre-requisites - create a properties file that turns off network access
run: |
conda activate PyRS
mkdir ~/.mantid
echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
- name: Test mantid/workbench
run: |
conda activate PyRS
python -c "import mantid"
python -c "import qtpy"
python -c "import mantidqt"
- name: Print Conda Packages
run: |
conda activate PyRS
conda list
- name: Run PyRS tests
run: |
conda activate PyRS
xvfb-run --server-args="-screen 0 640x480x24" -a pytest --cov=pyrs --cov-report=xml --cov-report=term tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
- name: Build python wheel # cannot be used without mantid
run: |
conda activate PyRS
python setup.py bdist_wheel
check-wheel-contents dist/pyrs-*.whl
- name: Build conda package
# Build in all cases, for testing purposes
run: |
conda activate PyRS
cd conda.recipe
conda-mambabuild --output-folder . . -c conda-forge -c mantid
conda-verify noarch/pyrs-*py*.tar.bz2
- name: Publish to Anaconda
shell: bash -l {0}
# Publish only for version tags (tag name starts with "v")
if: startsWith(github.ref, 'refs/tags/v')
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
# IS_RC: "true" for release-candidate tags, e.g. "v1.0.0-rc1"
IS_RC: ${{ contains(github.ref, 'rc') }}
run: |
conda activate PyRS
conda install -y anaconda-client
CONDA_LABEL="main"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo "pushing ${{ github.ref }} with label ${CONDA_LABEL}"
anaconda upload --label ${CONDA_LABEL} conda.recipe/noarch/pyrs-*.tar.bz2
trigger-deploy:
runs-on: ubuntu-22.04
needs: [ci]
# Deploys from branch next (except when running the nightly cron), or from a version tag
if: |
startsWith(github.ref, 'refs/tags/v') ||
(github.ref == 'refs/heads/next' && github.event_name != 'schedule')
steps:
- name: Determine Environment
uses: neutrons/branch-mapper@v2
id: conda_env_name
with:
prefix: pyrs
- name: Trigger deploy
id: trigger
uses: eic/trigger-gitlab-ci@v2
with:
url: https://code.ornl.gov
token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
project_id: 11849
variables: |
PLAY="update"
CONDA_ENV="${{ steps.conda_env_name.outputs.name }}"
- name: Annotate commit
uses: peter-evans/commit-comment@v2
with:
body: |
GitLab pipeline for ${{ steps.conda_env_name.outputs.name }} has been submitted for this commit: ${{ steps.trigger.outputs.web_url }}