Skip to content

Commit

Permalink
Change the CI and release process to use github actions (#5)
Browse files Browse the repository at this point in the history
* test: added nox for multi-version testing

* test: added safety for version security checking

* chore: updated and rationalised dependencies

* chore: remove no longer used readthedocs config

* ci: initial github actions test config

* ci: scrub travis configuration

* ci: try a different github action/nox config

* doc: update README tests badge

* ci: updated range of versions we test against

* chore: set up for python-semantic-release

* ci: added all the github actions for release etc

* ci: fix action references to use master branch

* ci: apparently you can you relative workflow references

* ci: fix linter (from gh_release repo)

* chore: fix linter errors
  • Loading branch information
nigelm authored Jan 29, 2022
1 parent 67013aa commit 86d9930
Show file tree
Hide file tree
Showing 22 changed files with 916 additions and 359 deletions.
22 changes: 0 additions & 22 deletions .bumpversion.cfg

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Generate documentation

on:
workflow_call:

jobs:
generate_docs:
name: Generate documentation
runs-on: ubuntu-latest
steps:
- name: Set up repository
uses: nigelm/gh_actions_python_poetry_setup@v1
with:
python-version: 3.10.2
poetry-version: 1.1.12
# needs fetch-depth to be set due to gh pages push
fetch-depth: 0

- name: Setup Git Commit Info
run: git config user.name 'github-actions[bot]' && git config user.email 'github-actions[bot]@users.noreply.github.com'

- name: Publish docs
run: poetry run mkdocs gh-deploy

# end
16 changes: 16 additions & 0 deletions .github/workflows/_full_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Run Complete Tests

on:
workflow_call:

jobs:
full_tests:
runs-on: ubuntu-latest
name: NOX test run
steps:
- uses: actions/checkout@v2
- uses: excitedleigh/[email protected]
- run: pip install poetry==1.1.12
- run: nox

# end
44 changes: 44 additions & 0 deletions .github/workflows/_linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint

on:
workflow_call:

jobs:
lint:
name: Run Linters
runs-on: ubuntu-latest
steps:

- name: Check out repository
uses: actions/checkout@v2

- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.10.2

- name: Load cached pre-commit installation
id: cached-pre-comit-install
uses: actions/cache@v2
with:
path: |
~/venv
~/.cache/pre-commit
key: precommit-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}

- name: Install dependencies
if: steps.cached-pre-comit-install.outputs.cache-hit != 'true'
run: |
python -m venv ~/venv
source ~/venv/bin/activate
pip install --upgrade pip
pip install pre-commit
shell: bash

- name: Run pre-commit set
run: |
source ~/venv/bin/activate
pre-commit run --all-files
shell: bash

# end
20 changes: 20 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run Tests

on:
workflow_call:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Set up repository
uses: nigelm/gh_actions_python_poetry_setup@v1
with:
python-version: 3.10.2
poetry-version: 1.1.12

- name: Run tests
run: make test

# end
25 changes: 25 additions & 0 deletions .github/workflows/_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Upload To Pypi

on:
workflow_call:
secrets:
PYPI_TOKEN:
description: The pypi token to use for authentication
required: true

jobs:
upload:
name: Upload To Pypi
runs-on: ubuntu-latest
environment: deployment
steps:
- name: Set up repository
uses: nigelm/gh_actions_python_poetry_setup@v1
with:
python-version: 3.10.2
poetry-version: 1.1.12

- run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- run: poetry publish --build --repository pypi

# end
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# basic set of tests
name: Deploy
on:
push:
tags:
- v*

jobs:
tests:
uses: ./.github/workflows/_test.yml
lint:
uses: ./.github/workflows/_linting.yml

upload:
needs: [tests, lint]
uses: ./.github/workflows/_upload.yml
secrets:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

docs:
needs: [tests, lint]
uses: ./.github/workflows/_docs.yml


# end
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Overall Release Process
on: workflow_dispatch
jobs:
tests:
uses: ./.github/workflows/_test.yml
lint:
uses: ./.github/workflows/_linting.yml
full_test:
needs: [tests, lint]
uses: ./.github/workflows/_full_tests.yml

release:
runs-on: ubuntu-latest
concurrency: release
needs: full_test
environment: deployment

steps:
- name: Set up repository
uses: nigelm/gh_actions_python_poetry_setup@v1
with:
python-version: 3.10.2
poetry-version: 1.1.12
# needs fetch-depth to be set due to release history deduction
fetch-depth: 0
token: ${{ secrets.GH_DEPLOY_TOKEN }}

#----------------------------------------------
# release
#----------------------------------------------
- name: Semantic Release
env:
GH_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }}
run: |
# source .venv/bin/activate
git config user.name github-actions
git config user.email [email protected]
poetry run semantic-release publish
# end
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# basic set of tests
name: Tests
on: push

jobs:
lint:
uses: ./.github/workflows/_linting.yml
tests:
uses: ./.github/workflows/_test.yml

# end
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ repos:
args: ['--max-line-length=200', '--ignore=F821', '--ignore=E203']

- repo: https://github.com/pre-commit/pre-commit
rev: v2.16.0
rev: v2.17.0
hooks:
- id: validate_manifest

- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
rev: v2.7.1
hooks:
- id: reorder-python-imports
args: [--py3-plus]
Expand Down
29 changes: 0 additions & 29 deletions .readthedocs.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

Unreleased Changes
------------------
<!--next-version-placeholder-->

<!-- insertion marker -->
[1.5.0] - 2022-01-13
--------------------
- Change schema processor to pick up many more places where array values are
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ lint: ## check style with flake8
test: ## run tests quickly with the default Python
poetry run pytest

.PHONY: nox
nox: ## run tests and other checks against multiple python versions
nox

.PHONY: servdocs
servdocs: ## serve out the mkdocs documentation
poetry run mkdocs serve
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Broadworks OCI-P Interface


[![ci](https://img.shields.io/travis/com/nigelm/broadworks_ocip.svg)](https://travis-ci.com/nigelm/broadworks_ocip)
[![Tests](https://github.com/nigelm/broadworks_ocip/workflows/Tests/badge.svg)](https://github.com/nigelm/broadworks_ocip/actions?workflow=Tests)
[![documentation](https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat)](https://nigelm.github.io/broadworks_ocip/)
[![pypi version](https://img.shields.io/pypi/v/broadworks_ocip.svg)](https://pypi.python.org/pypi/broadworks_ocip)

Expand Down
29 changes: 29 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# noxfile.py
import tempfile

import nox


@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"])
def tests(session):
session.run("poetry", "install", external=True)
session.run("pytest")


@nox.session(python="3.8")
def safety(session):
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
external=True,
)
session.install("safety")
session.run("safety", "check", f"--file={requirements.name}", "--full-report")


# end
Loading

0 comments on commit 86d9930

Please sign in to comment.