Skip to content

Commit

Permalink
fix(CI): add initial CI with semantic-release
Browse files Browse the repository at this point in the history
This adds initial CI for trame 2.0, which includes a pre-commit (that
currently uses black, codespell, and flake8), some simple tests, and
automatically releasing a new version with semantic release (including
a push to PyPI).

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed May 31, 2022
1 parent d8c11e6 commit a881ffb
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
skip = **/package-lock.json,*.vti,PKG-INFO,**/dist/**
ignore-words-list = hist
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]

# Just assume black did a good job with the line lengths
ignore =
E501

per-file-ignores =
# These directories will always contain "from ... import *"
trame/*:F401,F403
18 changes: 0 additions & 18 deletions .github/workflows/pr-checks.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/pypi.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test and Release

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.9"

# Install and run pre-commit
- run: |
pip install pre-commit
pre-commit install
pre-commit run --all-files
pytest:
name: Pytest ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.9]
config:
- {
name: "Linux",
os: ubuntu-latest
}
- {
name: "MacOSX",
os: macos-latest
}
- {
name: "Windows",
os: windows-latest
}

defaults:
run:
shell: bash

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install and Run Tests
run: |
pip install .
pip install -r tests/requirements.txt
pytest -s ./tests
check-and-lint:
runs-on: ubuntu-latest
name: Check and Lint
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # needed so commitlint can lint the commits

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14

- run: npm ci

- name: Lint commits
run: npx commitlint --from=${{ github.event.pull_request.base.sha }}

release:
needs: [pre-commit, pytest, check-and-lint]
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Python Semantic Release
uses: relekang/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repository_username: __token__
repository_password: ${{ secrets.PYPI_API_TOKEN }}
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
entry: black --check

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = trame
version = 2.0.0rc4
version = 2.0.0
description = Trame, a framework to build applications in plain Python
long_description = file: README.rst
long_description_content_type = text/x-rst
Expand Down Expand Up @@ -37,3 +37,6 @@ install_requires =
trame-vega
trame-vtk
trame-vuetify

[semantic_release]
version_pattern = setup.cfg:version = (\d+\.\d+\.\d+)
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
10 changes: 10 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def test_singleton():
from trame.app.singleton import Singleton

@Singleton
def new_object():
return object()

# Normally, a new object would be returned each time
# However, since this is a singleton, the same object should be returned
assert new_object() is new_object()
2 changes: 2 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_import():
from trame.assets.remote import HttpFile # noqa: F401

0 comments on commit a881ffb

Please sign in to comment.