Skip to content

Commit

Permalink
Fix/cicd (#13)
Browse files Browse the repository at this point in the history
Fixing CI/CD, documentation and licensing
  • Loading branch information
djpugh authored Dec 17, 2023
1 parent a5ca6c6 commit c428fab
Show file tree
Hide file tree
Showing 47 changed files with 438 additions and 105 deletions.
86 changes: 52 additions & 34 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
run: nox -t lint

test:
name: Test Python ${{ matrix.py }} - ${{ matrix.os }}(${{ github.event_name }})
name: Test Python ${{ matrix.py }} - ${{ matrix.os }} (${{ github.event_name }})
runs-on: ${{ matrix.os }}-latest
needs:
- changes
Expand Down Expand Up @@ -253,7 +253,10 @@ jobs:
(github.event_name == 'pull_request' ) ||
(github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || contains(github.ref, 'main'))) ||
(github.event_name == 'release')
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -277,8 +280,6 @@ jobs:
(github.event_name == 'pull_request' && contains(github.base_ref, 'main')) ||
(github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || contains(github.ref, 'main'))) ||
(github.event_name == 'release')
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -311,9 +312,11 @@ jobs:
(github.event_name == 'pull_request' && contains(github.base_ref, 'main')) ||
(github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || contains(github.ref, 'main'))) ||
(github.event_name == 'release')
runs-on: ubuntus-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
Expand All @@ -323,18 +326,25 @@ jobs:
python -m pip install --upgrade pip
pip install nox
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Build docs
id: build_docs
run: nox -t docs
env:
SPHINX_GITHUB_CHANGELOG_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Store build artifact
- name: Select Branch
run: git checkout ${{ steps.build_docs.outputs.branch_name}}

- name: Store Docs Artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: |
docs/html/*
!docs/html/.doctrees/*
.
test-build:
name: Test Build Python ${{ matrix.py }} - ${{ matrix.os }} (${{ github.event_name }})
Expand Down Expand Up @@ -395,27 +405,25 @@ jobs:
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'dev-')) ||
github.event_name == 'release'
environment:
name: pypi
url: https://pypi.org/p/nskit
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.py }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download build
uses: actions/download-artifact@v4
with:
name: build
path: dist
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U twine
- name: Upload Packages
run: |
twine upload dist/*.whl --verbose --skip-existing
twine upload dist/*.tar.gz --verbose --skip-existing
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
if: startsWith(github.ref, 'refs/tags')
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1


publish-docs:
name: Publish Docs
Expand All @@ -429,16 +437,24 @@ jobs:
startsWith(github.ref, 'refs/tags') && !(contains(github.ref, 'gh-pages') || contains(github.ref, 'docs') || contains(github.ref, 'dev-'))
)
steps:
- name: Download docs
uses: actions/download-artifact@v4
- uses: actions/checkout@v4
with:
name: docs
path: ./docs/html
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Get Version
id: get_version
run: |
tag_name=$(echo ${{github.ref}} | cut -d/ -f3)
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
major=$(echo $tag_name | cut -d. -f0)
echo "major=$major" >> $GITHUB_OUTPUT
minor=$(echo $tag_name | cut -d. -f1)
echo "minor=$minor" >> $GITHUB_OUTPUT
patch=$(echo $tag_name | cut -d. -f2)
echo "patch=$patch" >> $GITHUB_OUTPUT
- name: Check Tag doesn't exist
id: check_tag
run: |
Expand All @@ -449,10 +465,12 @@ jobs:
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: steps.check_tag.outputs.tag_exists == false
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html
tag_name: docs-${{ steps.get_version.outputs.tag_name }}
tag_message: 'Docs ${{ steps.get_version.outputs.tag_name }}'
run: |
git config user.name github-actions
git config user.email [email protected]
mike set-default latest --config-file docs/mkdocs.yml
mike deploy -u "${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor}}" latest --config-file docs/mkdocs.yml -p
git checkout gh-pages
git pull origin
git tag docs-${{ steps.get_version.outputs.tag_name }}
git push origin
3 changes: 3 additions & 0 deletions .github/workflows/pr-labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
jobs:
pr-labeler:
runs-on: ubuntu-latest
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
steps:
- uses: TimonVS/pr-labeler-action@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
jobs:
update_draft_release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: toolmantim/[email protected]
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ env/**
# Reports
reports/*-py*
.coverage
.coverage*
reports/*
test-reports/*

Expand All @@ -61,4 +62,7 @@ mypy
.nox/*

# DS Files
**/.DS_store
**/.DS_store

# SBOM FIles
licenses*.json
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py36-plus, --keep-runtime-typing]

- repo: local
hooks:
Expand Down
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2020-202x The nskit developers

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# NSkit

``nskit`` is a python package that provides useful utilities and implementations for creating and managing a namespaced codebase for python and other programming languages.

Please see the documentation at https://djpugh.github.io/nskit for more information (the contribution guidelines can also be found at [docs/developing.md](docs/developing.md))



# ToDo:

- [*] Testspace configuration
- [*] future annotations?
- [*] Sonar coverage
- [*] FOSSA API
- [*] CodeQL
- [*] Build docs
44 changes: 36 additions & 8 deletions mkdocs.yml → docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
site_name: NSKit
repo_url: https://github.com/djpugh/nskit/
edit_uri: blob/main/docs/
docs_dir: ./docs
site_dir: ./docs/html
edit_uri: blob/main/docs/source/
docs_dir: ./source
site_dir: ./html
nav:
- index.md
- usage.md
- developing.md
- 'Developing':
- developing/index.md
- developing/license.md
- 'Test Coverage': coverage.md
- 'API':
- 'nskit.common': api/nskit.common.md
- 'nskit.mixer': api/nskit.mixer.md
Expand All @@ -18,6 +21,20 @@ exclude_docs: |
mkdocs.yml
theme:
name: material
icon:
logo: material/family-tree
favicon: assets/images/favicon.ico
features:
- navigation.instant
- navigation.prefetch
- navigation.progress
- navigation.tabs
- navigation.tabs.sticky
- navigation.path
- navigation.indexes
- search.suggest
- search.highlight
- search.share
markdown_extensions:
- admonition
- pymdownx.details
Expand All @@ -36,11 +53,22 @@ plugins:
- https://jinja.palletsprojects.com/en/3.1.x/objects.inv
paths: [src]
# https://github.com/jimporter/mike
- mike
- mike:
canonical_version: latest
# https://github.com/pawamoy/mkdocs-coverage
- coverage:
page_name: coverage # default
html_report_dir: htmlcov # default
html_report_dir: reports/htmlcov
# https://github.com/timvink/mkdocs-git-revision-date-localized-plugin
# - git-revision-date-localized
# https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages
- git-revision-date-localized:
exclude:
- coverage.md
type: iso_date
- include-markdown
# https://github.com/mondeja/mkdocs-include-markdown-plugin

# https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages

extra:
version:
provider: mike
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added docs/source/assets/images/favicon.ico
Binary file not shown.
Binary file added docs/source/assets/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/source/assets/images/favicon/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added docs/source/assets/images/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/assets/images/favicon/favicon.ico
Binary file not shown.
Binary file added docs/source/assets/images/favicon/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/assets/images/favicon/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions docs/source/assets/images/favicon/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/source/assets/images/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-72x72.png",
"sizes": "72x72",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
2 changes: 2 additions & 0 deletions docs/developing.md → docs/source/developing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Install ``nskit``:
pip install -e ".[dev]"
```

The codebase uses ``pre-commit``, so please use ``pre-commit install`` and ``pre-commit install-hooks`` to make sure the pre-commit hooks are installed correctly.

#### Checkout a branch and make changes

Create a branch to make your changes in:
Expand Down
Loading

0 comments on commit c428fab

Please sign in to comment.