-
Notifications
You must be signed in to change notification settings - Fork 94
130 lines (115 loc) · 4 KB
/
pr-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
name: Pull Request CI
on:
pull_request:
branches:
- "main"
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
- CITATION
- AUTHORS
- docs/**
- .readthedocs.yml
- .pre-commit-config.yaml
- mkdocs.yml
defaults:
run:
shell: bash -l {0}
concurrency:
# Use github.run_id on main branch
# Use github.event.pull_request.number on pull requests, so it's unique per pull request
# Use github.ref on other branches, so it's unique per branch
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
if: github.event.pull_request.draft == false
strategy:
matrix:
os: [ubuntu-latest]
py3version: ["10", "11", "12"]
include:
- os: windows-latest
py3version: "12"
- os: macos-latest
py3version: "12"
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.10-0'
environment-name: ${{ github.event.repository.name }}-${{ matrix.os }}-3${{ matrix.py3version }}-${{ hashFiles('requirements/dev.txt') }}
environment-file: requirements/base.txt
create-args: >-
-f requirements/dev.txt
curl
python=3.${{ matrix.py3version }}
gurobi::gurobi
post-cleanup: all
cache-environment: true
- name: Install package
run: pip install --no-dependencies -e .
- name: install CBC (Windows)
if: matrix.os == 'windows-latest'
run: |
curl -L https://github.com/coin-or/Cbc/releases/download/releases%2F2.10.10/Cbc-releases.2.10.10-w64-msvc17-md.zip -o cbc.zip
unzip cbc.zip -d ${HOME}/cbc
echo "${HOME}/cbc/bin" >> $GITHUB_PATH
- name: install CBC (Unix)
if: matrix.os != 'windows-latest'
run: micromamba install coin-or-cbc
- name: Install jupyter kernel
run: python -m ipykernel install --user --name calliope
- name: run tests with coverage
if: matrix.os == 'ubuntu-latest' && matrix.py3version == '12'
run: pytest --cov
- name: run tests without coverage
if: matrix.os != 'ubuntu-latest' || matrix.py3version != '12'
run: pytest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.py3version == '12'
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
directory: "./reports/coverage/"
verbose: true
pre-release-version:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.title, 'Release v')
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- id: get-version
run: |
fullname="${{github.event.pull_request.title}}"
echo "version=${fullname#"Release "}" >> $GITHUB_OUTPUT
pip-test:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.title, 'Release v')
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.10-0'
environment-file: .github/workflows/pr-ci-pipbuild-environment.yml
post-cleanup: all
cache-environment: true
- name: Build package
run: python -m build
- name: Test package install
run: |
pip install dist/calliope-*.tar.gz
calliope --help
pre-release:
needs: [test, pre-release-version, pip-test]
if: needs.pip-test.result == 'success' && needs.test.result == 'success' && startsWith(github.event.pull_request.title, 'Release v')
uses: arup-group/actions-city-modelling-lab/.github/workflows/pip-build.yml@main
secrets:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
with:
package_name: calliope
version: ${{needs.pre-release-version.outputs.version}}