Skip to content

Commit f6e5cbb

Browse files
authored
Albrja/mic-5834/Add resuable workflows (#488)
Albrja/mic-5834/Add resuable workflows Add reusable pipelines for github and jenkins - *Category*: CI - *JIRA issue*: [MIC-5834](https://jira.ihme.washington.edu/browse/MIC-5834) -adds reusable pipelines for github and jenkins ### Testing <!-- Details on how code was verified, any unit tests local for the repo, regression testing, etc. At a minimum, this should include an integration test for a framework change. Consider: plots, images, (small) csv file. *** REMINDER *** CI WILL NOT RUN ANY TESTS MARKED AS SLOW (CURRENTLY INCLUDES INTEGRATION TESTS). MANUALLY RUN SLOW TESTS LIKE `pytest --runslow` WITH EACH PR. --> - [ ] all tests pass (`pytest --runslow`)
1 parent db92ce8 commit f6e5cbb

File tree

7 files changed

+66
-65
lines changed

7 files changed

+66
-65
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,21 @@ on:
77
push:
88
pull_request:
99
workflow_dispatch:
10-
schedule:
10+
schedule:
1111
- cron: "0 8 * * *"
12-
12+
1313
jobs:
1414
build:
15-
runs-on: ubuntu-latest
1615
strategy:
1716
matrix:
1817
python-version: ["3.10", "3.11"]
19-
steps:
20-
- uses: actions/checkout@v3
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v4
23-
with:
24-
python-version: ${{ matrix.python-version }}
25-
- name: Print environment values
26-
run: |
27-
python --version
28-
cat $GITHUB_ENV
29-
- name: Update pip
30-
run: |
31-
python -m pip install --upgrade pip
32-
- name: Install dependencies
33-
run: |
34-
pip install .[dev]
35-
- name: Lint
36-
run: |
37-
pip install black==22.3.0 isort
38-
black . --check --diff
39-
isort . --check --verbose --only-modified --diff
40-
- name: Test
41-
run: |
42-
if "${{ github.event_name == 'schedule' }}"; then
43-
pytest --runslow ./tests
44-
else
45-
pytest --limit=1 ./tests
46-
fi
47-
- name: Doc build
48-
run: |
49-
make html -C docs/ SPHINXOPTS="-W --keep-going -n"
50-
- name: Doctest
51-
run: |
52-
make doctest -C docs/
53-
- name: Send mail
54-
# Notify when cron job fails
55-
if: (github.event_name == 'schedule' && failure())
56-
uses: dawidd6/action-send-mail@v2
57-
with:
58-
# mail server settings
59-
server_address: smtp.gmail.com
60-
server_port: 465
61-
# user credentials
62-
username: ${{ secrets.NOTIFY_EMAIL }}
63-
password: ${{ secrets.NOTIFY_PASSWORD }}
64-
# email subject
65-
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
66-
# email body as text
67-
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
68-
# comma-separated string, send email to
69-
to: uw_ihme_simulationscience@uw.edu
70-
# from email name
71-
from: Pseudopeople Notifications
18+
uses:
19+
ihmeuw/vivarium_build_utils/.github/workflows/build.yml@main
20+
with:
21+
dependencies: "layered_config_tree"
22+
python_version: ${{ matrix.python-version }}
23+
skip_mypy: true
24+
secrets:
25+
notify_email: ${{ secrets.NOTIFY_EMAIL }}
26+
NOTIFY_PASSWORD: ${{ secrets.NOTIFY_PASSWORD }}
27+

.readthedocs.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# This is the version for the readthedocs configuration. Version 2 ignores
22
# web-based configuration and uses everything from this file.
33
version: 2
4-
4+
sphinx:
5+
configuration: docs/source/conf.py
6+
fail_on_warning: true
7+
58
# Configure the python version and environment construction run before
69
# docs are built.
710
build:
@@ -16,9 +19,5 @@ python:
1619
extra_requirements:
1720
- docs
1821

19-
# Doc builds will fail if there are any warnings
20-
sphinx:
21-
fail_on_warning: true
22-
2322
formats:
2423
- pdf

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**1.2.1 - 02/05/25**
2+
3+
- Get python versions from python_versions.json
4+
15
**1.2.0 - 11/14/24**
26

37
- Drop support for Python 3.9

Jenkinsfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*This file uses jenkins shared library `vivarium_build_utils`,
2+
found at https://github.com/ihmeuw/vivarium_build_utils
3+
Due to Jenkins convention, importable modules must be stored
4+
in the 'vars' folder.
5+
Jenkins needs to be configured globally to use the correct branch.
6+
To configure the repo/branch go to:
7+
* Manage Jenkins
8+
* Configure System
9+
* Global Pipeline Libraries section
10+
* Library subsection
11+
* Name: The Name for the lib
12+
* Version: The branch you want to use. Throws an error
13+
for nonexistent branches.
14+
* Project Repository: Url to the shared lib
15+
* Credentials: SSH key to access the repo
16+
17+
Updating the shared repo will take affect on the next pipeline invocation.
18+
The "_" denotes that all modules will be imported from the shared library.
19+
*/
20+
@Library("vivarium_build_utils") _
21+
reusable_pipeline(scheduled_branches: ["main", "release-candidate/v.orange.rebased"], upstream_repos: ["layered_config_tree"])

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Check if we're running in Jenkins
2+
ifdef JENKINS_URL
3+
# Files are already in workspace from shared library
4+
MAKE_INCLUDES := .
5+
else
6+
# For local dev, search in parent directory
7+
MAKE_INCLUDES := ../vivarium_build_utils/resources/makefiles
8+
endif
9+
10+
PACKAGE_NAME = pseudopeople
11+
12+
# Include makefiles from vivarium_build_utils
13+
include $(MAKE_INCLUDES)/base.mk
14+
include $(MAKE_INCLUDES)/test.mk
15+

python_versions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["3.10", "3.11"]

setup.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import json
12
import sys
23
from pathlib import Path
34

45
from packaging.version import parse
56
from setuptools import find_packages, setup
67

7-
min_version, max_version = ("3.10", "3.11")
8+
with open("python_versions.json", "r") as f:
9+
supported_python_versions = json.load(f)
10+
11+
python_versions = [parse(v) for v in supported_python_versions]
12+
min_version = min(python_versions)
13+
max_version = max(python_versions)
814

9-
min_version = parse(min_version)
10-
max_version = parse(max_version)
1115

1216
if not (
1317
min_version <= parse(".".join([str(v) for v in sys.version_info[:2]])) <= max_version
@@ -56,12 +60,13 @@
5660

5761
test_requirements = [
5862
"pytest",
63+
"pytest-cov",
5964
"pytest-mock",
6065
] + dask_requirements
6166

6267
lint_requirements = [
6368
"black==22.3.0",
64-
"isort",
69+
"isort==5.13.2",
6570
]
6671

6772
doc_requirements = [

0 commit comments

Comments
 (0)