Skip to content

Commit

Permalink
Feature/publishing (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxndtaylor authored Jun 2, 2024
2 parents e4d8a3b + cee958e commit 8c61c11
Show file tree
Hide file tree
Showing 21 changed files with 1,457 additions and 224 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Test and Report

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies on ${{ matrix.python-version }}
run: |
python -m pip install --upgrade pip
python -m pip install pdm
pdm sync --dev
- name: Test reports on ${{ matrix.python-version }}
run: pdm reports
- name: Build on ${{ matrix.python-version }}
run: pdm build
reports:
permissions:
contents: write
pull-requests: write
issues: write

runs-on: ubuntu-latest
environment: test
strategy:
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies on ${{ matrix.python-version }}
run: |
python -m pip install --upgrade pip
python -m pip install pdm
pdm sync --dev
- name: Test reports on ${{ matrix.python-version }}
run: pdm reports
- name: Update PR with reports
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
# language=javascript
script: |
const fs = require('fs')
const test_content = fs.readFileSync('reports/junit/junit.xml', 'utf8')
const coverage_content = fs.readFileSync('reports/coverage/coverage.xml', 'utf8')
const flake8_content = fs.readFileSync('reports/flake8/stats.txt', 'utf8')
const test_details = `<details><summary>Test Report</summary>\n\n\`\`\`xml\n${test_content}\n\`\`\`\n\n</details>`
const coverage_details = `<details><summary>Coverage Report</summary>\n\n\`\`\`xml\n${coverage_content}\n\`\`\`\n\n</details>`
const flake8_details = `<details><summary>Flake8 Report</summary>\n\n\`\`\`\n${flake8_content}\n\`\`\`\n\n</details>`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Reports:\n${test_details}\n${coverage_details}\n${flake8_details}`
})
- name: Build on ${{ matrix.python-version }}
run: pdm build
- name: Style
if: ${{ !cancelled() }}
run: pdm style
- name: Badges
if: ${{ !cancelled() }}
run: |
git config --global user.name 'Auto'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch origin "${GITHUB_HEAD_REF}"
git checkout "${GITHUB_HEAD_REF}"
pdm badges-only
git commit -am "Update Badges"
git push
45 changes: 45 additions & 0 deletions .github/workflows/pypi-publish-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish release

on:
push:
branches: [ "main" ]

jobs:
pypi-publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v3
- name: Build
run: pdm build
- name: Update git release tag
run: |
git config --global user.name 'Auto'
git config --global user.email '[email protected]'
pdm bump tag
git push --tags
- name: Test and get reports
run: pdm reports
- uses: "marvinpinto/action-automatic-releases@latest"
id: gh-release
with:
prerelease: false
draft: true
automatic_release_tag: latest
repo_token: "${{ secrets.GITHUB_TOKEN }}"
files: |
dist/*
badges/*.svg
reports/junit/junit.xml
reports/coverage/coverage.xml
reports/flake8/stats.txt
reports/junit/report.html
reports/coverage/html/*
reports/flake8/html/*
- name: Publish package distributions to PyPI
run: pdm publish --no-build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
reports/
htmlcov/
.tox/
.nox/
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Łukasz Langa

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.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# aliasing

![Tests Status](./badges/tests.svg)
![Coverage Status](./badges/coverage.svg)
![Flake8 Status](./badges/flake8.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

[![PyPi](https://img.shields.io/pypi/v/aliasing)](https://pypi.org/project/aliasing)

`aliasing` is a small utility library for python which adds aliases to class members using python descriptors.
1 change: 1 addition & 0 deletions badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/flake8.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/tests.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/timestamp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sun Jun 2 23:08:54 UTC 2024
Loading

0 comments on commit 8c61c11

Please sign in to comment.