-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (151 loc) · 5.36 KB
/
ci.yaml
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
154
155
156
157
158
159
160
name: ci
on:
# Trigger the workflow on push to master or develop, except tag creation
push:
branches:
- 'main'
- 'develop'
# Trigger the workflow on pull request
pull_request: ~
# Trigger the workflow manually
workflow_dispatch: ~
# Trigger after public PR approved for CI
pull_request_target:
types: [labeled]
release:
types: [created]
jobs:
downstream-ci:
name: downstream-ci
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
# FIXME: revert to main when ready
uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci.yml@feature/add-conflator
with:
conflator: ecmwf/conflator@${{ github.event.pull_request.head.sha || github.sha }}
python_qa: true
secrets: inherit
# qa:
# name: qa
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
# with:
# repository: ${{ inputs.repository }}
# ref: ${{ inputs.ref }}
# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ inputs.python_version }}
# - name: Install Python Dependencies
# run: |
# python -m pip install --upgrade pip
# python -m pip install black==23.1.0
# python -m pip install flake8 isort
# - name: Check isort
# run: isort --check .
# - name: Check black
# run: black --check .
# - name: Check flake8
# run: flake8 .
setup:
name: setup
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
inputs: ${{ steps.prepare-inputs.outputs.inputs }}
inputs-for-ubuntu: ${{ steps.prepare-inputs.outputs.inputs-for-ubuntu }}
steps:
- name: Set Matrix
id: set-matrix
shell: bash -eux {0}
run: |
MATRIX=$(cat << 'EOS'
name:
include:
- name: [email protected]
os: ubuntu-22.04
compiler: gnu-11
compiler_cc: gcc-11
compiler_cxx: g++-11
compiler_fc: gfortran-11
- name: [email protected]
os: ubuntu-22.04
compiler: clang-14
compiler_cc: clang-14
compiler_cxx: clang++-14
compiler_fc: gfortran-11
# Xcode compiler requires empty environment variables, so we pass null (~) here
EOS
)
SKIP_MATRIX_JOBS=$(cat << 'EOS'
${{ inputs.skip_matrix_jobs }}
EOS
)
SELECT_NAME_COND="1 != 1"
SELECT_INCLUDE_COND="1 != 1"
for skip_job in $SKIP_MATRIX_JOBS; do SELECT_NAME_COND="$SELECT_NAME_COND or . == \"$skip_job\""; SELECT_INCLUDE_COND="$SELECT_INCLUDE_COND or .name == \"$skip_job\""; done
echo matrix=$(echo "$MATRIX" | yq eval "del(.name[] | select($SELECT_NAME_COND)) | del(.include[] | select($SELECT_INCLUDE_COND))" --output-format json --indent 0 -) >> $GITHUB_OUTPUT
- name: Prepare build-package Inputs
id: prepare-inputs
shell: bash -eux {0}
run: |
echo inputs=$(echo "${{ inputs.build_package_inputs || '{}' }}" | yq eval '.' --output-format json --indent 0 -) >> $GITHUB_OUTPUT
echo inputs-for-ubuntu=$(echo "${{ inputs.build_package_inputs || '{}' }}" | yq eval '. * {"os":"ubuntu-20.04","compiler":"gnu-10","compiler_cc":"gcc-10","compiler_cxx":"g++-10","compiler_fc":"gfortran-10"}' --output-format json --indent 0 -) >> $GITHUB_OUTPUT
test:
name: test
needs:
- qa
- setup
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade pip setuptools wheel
python -m pip install pytest pytest-cov
python -m pip install -r requirements.txt
python -m pip install -r ./tests/requirements_test.txt
- name: Run Tests with Repository Code
env:
LD_LIBRARY_PATH: ${{ steps.install-dependencies.outputs.lib_path }}
shell: bash -eux {0}
run: |
DYLD_LIBRARY_PATH=${{ env.LD_LIBRARY_PATH }} python -m pytest tests --cov=./ --cov-report=xml
python -m coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.xml
deploy:
needs: test
if: ${{ github.event_name == 'release' }}
name: Upload to Pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Build and publish
env:
PYPI_USERNAME: "__token__"
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry build
poetry publish --username=$PYPI_USERNAME --password=$PYPI_PASSWORD