-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (92 loc) · 3.07 KB
/
build_and_test.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
name: CI (build and test)
on:
push:
branches:
- main
tags:
- "*"
pull_request:
workflow_dispatch:
release:
types: [published]
jobs:
tests:
strategy:
matrix:
os: [ubuntu-22.04, macos-latest]
python-version: ["3.9", "3.10", "3.11"]
exclude:
- os: macos-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.10'
name: "Core, Python ${{ matrix.python-version }}, ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install package
run: python -m pip install -e .[dev]
- name: Install some testing dependencies (hard-coded)
run: python -m pip install pytest pytest-cov devtools jsonschema requests wget pooch
- name: Regenerate the manifest
run: python src/fractal_helper_tasks/dev/create_manifest.py
- name: Cache Pooch folder
id: cache-pooch-folder
uses: actions/cache@v3
with:
path: ~/.cache/pooch
key: pooch-cache
- name: Check if manifest has changed
run: |
if [ -n "$(git diff --exit-code ./src/fractal_helper_tasks/__FRACTAL_MANIFEST__.json)" ]; then
echo "__FRACTAL_MANIFEST__.json has changed. Please run 'python src/fractal_helper_tasks/dev/create_manifest.py' and commit the changes."
exit 1
else
echo "__FRACTAL_MANIFEST__.json has not changed."
fi
- name: Test tasks with pytest
run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing -s --log-cli-level debug
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: jluethi/fractal-helper-tasks
deploy:
name: Deploy
needs: tests
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing on PyPi
# see https://docs.pypi.org/trusted-publishers/
id-token: write
# This permission allows writing releases
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: 👷 Build
run: |
python -m pip install build
python -m build
- name: 🚢 Publish to PyPI
# TODO remove the "if: false" line when the package is ready for pypi release
if: false
uses: pypa/gh-action-pypi-publish@release/v1
- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: './dist/*'