Skip to content

fix script execution in non-PATH directories (#156) #107

fix script execution in non-PATH directories (#156)

fix script execution in non-PATH directories (#156) #107

Workflow file for this run

name: Build, Test & Deploy
on:
push:
branches:
- main
paths:
- "pyproject.toml"
- ".github/workflows/deploy.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
generate-gh-release:
description: Generate a GH release and create a new tag
type: boolean
required: false
default: false
release-to-pypi-override:
description: Generate a release to PYPI even if the version in pyproject.toml is the same as main
type: boolean
required: false
default: false
run-integration-tests:
description: Run integration testing before generating release
type: boolean
required: false
default: true
jobs:
output_workflow_inputs:
name: Output Workflow Input Values
runs-on: ubuntu-latest
steps:
- run: |
echo "run-integration-tests = ${{ github.event.inputs.run-integration-tests }}"
echo "generate-gh-release = ${{ github.event.inputs.generate-gh-release }}"
echo "release-to-pypi-override = ${{ github.event.inputs.elease-to-pypi-override }}"
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Python dependencies
run: poetry install
- name: Linter
run: |
# Lint via flake8
printf "Running flake8 linter -------->\n"
printf "flake8 count for E9,F63,F7,F82: "
poetry run flake8 ./mkdocs_multirepo_plugin --count --select=E9,F63,F7,F82 --show-source --statistics
printf "flake8 count for max-complexity=10: "
poetry run flake8 ./mkdocs_multirepo_plugin --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Unittests
run: poetry run python3 -m unittest tests.unittests -v
integration-tests:
if: ${{ github.event.inputs.run-integration-tests == 'true' || github.event.inputs.run-integration-tests == '' }}
needs: unit-tests
name: Python ${{ matrix.python-version }} and Git ${{ matrix.git-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
git-version: [2.17.0, 2.35.0, 2.37.1]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Git ${{ matrix.git-version }} from Source
run: |
sudo apt-get update
sudo apt-get install -y dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev install-info unzip
sudo apt-get -y install docbook2x
wget https://github.com/git/git/archive/refs/tags/v${{ matrix.git-version }}.zip && unzip v${{ matrix.git-version }}.zip
cd git-${{ matrix.git-version }}
make configure
./configure --prefix=/usr
make all
sudo make install
git --version
- name: Install Bats
run: ./__tests__/setup-bats.sh
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Install Package and Integration Test Deps
run: |
poetry build
pip install ./dist/*.whl
pip install -r integration-requirements.txt
- name: Integration Tests
run: ./__tests__/test-bats-ci.sh
publish-to-pypi:
if: ${{ always() && github.event.inputs.run-integration-tests != 'false' }}
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: '3.10'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Build Python distribution
run: |
pip install wheel
rm -rf dist
poetry build
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
- run: |
npm install semver
npm install toml
npm install changelog-parser
- name: Get the previous commit on main pyproject.toml
run: |
git show main~1:pyproject.toml > old_pyproject.toml
- name: Version Check
uses: actions/github-script@v6
id: generate-release
with:
script: |
const toml = require('toml')
const fs = require('fs').promises
const semver = require('semver')
var pyproject = toml.parse(await fs.readFile('pyproject.toml', 'utf8'))
var old_pyproject = toml.parse(await fs.readFile('old_pyproject.toml', 'utf8'))
if (semver.gte(old_pyproject.tool.poetry.version, pyproject.tool.poetry.version)) {
console.log(`the current package version is <= the version on main (${old_pyproject.tool.poetry.version} >= ${pyproject.tool.poetry.version})`)
return "false"
} else {
return "true"
}
result-encoding: string
- name: Publish a Python distribution to PyPI
if: ${{ steps.generate-release.outputs.result == 'true' || github.event.inputs.release-to-pypi-override == 'true' }}
uses: pypa/gh-action-pypi-publish@f3ebf87ba2883f1c40faf37d2bb42277f12179c8
with:
user: __token__
password: ${{ secrets.pypi_api_key }}
- name: Get changes from changelog
id: get-changes
uses: actions/github-script@v6
with:
script: |
const toml = require('toml')
const fs = require('fs').promises
const parseChangelog = require('changelog-parser')
var version = toml.parse(await fs.readFile('pyproject.toml', 'utf8')).tool.poetry.version
var changelog = await parseChangelog('CHANGELOG.md')
let result = {changes: changelog.versions[0].body, version: version}
console.log(result)
return result
- name: Create Release
if: ${{ steps.generate-release.outputs.result == 'true' || github.event.inputs.generate-gh-release == 'true' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ fromJSON(steps.get-changes.outputs.result).version }}
release_name: Release v${{ fromJSON(steps.get-changes.outputs.result).version }}
body: |
Changes in this Release
${{ fromJSON(steps.get-changes.outputs.result).changes }}
draft: false
prerelease: false