Skip to content

Commit 7be5a22

Browse files
authored
Add CI (#40)
* Create chartlets-ci.yml Add workflow for backend * Update chartlets-ci.yml * Update chartlets-ci.yml * Update chartlets-ci.yml with frontend workflow * Update chartlets-ci.yml * Update README.md * Update chartlets-ci.yml * Update and rename chartlets-ci.yml to frontend-ci.yml * Create backend-ci.yml * Update README.md * Update README.md * Update README.md * Add pypi version * Update README.md * Update README.md * Initial commit to publish.yml * Add python matrix for testing before releasing * Update publish.yml
1 parent fe2985c commit 7be5a22

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
lines changed

.github/workflows/backend-ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Backend CI workflow
2+
3+
on:
4+
push:
5+
paths:
6+
- chartlets.py/**
7+
8+
jobs:
9+
backend:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: git-checkout chartlets
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Micromamba
16+
uses: mamba-org/setup-micromamba@v1
17+
with:
18+
environment-file: chartlets.py/environment.yml
19+
20+
- name: Run unit tests
21+
shell: bash -l {0}
22+
run: |
23+
cd chartlets.py
24+
pytest

.github/workflows/frontend-ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Frontend CI workflow
2+
3+
on:
4+
push:
5+
paths:
6+
- chartlets.js/**
7+
8+
jobs:
9+
frontend:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: git-checkout chartlets
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '18.x'
19+
20+
- name: Install dependencies
21+
run: |
22+
cd chartlets.js
23+
npm install
24+
25+
- name: Linter
26+
run: |
27+
cd chartlets.js
28+
npm run lint
29+
30+
- name: Run frontend tests
31+
run: |
32+
cd chartlets.js
33+
npm run test
34+
35+
- name: Build frontend application
36+
run: |
37+
cd chartlets.js
38+
npm run build

.github/workflows/publish.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Package and Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
python-tests:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ["3.10", "3.11", "3.12"]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install .[dev]
27+
28+
- name: Lint with flake8
29+
run: |
30+
# stop the build if there are Python syntax errors or undefined names
31+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34+
35+
- name: Test with pytest
36+
run: |
37+
pytest --cov=chartlets
38+
39+
- name: Upload coverage reports to Codecov
40+
uses: codecov/codecov-action@v3
41+
env:
42+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
43+
44+
PyPi-Deploy:
45+
name: Publish Python Package to PyPI
46+
runs-on: ubuntu-latest
47+
needs: python-tests
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.x'
56+
57+
- name: Install dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install build
61+
62+
- name: Build package
63+
run: |
64+
python -m build
65+
66+
- name: Publish to PyPI
67+
run: |
68+
pip install twine
69+
python -m twine upload --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} dist/*
70+
71+
npm-tests:
72+
runs-on: ubuntu-latest
73+
74+
strategy:
75+
matrix:
76+
node-version: [16.x, 18.x, 20.x]
77+
# See supported Node.js release schedule at
78+
# https://nodejs.org/en/about/releases/
79+
80+
steps:
81+
- uses: actions/checkout@v3
82+
- name: Use Node.js ${{ matrix.node-version }}
83+
uses: actions/setup-node@v3
84+
with:
85+
node-version: ${{ matrix.node-version }}
86+
cache: 'npm'
87+
- run: npm ci
88+
- run: npm run lint
89+
- run: npm run build
90+
- run: npm run test
91+
92+
npm-Deploy:
93+
name: Publish TS-React Package to npmjs
94+
runs-on: ubuntu-latest
95+
needs: npm-tests
96+
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- name: Set up Node.js
101+
uses: actions/setup-node@v4
102+
with:
103+
node-version: '18.x'
104+
registry-url: 'https://registry.npmjs.org'
105+
- run: npm ci
106+
- run: npm run build
107+
- run: npm publish --access public
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

chartlets.js/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# chartlets
22

3+
[![Frontend CI workflow](https://github.com/bcdev/chartlets/actions/workflows/frontend-ci.yml/badge.svg)](https://github.com/bcdev/chartlets/actions/workflows/frontend-ci.yml)
4+
[![NPM Version](https://badge.fury.io/js/chartlets.svg)](https://npmjs.org/package/chartlets)
5+
![](https://img.shields.io/badge/Linting-TypeScript%20%26%20Prettier-blue?logo=typescript&logoColor=white)
6+
7+
8+
[![NPM Download Stats](https://nodei.co/npm/chartlets.png?downloads=true)](https://www.npmjs.com/package/chartlets)
9+
310
Chartlets is a software framework that allows websites developed with
411
React to be extended by server-side widgets programmed in Python or other
512
programming languages.

chartlets.py/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# chartlets
22

3+
[![Backend CI workflow](https://github.com/bcdev/chartlets/actions/workflows/backend-ci.yml/badge.svg)](https://github.com/bcdev/chartlets/actions/workflows/backend-ci.yml)
4+
[![PyPI Version](https://img.shields.io/pypi/v/chartlets)](https://pypi.org/project/chartlets/)
5+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
6+
37
Chartlets is a software framework that allows websites developed with
48
React to be extended by server-side widgets programmed in Python or other
59
programming languages.

0 commit comments

Comments
 (0)